项目作者: sayeed958

项目描述 :
Indian railway Facebook messenger chat bot application
高级语言: JavaScript
项目地址: git://github.com/sayeed958/Indian-rail-fb-chatbot.git
创建时间: 2017-01-16T09:03:20Z
项目社区:https://github.com/sayeed958/Indian-rail-fb-chatbot

开源协议:

下载


Indian-Rail-Facebook-chatbot using WIT ai

Wit.ai and Facebook Messenger Integration using IRCTC APIs

Initial Installation

Fork this repository and clone.

  1. git clone https://github.com/{forked}/Indian-rail-fb-chatbot.git
  2. cd Indian-rail-fb-chatbot
  3. npm install

Configuration

Wit Setting

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.

  1. $WIT_TOKEN=insert_token_here node bot

Facebook Page Creation

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.

Facebook App Creation

image

  • Add email, select category, an add web site. (Any URL is OK):

image

Facebook Messenger Setting

image

  • Select Messenger and get started:

image

  • Select the page you have created and get the Page Access Token:

image

Launch Server in Heroku

  • Run heroku create and push to heroku:
  1. cd Indian-rail-fb-chatbot
  2. heroku create
  3. git push heroku master

Facebook Webhooks Setting

image

  • 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.

image

  • Then, you will see the green complete!

image

  • You may need to select the Facebook Page one more time and get the access token.

image

  • You need to fire this command to activate your messanger.
  1. curl -X POST "https://graph.facebook.com/v2.6/me/subscribed_apps?access_token=<PAGE_ACCESS_TOKEN>"
  • You may see:

    1. {"success":true}
  • Finally, go to the Facebook page you created/selected, and talk to your bot. Enjoy!

Testing

Jest

  1. npm test

Contribution

We welcome your comments.