Search in sources :

Example 1 with UploadAttachmentResponse

use of co.aurasphere.botmill.fb.model.api.upload.UploadAttachmentResponse 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 2 with UploadAttachmentResponse

use of co.aurasphere.botmill.fb.model.api.upload.UploadAttachmentResponse in project fb-botmill by BotMill.

the class UploadApiTest method test.

@Test
public void test() {
    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();
    Assert.notNull(attachmentId);
    logger.info("Succesfully posted attachment with Upload Api (ID: [{}])", attachmentId);
}
Also used : UploadAttachmentResponse(co.aurasphere.botmill.fb.model.api.upload.UploadAttachmentResponse) Test(org.junit.Test)

Aggregations

UploadAttachmentResponse (co.aurasphere.botmill.fb.model.api.upload.UploadAttachmentResponse)2 AutoReply (co.aurasphere.botmill.fb.autoreply.AutoReply)1 MessageAutoReply (co.aurasphere.botmill.fb.autoreply.MessageAutoReply)1 FbBotMillController (co.aurasphere.botmill.fb.model.annotation.FbBotMillController)1 MessageEnvelope (co.aurasphere.botmill.fb.model.incoming.MessageEnvelope)1 FbBotMillResponse (co.aurasphere.botmill.fb.model.outcoming.FbBotMillResponse)1 Test (org.junit.Test)1