Overview

Skill Level: Any Skill Level

This recipe will allow you to deploy a fresh bot on your IBM Bluemix environment and make it accessible from web and Facebook Messenger in less than 10 minutes.
This app also lets you modify user input, Watson output, context, and display buttons easily.

Ingredients

  • Bluemix Account - Sign up for a trial account if you don't already have one.
  • [Optional] Facebook Account (for Messenger integration) - Sign up if you don't already have one.
  • [Optional] Telegram Account (for Telegram integration)
  • [Optional] Watson Conversation Workspace - I made a sample one in French on my GitHub repository

You can also check my Github repository for more info.

Step-by-step

  1. Deploy to Bluemix

    1. The first thing you have to do is to deploy the sample app to Blumix. button2
    2. In this example, we’ll call this app ‘sample’ and its link will be sample.mybluemix.net.
  2. Create a new Facebook Page

    1. Go to https://www.facebook.com/pages/create/
    2. Create an app.
  3. Create a new Facebook application

    1. Go to https://developers.facebook.com
    2. Log in and create a new app.
    3. Choose App for Messenger and Create an app ID.
    4. Select your new Page in Token Generation field. access_token
    5. Copy the Page Access Token.
    6. Go to Dashboard and Copy your Secret key.access_token
  4. Create a new Telegram bot

    1. In Telegram, start a new conversation with @BotFather
    2. Say ‘/newbot’ then give your bot a name and an username.
    3. Copy the HTTP token that is given to you by BotFather.
    4. Create an arbitrary webhookEndpoint for Telegram (ie. /webhook1234), and copy it for later.
  5. Create (or import) your Watson Conversation workspace

    1. Open the Watson Conversation tool, and create (or import) a new workspace.Screen-Shot-2017-04-21-at-00.00.52-copyScreen-Shot-2017-04-21-at-00.02.38-copyScreen-Shot-2017-04-21-at-00.11.12-copy
    2. Click on the three dots and choose View details.workspace_id
    3. Copy the Workspace ID.
  6. Set your envirnmental variable in Bluemix

    In order to work, your Bluemix app will need some environment variables.

    1. Go to https://bluemix.net and get to the Runtime part of the app freshly created. Click on Environment variables.bluemix_appenv_variables
    2. Use the Page Access Token previously copied as MESSENGER_PAGE_TOKEN.
    3. Use the Secret Key as MESSENGER_APP_SECRET.
    4. Set an arbitrary MESSENGER_VERIFY_TOKEN and keep it for later.
    5. Create a webhook endpoint for Facebook Messenger as you did for Telegram with what you saved earlier and set it as MESSENGER_WEBHOOKENDPOINT.
    6. Set your TELEGRAM_AUTH_TOKEN and TELEGRAM_WEBHOOKENDPOINT with what you saved earlier.
    7. Set your WORKSPACE_ID with what you copied earlier.
  7. Configure the Facebook webhooks

    1. Click on Configure webhooks
    2. Use https://sample.mybluemix.net/messenger/MESSENGER_WEBHOOKENDPOINT (watch out, we’re here using our sample link, DO NOT copy paste this link)
    3. Select messages, messages_deliveries, messaging_postbacks, and messaging_optins as subscribing fields.
  8. Configure the Telegram webhook

    1. Open the page https://api.telegram.org/botHTTP_TOKEN/setWebhook?url=https://sample.mybluemix.net/telegram/TELEGRAM_WEBHOOKENDPOINT
  9. 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.

    add_testers

    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.

16 Comments on "How to build an enhanced chatbot with Watson Conversation"

  1. Hi, thank you for your help!

    I have a problem in step 7, because I try to create a Webhook on Facebook.

    my aplication is: conversationMaster-vyktor-01.mybluemix.net

    which are the correct parameters?
    my paremeter are:

  2. mohamed.mokhtar April 11, 2017

    it seems outdated or something, you lost me on point 5 , i can’t find any of those things

    • cyrille.benoit April 20, 2017

      Hi, I’ve added some more screenshots in Step 5 so you can follow the instructions on your machine. Thank you for your feedback 😉

  3. chrisjeo93 April 18, 2017

    Hi. What do I enter in the verify token field while customising the webhooks?

    • cyrille.benoit April 20, 2017

      Hi,
      You may enter some personal text, like, for instance : test123
      Facebook will check if the token you gave it and the one from the Bluemix App are the same so it belongs to you.

  4. randywreed April 27, 2017

    I would note that when I tried to deploy this through tool pipe, I got
    “Creating route wConversationMaster.mybluemix.net…
    OK
    FAILED
    Server error, status code: 400, error code: 210003, message: The host is taken: wConversationMaster
    Finished: FAILED”

    Solution to this was to change the host in the manifest1.yml file to “rrwConversationMaster” (or whatever your intials are). I would note that if you use the Eclipse Orion Web IDE that toolchain setup for you, any changes made need to committed (use the git menu which is launched using the 2nd icon on the left) and then pushed before they will actually take effect.

  5. leowiseBLUE May 09, 2017

    Hi, I am note sure how many ppl is using this recipe, which I found an easy and interesting way to test Watson. However, after following a very similar recipe that also uses the Telegram client, the app failed after a couple of days!
    I found out that the Node-RED implementation used by Bluemix has deprecated support for Nodejs v5 so this breaks the Telegram Nodes!

    leowise

Join The Discussion