Skip to Content

Deploy an SAP Conversational AI ChatBot on Facebook Messenger

Create, test, and publish an SAP Conversational AI chatBot on Facebook Messenger.
You will learn
  • How to create a Facebook Messenger app
  • How to set up your app for use as a chatbot
  • How to connect your SAP Conversational AI chatbot to your app
  • How to test and publish your Messenger chatbot
thecodesterDaniel WroblewskiOctober 8, 2021
Created by
thecodester
September 22, 2021
Contributors
thecodester

Prerequisites

  • Step 1

    First, create a chatbot by following the steps in the tutorial Build Your First Chatbot with SAP Conversational AI.

    You’ll need a bot so you can connect it to Facebook Messenger, and share with others.

    Log in to complete tutorial
  • Step 2

    Your chatbot will only be available for integration on a Facebook page – not on your personal profile. This means you must either create a Facebook page or have an existing page that you can use with your bot.

    We assume your organization already has a page. If it does, continue to the next step.

    If it doesn’t, create one by doing the following:

    1. Click Create a Page.

      Facebook pages
    2. In the Business or Brand tile, click Get Started.

    3. Enter:

      Field Name Value
      Page name My Chat Bot Page
      Category Education

      Click Continue and follow the remaining instructions.

      We suggest you add a unique profile image so when you message the page later, you can more easily find your page.

      We also suggest you create a unique username for your page, also to make it easier to find. You can do this on the About tab of your page.

      Username
    Log in to complete tutorial
  • Step 3

    To publish your chatbot on your Facebook page, you need to create an app that connects SAP Conversational AI and your Facebook page.

    You do this at https://developers.facebook.com/ (make sure you are logged into Facebook).

    Facebook developers

    First, choose My Apps at the top right of the screen and then choose + Create App.

    Facebook create app

    Second, give the app a name (e.g., My Bot App) and enter your email, then click Create App ID.

    Facebook app name and email

    Complete security check, if needed.

    Log in to complete tutorial
  • Step 4
    1. On the left of your Facebook dashboard, choose the plus symbol after PRODUCTS.

    2. Find the Messenger tile, and choose Set Up.

      Messenger

    You now see Messenger under PRODUCTS on the left of the screen.

    Messenger products
    Log in to complete tutorial
  • Step 5
    1. On the left of your dashboard, choose Settings just below the Messenger product.

      Settings
    2. In Access Tokens section, click Add or Remove Pages.

      Add page to app
      • A login dialog asks you to confirm your account. Click Continue as ….

      • Select your Facebook page, and click Next.

      • Click Done.

    3. Back in the Settings screen, click Generate Token.

      Generate tokens

      Click I Understand, and copy the token, and click Done.

      Token
    4. Go back to your SAP Conversational AI bot, and open the Connect tab in your SAP Conversational AI chatbot.

      • Choose Messenger.

      • Under Get your app secret, paste the token into the Page token field.

      Leave the page open. You will soon add the secret.

    Log in to complete tutorial
  • Step 6

    On your Facebook dashboard, choose Settings > Basic.

    Basic settings

    For privacy reasons, the app secret is hidden.

    1. Choose Show.

    2. Copy the contents of the field, and then paste them into the App secret field on back in SAP Conversation AI on your chatbot’s Connect tab – in the same way as you did with the page token.

      Link text e.g., Destination screen
    3. Now that you pasted in the token and secret, click Get Tokens.

    Log in to complete tutorial
  • Step 7
    1. Go back to the Facebook dashboard and choose Products > Messenger > Settings.

    2. Go to the Webhooks section, and click Add Callback URL.

      Add Callback URL
    3. In the popup that now appears, enter the values for Callback URL and Verify Token, which you can copy from the your chatbot’s Connect tab in SAP COnversational AI.

      The values were generated when you clicked Get Tokens.

      Callback and token

      Click Verify and Save.

    4. Once your page has reloaded, click Add Subscriptions for your page.

      Link text e.g., Destination screen

      Select the first 4 fields:

      • messages

      • messaging_postbacks

      • messaging_optins

      • message_deliveries

      Link text e.g., Destination screen

      Click Save.

    Log in to complete tutorial
  • Step 8

    Your bot won’t be publicly accessible until you get approval and publish it. But you can access it as the administrator/developer.

    Take your time to test the bot and make sure everything is working properly before releasing it to the world.

    1. Go to your Facebook home page (not the bot page) and start a conversation with your bot.

    2. Click the New Message button at the bottom of the page, and enter the name of your Facebook page.

      I used the unique username DanielSAPChatBot to find my page.

      Link text e.g., Destination screen
    3. Type in text that will trigger intents of your bot.

      Conversation

    You can also grant test roles using Roles in the left-hand menu in your app page on Facebook for Developers.

    Log in to complete tutorial
  • Step 9

    You’ve been testing your bot in development. Now you can make it public and everyone can talk with it.

    1. Go back to your app in Facebook for Developers.

    2. In the menu on the left, choose Products > Messenger > Settings.

    3. In the App Review for Messenger area, and next to pages_messaging, click Add to Submission.

      Link text e.g., Destination screen

      This enables Facebook to perform mandatory verification and testing for your Messenger chatbot.
      You likely will have to provide additional information and add settings to the bot.

      To do for approval

      Once you have added all the information, click Submit for Review. It won’t take long for the Facebook review team to look at your bot and give you the green light to publish it.

      Once it is approved, a message should appear next to your submission.

      Approved
    4. Once approved, make your application live by changing the In development / Live toggle.

      Link text e.g., Destination screen
    Log in to complete tutorial
  • Step 10

    Congratulations! Your Messenger chatbot is now online on Facebook. If necessary, you can modify it, and any changes you make will appear in your Messenger chat.

    Ask others to test

    Which of the following do you require to create your Facebook Messenger bot?

    Log in to complete tutorial
Back to top