use of co.aurasphere.botmill.fb.autoreply.AutoReply in project fb-botmill by BotMill.
the class ActionFrame method processMultipleReply.
/**
* Executes multiple replies when multiple autoreply is set.
*
* @param envelope
* the incoming message.
* @return true, if the event has been triggered.
*/
public boolean processMultipleReply(MessageEnvelope envelope) {
if (this.event == null) {
return false;
}
boolean triggered = this.event.verifyEventCondition(envelope);
if (triggered) {
beforeReply(envelope);
if (this.replies != null) {
synchronized (replies) {
for (AutoReply reply : replies) {
reply.reply(envelope);
}
}
}
afterReply(envelope);
}
return triggered;
}
use of co.aurasphere.botmill.fb.autoreply.AutoReply in project fb-botmill by BotMill.
the class AnnotatedTemplatedBehaviourTest method catchTextAndReplyWithImage.
@FbBotMillController(eventType = FbBotMillEventType.MESSAGE, text = "Hi with Image!", caseSensitive = true)
public void catchTextAndReplyWithImage(MessageEnvelope envelope) {
//
UploadAttachmentResponse response = UploadApi.uploadAttachment(AttachmentType.IMAGE, "http://vignette2.wikia.nocookie.net/nickelodeon/images/2/27/Spongebob_PNG.png/revision/latest?cb=20120702055752");
String attachmentId = response.getAttachmentId();
reply(new AutoReply() {
@Override
public FbBotMillResponse createResponse(MessageEnvelope envelope) {
String greetingMessage = "Hey There! ";
return ReplyFactory.addTextMessageOnly(greetingMessage).build(envelope);
}
});
}
use of co.aurasphere.botmill.fb.autoreply.AutoReply in project fb-botmill by BotMill.
the class BuyButtonTest method defineBehaviour.
/*
* (non-Javadoc)
*
* @see co.aurasphere.botmill.fb.FbBotDefinition#defineBehavior()
*/
public void defineBehaviour() {
// loads the annotated encryption class.
ConfigurationUtils.loadEncryptedConfigurationProperties();
// loads the annotated bot.
ConfigurationUtils.loadBotDefinitions();
addActionFrame(new MessageEvent(MESSAGE_TO_SEND), new AutoReply() {
@Override
public FbBotMillResponse createResponse(MessageEnvelope envelope) {
return ReplyFactory.addGenericTemplate().addElement("A simple Button Template with a Buy Button").addButton(ButtonFactory.createBuyButton("buy_button_payload").setPaymentSummary("USD", PaymentType.FIXED_AMOUNT, "BotMill.io").addPriceLabel("A price label", "2").setTestPayment(true).addRequestedUserInfo(RequestedUserInfo.CONTACT_PHONE).build()).endElement().build(envelope);
}
});
}
use of co.aurasphere.botmill.fb.autoreply.AutoReply in project fb-botmill by BotMill.
the class AnnotatedTemplatedBehaviourTest method initialGreeting.
/**
* Initial greeting.
*/
@FbBotMillController(eventType = FbBotMillEventType.MESSAGE_PATTERN, pattern = "(?i:hi)|(?i:hello)|(?i:hey)|(?i:good day)|(?i:home)")
public void initialGreeting(MessageEnvelope envelope) {
addReply(new AutoReply() {
@Override
public FbBotMillResponse createResponse(MessageEnvelope envelope) {
return ReplyFactory.addTypingAction(TypingAction.TYPING_ON).build(envelope);
}
});
addReply(new AutoReply() {
@Override
public FbBotMillResponse createResponse(MessageEnvelope envelope) {
String greetingMessage = "Hey There! ";
return ReplyFactory.addTextMessageOnly(greetingMessage).build(envelope);
}
});
addReply(new AutoReply() {
@Override
public FbBotMillResponse createResponse(MessageEnvelope envelope) {
String greetingMessage = "Hey There Again! ";
return ReplyFactory.addTextMessageOnly(greetingMessage).build(envelope);
}
});
executeReplies();
}
Aggregations