In order to aloow user send messages to a chatboot we firstly need to create a Facebook Page for our bot:
- Create a page on facebook.com/pages/create
- Choose a category Brand or product
- Choose a subcategory from a dropdrown menu and name your App
- Click Get Started
- Create an app on developers.facebook.com/quickstarts
Once an App is created:
- Go to the Dashboard
- Click Add Product (left menu)
- Choose Messenger
- Click Get Started
- Find Token Generation
- Select your page from dropdown menu Page
- You will see a just generated Token, that will be used later in the web.js file
-
Install local tunnel globally to make it accessible for everyone: $ npm install -g localtunnel
-
Start a webserver on some local port: $ lt --port 5000
-
You will see a link. Save it!
-
Create your app directory and set up your Node.js app: $ npm init
-
Install Express and body-parser: $ npm install express body-parser --save
-
Instantiate express and listen the server to port 5000
(see the Node.js) -
While creating HTTP GET and POST route method to handle the command, you should define a token. You will need it later.
-
- Go to your Facebook developer account again
- Choose Messanger Setting
- At the Webhooks click Setup Webhooks
- Fill out the Callback URL with your link, adding "/webhook" - Add a token that is written in your web.js
- Create an account on Bluemix
- Go to Watson Conversation
- Create dialogs
- Go to Credentials
- Add your workspaceID, username and pass to your code
Launch web.js