It should take about 15 minutes to deploy an AppSheet chatbot app to a Facebook page. Once deployed, the chatbot will respond to any Messenger messages sent to that page. 

As pre-requisites, let us assume that:

  • You have created a chatbot app with AppSheet. 
  • The app has been marked as Deployed
  • You are the owner of a Facebook page. If you don't have a page (or want to create another one for testing), go to the Facebook resource for creating pages.

These two articles will also provide useful background reading:

As an example, we will use the AppSheetDocs sample app and demonstrate how it is deployed to the Citizen Developers United page on Facebook.

Step 0: Understand the Facebook Messenger chatbot model

Any Facebook user can send start a messaging session with a Facebook page. Typically, businesses have Facebook pages and customers may start a messaging session with such a page to find out information, look for a product, ask for customer support, report an issue, etc. Normally, this would require a human being (eg: an employee of that business) to respond. This process involves delay for the customer and cost for the business. A chatbot app automates this process.

To use a chatbot on your Facebook page, you need to:

  1. Register an "app" with Facebook
  2. Configure the "app" to listen to messages coming to your Facebook page and to have the permission to respond. Also provide a link to a backend service that the "app" will send the mesages to and get the responses from. In your case, that backend service is the AppSheet chatbot app that you have built. 
  3. Configure your AppSheet app to communicate with Facebook

In other words, to deploy a chatbot app to Facebook, you will be configuring your Facebook page to hook to your AppSheet app in a few different ways. Facebook calls these "webhooks".

Step 1: Register an "app" with Facebook

 First, create a developer account with Facebook by going to this page and clicking on "Get Started". You will need to answer a few questions and then your Facebook account will be enabled to create apps.

After this, go to the app dashboard and click on "Add a New App"

This brings up a dialog that asks for an app name and then you click on "Create".

This brings up to a page with the details for your app. In the left bar, click on "Add Product" if it is not already chosen, and then hover over the Messenger pane. This will show a "Set Up" button. Click on it.

This will add the Messenger platform in your sidebar under "Products" and the Messenger settings console will be displayed. You will need to make most of your configuration changes here.

Step 2: Configure the Facebook "app" 

First, scroll to the Webhooks section and click on "Setup Webhooks"

You will now need to configure three things:

  1. Callback URL (how Facebook communicates to AppSheet): enter https://www.appsheet.com/api/chatbot/facebook
  2. Verify token (how AppSheet will know that it is Facebook communicating): enter I_like_green_eggs_and_ham_{your AppSheet app id} . Your will also find this token to copy in the chatbot section of the AppSheet app editor.
  3. Subscription fields (what permissions to give the chatbot app): make sure to always choose messages and messaging_postbacks. If your chatbot requires signin (eg: for customer service apps), then also enable messaging_account_linking

After this, if you hit "Verify and Save", this should successfully test the connection with AppSheet. If it fails, here are some possible causes:

  • Typo in the callback URL or the verify token
  • Your AppSheet app is still in the Prototype stage. Go to the AppSheet app editor and mark it as Deployed
  • AppSheet system error (unlikely)
  • Facebook system error (unlikely)

Once it succeeds, you should see a pane that looks like this. Note the "Select a Page" button. Do not click this just yet -- you will need to come back to it a couple of steps later.

Instead, scroll up to the Token Generation section and click on "Select a Page" in that section. The purpose here is to get an access token that you can provide to AppSheet. When AppSheet sends a message to Facebook on behalf of your chatbot app, this access token proves that it is talking on your behalf.

Once you select your Facebook page, you will likely see a scary/ugly authorization page that shows the permission you are giving the chatbot app you are registering. Effectively, you are letting this chatbot app message on your behalf. You need to authorize this in order for the chatbot to work. 

The red highlighted message shows up because the app is not yet reviewed by Facebook. Before you make the app public on your page, you will need to submit it for a review. But that step comes later. For now, click on "Continue as {your user name}" and accept the permissions in the next screen.

You should now have a page access token that you can click on to copy.

Now go back to the Webhooks section, select the page, and click on "Subscribe". This should succeed immediately and now your Facebook "app" is fully configured.

Step 3: Configure your AppSheet app to talk to Facebook

In your AppSheet app editor, go to the Manage > Deploy > Chatbot pane. You will need to copy in the page access token generated in the previous step and the page ID.
The Facebook page ID is found in the URL suffix when opening the Facebook page in a browser. For example, in our sample page, the URL is https://www.facebook.com/Citizen-Developers-United-1793318880931237 and the page id is 1793318880931237

Once you copy these values in, save the settings.

That's it! You should now have a working Facebook chatbot app.

Step 4: Test your chatbot

Open Facebook Messenger on your phone or in a browser and start a messaging session with your Facebook page. For example, here is the URL for a Messenger session with the example page.
https://www.messenger.com/t/1793318880931237

Your chatbot should be functional. You should see a welcome screen and subsequent interaction. Try it out!

However, at this stage, you are the only person who can view or try your chatbot. Other users who use Messenger to access your page will only have the default prior interaction mode. 

To change this, go to Facebook's app console. If you go to the Roles tab in the sidebar, you can add people as developers or testers who will then be able to interact with your chatbot via Facebook messenger.

Step 5: Make your Facebook chatbot public

After testing your chatbot and before your chatbot becomes publicly accessible, you need to submit it for review. Click on App Review in the sidebar to start the process.

You will be prompted to choose a category for your app. Choose "Apps for Messenger". Make sure to read Facebook's app review guidelines. In particular (copied from the app review guidelines):

Then, all you have to do is toggle the option to make your app public. If you have followed the steps listed here, you should not need any further approval process (i.e. you can ignore the "Submit Items for Approval" section -- that is needed only if you chose additional integrations or permissions by mistake).

Congratulations! You have a working public chatbot app. 

Any subsequent changes made to the app definition via AppSheet will reflect automatically in Facebook Messenger. 

Step 6: Note of caution

AppSheet chatbot apps are very much a beta feature. There are many more features to add, and there may be bugs or inconsistencies in the system. Please report them so that we can iron out these issues and improve the platform rapidly.

Our intent is for the chatbot app definitions to be almost identical to the mobile app definitions in terms of data, behavior and UX definition. However, some of the app features available in mobile apps are not yet replicated for chatbot apps.

Do not register multiple apps to the same Facebook page. If you do, both will attempt to respond to the same message. While there can be some cool scenarios involving multiple chatbots reacting to the same conversation, it can also be pretty confusing, so it's best to keep it simple.

Every AppSheet chatbot app gives the user the ability to opt out of the chatbot and ask for a human to intervene. So even though you can do a great deal of automation with a chatbot app, you do have to monitor conversations as well.

Did this answer your question?