The tutorial use ngrok to develop messenger bot in spring boot.
- Create Messenger Bot in db developer:
- follow step with Reference 1
- Messenger4j sample code in Spring boot:
- git clone sample code:
git clone https://github.com/messenger4j/messenger4j-spring-boot-quickstart-template.git
- create Spring boot project:
- create Spring start project in Maven。
- Copy src,.gitignore,pom.xml and replace those files in Spring boot project. Then Run Maven->update project
- set up application.properties:
- messenger4j.appSecret = find the secret in Dashboard
- messenger4j.verifyToken = create random string by youself
- messenger4j.pageAccessToken = find this from messenger -> setting -> Page Access Token.
- set up webhooks:
- Callback URL:Use ngrok to create https://XXX/callback
- Verify Token: th same as the random string in application.properties
- Subscription Fields: messages, messaging_postbacks, messaging_optins, message_deliveries, message_reads, messaging_account_linking, message_echoes.
- Select the App for subscribed page:
☆★ if you’re not subscribed, the App will not give you response anymore.☆★
- git clone sample code:
Result:
Reference:
ChatBot&Chatbase 系列
Messenger4j-spring-boot-quickstart-template
Facebook for developers
My first Messenger Bot, using Java
Local developement: ngrok tool