For more about using Facebook Messenger with Twilio, see the documentation on Twilio Channels.
With Twilio Autopilot, you can build Facebook Messenger bots. On this page, we'll walk you through how to link your Facebook account to Autopilot so you can get started building your Facebook Messenger bot.
- You must have a Facebook Page for your brand or business. If you don't have one follow these instructions to create one here.
- Download the Messenger App for your phone here: iOS - Android.
- Make sure you have created an Autopilot assistant to power the Facebook Messenger Bot.
Once you have the Facebook page and the Messenger app installed you'll need to link your Facebook page with Twilio, and then configure the FB Messenger channel on Twilio to point to Autopilot. We'll walk you through step by step.
- First, you need to install the FB Messenger channel on your Twilio Account. Go here and click install.
- Once installed, you'll see a Configure section.
- In the Properties section, select Use in -> Programmable SMS Inbound
- In the Credentials section, click the Facebook Log in button to link and follow the instructions. This will link your Facebook page with your Twilio Account.
- Select the Facebook page that you want to build your Bot for. You'll see most of the Configuration fields auto-populate below.
- At this point, we need to configure the Callback URL with the Autopilot URL for Facebook Messenger. So, open a new tab, and to Autopilot in the Twilio Console.
- On the left-hand menu, click Assistants. Then click on the assistant that is going to power the Facebook Messenger Bot.
- Then click Channels. You'll see a Facebook Messenger tile. Click on it and make sure you're on Configuration.
- You will see a URL, copy that URL, then go back to the FB Messenger Configuration page and paste that URL on the Callback URL field.
- Hit save and you're all set!
Now that you have Facebook Messenger configured it's time to test!
- Open your Facebook Messenger app on your mobile
- Search for the name of your Facebook page
- Send your first message, you should get a response from Autopilot
- Check the Autopilot Query logs, you should see the message you sent from Facebook Messenger in the query logs.
A string representing the unique name of the destination Task. If no TargetTask is provided, the destination task is determined by the natural language understanding.
TargetTask is useful when you want to control what task a user is routed to.
Lets you send Inbound Context to Autopilot. Should be a JSON string containing key-value pairs to insert into the Autopilot memory before starting a dialogue with the bot.
Useful for passing data stored in third party systems like a CRM into Autopilot to deliver a more contextual experience.
Example 1: Using TargetTask parameter at the end of the URL
Any message sent to number or messaging service configured with this URL will land in the handle_appointment_confirmation task.
Example 2: Passing Inbound Context with Memory
Any message sent to a bot with this URL will insert CarModel, CarMake and CarYear into the Autopilot Memory.