Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration of Botmill with Spring-boot #127

Closed
darrelRayen opened this issue Jun 30, 2017 · 6 comments
Closed

Integration of Botmill with Spring-boot #127

darrelRayen opened this issue Jun 30, 2017 · 6 comments

Comments

@darrelRayen
Copy link

No description provided.

@darrelRayen
Copy link
Author

Is it possible to integrate botmill with spring-boot

@alvin-reyes
Copy link
Collaborator

Yes it is.

BotMill framework is just a java library. You can call the built in class load functions we have to load the bots on your Spring-Boot start up context.

//    load the botmill.properties config.
 ConfigurationUtils.loadConfigurationFile();

//    set the tokens
FbBotMillContext.getInstance().setup( ConfigurationUtils.getConfiguration().getProperty(FB_BOTMILL_PAGE_TOKEN),ConfigurationUtils.getConfiguration().getProperty(FB_BOTMILL_VALIDATION_TOKEN));

//    load the bots (@Bot)
ConfigurationUtils.loadBotDefinitions();

@Manojjanaka
Copy link

Hi,

I got everything setup and seems everything is working fine. I can see the request in the log also. But the Bot doesn't reply to any messages. Is there any other configuration that we need to do.

12:02:38.784 DEBUG [main][FbBotMillNetworkController] Confirmation from Facebook. Recipient ID: [null], Message ID: [null], Result Message: [success]
12:02:59.911 DEBUG [http-nio-8080-exec-1][FbBot] AbstractFbot - Start Initialize
12:02:59.911 DEBUG [http-nio-8080-exec-1][FbBot] AbstractFbot - End Initialize
12:02:59.911 INFO  [http-nio-8080-exec-1][BotMillServlet] BotMill servlet started.
12:02:59.927 DEBUG [http-nio-8080-exec-1][FbBotMillServlet] JSON input: {"object":"page","entry":[{"id":"1723442377696212","time":1499162574914,"messaging":[{"sender":{"id":"1328610440586613"},"recipient":{"id":"1723442377696212"},"timestamp":1499162574757,"message":{"mid":"mid.$cAAZFhUaSwZZjPlLHpVdDQ7ZYAO6p","seq":35602,"text":"hi"}}]}]}
12:03:24.559 DEBUG [http-nio-8080-exec-2][FbBotMillServlet] JSON input: {"object":"page","entry":[{"id":"1723442377696212","time":1499162604131,"messaging":[{"sender":{"id":"1375110925911070"},"recipient":{"id":"1723442377696212"},"timestamp":1499162603940,"message":{"mid":"mid.$cAAZFgVAy_e5jPlM5pFdDQ3wpZo1b","seq":226,"text":"Hi"}}]}]}

@Manojjanaka
Copy link

Hi, This got resolved when I updated the version to RC-03-snapshot. Thanks

@alvin-reyes
Copy link
Collaborator

alvin-reyes commented Jul 4, 2017 via email

@Manojjanaka
Copy link

Actually what I did was, I added the FbBotMillServlet to the spring boot context by

 @Bean
    public ServletRegistrationBean dispatchServletRegistration() {

        ServletRegistrationBean registration = new ServletRegistrationBean(new FbBotMillServlet(), "/webhook");
        registration.setName(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
        return registration;

    }

And then I created the FbBot as follows

@Bot
public class MyBotClass extends FbBot {

    @FbBotMillController(eventType = FbBotMillEventType.MESSAGE_PATTERN, pattern = "(?i:hi)|(?i:hello)|(?i:hey)|(?i:good day)|(?i:home)")
    public void replyWithQuickReply(MessageEnvelope envelope) {
        reply(new AutoReply() {
            @Override
            public FbBotMillResponse createResponse(MessageEnvelope envelope) {
                return ReplyFactory.addTextMessageOnly("Text message with quick replies")
                        .addQuickReply("Quick reply 1", "Payload for quick reply 1").build(envelope);
            }
        });
    }
}

and used the 2.0.0-RC3-SNAPSHOT as the dependency.

You can find the sample project here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants