Developing bots for Facebook Messenger Platform with Glasfish server

Developing bots for Facebook Messenger Platform with Glasfish server

There is so much informational noise about new Facebook feature – Messenger Platform, that I could not resist to try it out for our project “Is it kosher?“.

Here are some general steps for make your own bot on a simple REST server like Glassfish.
1. register your webhooks.
I think this was one of the most complicated parts, because Facebook documentation is not quite clear.
So, I created a Constroller:

After the server is up and running, you will be able to register it for messenger API. Checkout Quick Start documentation for more details.

2. sending messages to users
After you got request from Messenger, then you can parse the message and respond properly.
To send a response, I am using the following function:

As a result user will be able to communicate with our kosher bot.