Search in sources :

Example 1 with AutoReply

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;
}
Also used : AutoReply(co.aurasphere.botmill.fb.autoreply.AutoReply)

Example 2 with AutoReply

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);
        }
    });
}
Also used : MessageAutoReply(co.aurasphere.botmill.fb.autoreply.MessageAutoReply) AutoReply(co.aurasphere.botmill.fb.autoreply.AutoReply) FbBotMillResponse(co.aurasphere.botmill.fb.model.outcoming.FbBotMillResponse) UploadAttachmentResponse(co.aurasphere.botmill.fb.model.api.upload.UploadAttachmentResponse) MessageEnvelope(co.aurasphere.botmill.fb.model.incoming.MessageEnvelope) FbBotMillController(co.aurasphere.botmill.fb.model.annotation.FbBotMillController)

Example 3 with AutoReply

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);
        }
    });
}
Also used : AutoReply(co.aurasphere.botmill.fb.autoreply.AutoReply) FbBotMillResponse(co.aurasphere.botmill.fb.model.outcoming.FbBotMillResponse) MessageEvent(co.aurasphere.botmill.fb.event.message.MessageEvent) MessageEnvelope(co.aurasphere.botmill.fb.model.incoming.MessageEnvelope)

Example 4 with AutoReply

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();
}
Also used : MessageAutoReply(co.aurasphere.botmill.fb.autoreply.MessageAutoReply) AutoReply(co.aurasphere.botmill.fb.autoreply.AutoReply) FbBotMillResponse(co.aurasphere.botmill.fb.model.outcoming.FbBotMillResponse) MessageEnvelope(co.aurasphere.botmill.fb.model.incoming.MessageEnvelope) FbBotMillController(co.aurasphere.botmill.fb.model.annotation.FbBotMillController)

Aggregations

AutoReply (co.aurasphere.botmill.fb.autoreply.AutoReply)4 MessageEnvelope (co.aurasphere.botmill.fb.model.incoming.MessageEnvelope)3 FbBotMillResponse (co.aurasphere.botmill.fb.model.outcoming.FbBotMillResponse)3 MessageAutoReply (co.aurasphere.botmill.fb.autoreply.MessageAutoReply)2 FbBotMillController (co.aurasphere.botmill.fb.model.annotation.FbBotMillController)2 MessageEvent (co.aurasphere.botmill.fb.event.message.MessageEvent)1 UploadAttachmentResponse (co.aurasphere.botmill.fb.model.api.upload.UploadAttachmentResponse)1