Deploy to Bluemix
Create a new Facebook Page
- Go to¬†https://www.facebook.com/pages/create/
- Create an app.
Create a new Facebook application
- Go to¬†https://developers.facebook.com
- Log in and create a new app.
- Choose App for Messenger and Create an app ID.
- Select your new Page in Token Generation field.¬†
- Copy the Page Access Token.
- Go to Dashboard and Copy your Secret key.
Create a new Telegram bot
- In Telegram, start a new conversation with¬†@BotFather
- Say ‘/newbot’ then give your bot a name and an username.
- Copy the HTTP token that is given to you by BotFather.
- Create an arbitrary webhookEndpoint for Telegram (ie. /webhook1234), and copy it for later.
Create (or import) your Watson Conversation workspace
- Open the Watson Conversation tool, and create (or import) a new workspace.
- Click on the three dots and choose View details.
- Copy the Workspace ID.
Set your envirnmental variable in Bluemix
In order to work, your Bluemix app will need some environment variables.
- Go to¬†https://bluemix.net and get to the Runtime part of the app freshly created. Click on Environment variables.
- Use the Page Access Token previously copied as¬†MESSENGER_PAGE_TOKEN.
- Use the Secret Key as¬†MESSENGER_APP_SECRET.
- Set an arbitrary¬†MESSENGER_VERIFY_TOKEN¬†and keep it for later.
- Create a webhook endpoint for Facebook Messenger as you did for Telegram with what you saved earlier and set it as¬†MESSENGER_WEBHOOKENDPOINT.
- Set your¬†TELEGRAM_AUTH_TOKEN¬†and¬†TELEGRAM_WEBHOOKENDPOINT¬†with what you saved earlier.
- Set your¬†WORKSPACE_ID¬†with what you copied earlier.
Configure the Facebook webhooks
- Click on Configure webhooks
- Use https://sample.mybluemix.net/messenger/MESSENGER_WEBHOOKENDPOINT¬†(watch out, we’re here using our sample link, DO NOT copy paste this link)
- Select messages, messages_deliveries, messaging_postbacks, and messaging_optins as subscribing fields.
Configure the Telegram webhook
Almost done !
And that’s it, your app is now fully deployed, accessible through the web directly, from Messenger, and from Telegram !
But, for now, you’re the only one able to use the Facebook app, if you want someone else to use your chatbot through the Facebook page, you need to add them as Testers or Developers.
Here is¬†a link¬†to¬†my detailed documentation on how to make this code yours and how to use every piece of code I added. (including buttons for premade answers on Messenger and Telegram)
Please let me know if anything goes wrong for you.