-
Create a new API Builder Project
-
Disable Auth (set auth to none in default.js)
-
Run the Project (appc run)
-
Use ngrok so your API will be accessible by FB
-
Follow the FB Messenger Quick Start Guide here: https://developers.facebook.com/docs/messenger-platform/getting-started/quick-start
-
Stop here since you will need API Builder APIs to enter in the Webhook section
-
Place fbwebhook.js and fbwebhookp.js in the /api folder
-
Run the Project (appc run)
-
Go to http://localhost:8080/console and show the two APIs (webhooks)
-
In the Webhooks section, click "Setup Webhooks"
-
Enter https://26bc6f28.ngrok.io/api/fbwebhook for the webhook URL
-
Enter a URL for a webhook, enter a Verify Token (XXX) and select messages and messaging_postbacks under Subscription Fields
- See the API Builder console log for
fbwebhook - fbwebhook API called (GET) Validating webhook
-
Since this worked properly, you should see a green check mark that the webhook is complete
-
Review the code for the fbwebhook GET and the validation and the token
-
In the Token Generation section, select your Page (created above)
-
Copy page token to clipboard
-
Paste the access token in the callSendAPI() method in the request options
-
Show how the code is mainly copy and pasted from the FB Messenger Quick Start Guide
-
Show how the response is just an echo of what was received
-
Restart the API Builder app
-
In the Webhooks section, you can subscribe the webhook for a specific page (Demobot) and click subscribe
-
Go to the FB Demobot home page (https://www.facebook.com/DemoBot-1437442156352884/)
-
In the lower right hand corner, bring up the chat window and search for Demobot and click on it
-
You should see a "Demobot is active now. Start a conversation"
-
Type "Hello Demobot"
-
Should see the response: "The API Builder Chatbot detected that you wrote: Hello Demobot"
-
See the console log for the following:
Received message for user 1896462583703774 and page 1437442156352884 at 1507323189868 with message:
{"mid":"mid.$cAAUbWLKh6iZlJLvibFe83aaLeYVd","seq":6143,"text":"Hi"}
Successfully sent generic message with id mid.$cAAUbWLKh6iZlJLvlUle83adD5LKX to recipient 1896462583703774
TADA!