Wit.ai and Facebook Messenger Integration using IRCTC APIs
Fork this repository and clone.
git clone https://github.com/{forked}/Indian-rail-fb-chatbot.git
cd Indian-rail-fb-chatbot
npm install
Go to https://wit.ai/home and create a wit app for you. Read https://wit.ai/docs/quickstart Then, go to the setting in your wit app and get the token id.
Test the bot.js with your WIT_TOKEN, and make sure the bot is working.
$WIT_TOKEN=insert_token_here node bot
First you need to make a Facebook Page at https://www.facebook.com/pages/create/?ref_type=pages_browser, since the messenger bot will be connected to your facebook page.
- Add a new app at https://developers.facebook.com/quickstarts/?platform=web. Name it and click "Create New Facebook App ID":
- Add email, select category, an add web site. (Any URL is OK):
- From https://developers.facebook.com/apps/, select the created app:
- Select Messenger and get started:
- Select the page you have created and get the Page Access Token:
- Run heroku create and push to heroku:
cd Indian-rail-fb-chatbot
heroku create
git push heroku master
- The final step is to put this server URL in the Facebook app setting. From https://developers.facebook.com/apps/, select your app and messenger. You will see Webhooks:
-
Select "Setup Webhooks", and you will see callback URL and verify token. For the callback URL put your Hherokuapp URL + "/webhook". For example, my callback URL is https://irctcfbweb.herokuapp.com/webhook.
-
Type the Verify Token that you set in the Heruku app setting. If you haven't set, the default value is "just_do_it".
-
Click all items in the Subscription Fields.
- Then, you will see the green complete!
- You may need to select the Facebook Page one more time and get the access token.
- You need to fire this command to activate your messanger.
curl -X POST "https://graph.facebook.com/v2.6/me/subscribed_apps?access_token=<PAGE_ACCESS_TOKEN>"
- You may see:
{"success":true}
- Finally, go to the Facebook page you created/selected, and talk to your bot. Enjoy!
npm test
We welcome your comments.