Quick Start Tutorial
This tutorial will guide you through everything you need to know to build your first Messenger bot. Before you begin, choose one of the options under Requirements to get the code you will need to start, then follow the steps under Getting Started to get set up.Just want to see the finished code? Not a problem! You can fork it on GitHub.
Before you begin this quick start, make sure you have completed one of the following to ensure you have the starter code you will need. The starter code provides a basic webhook that we will use as the foundation of our Messenger bot.
Option 1: Build It Yourself
Our webhook setup guide will walk you through building your first webhook that your can use with this quick start from start to finish.Build Your Webhook
Option 2: Download It from GitHub
Download our webhook starter code from GitHub, and deploy it to a server of your choice.Download the Code
Option 3: Remix It on Glitch
If you do not have a server to deploy your webhook to, you can remix our starter webhook project on Glitch, which will provide a public URL served over HTTPS for your webhook.
To create your own webhook on Glitch, do the following:
- Open our starter webhook project on Glitch: Remix on Glitch
- Click the 'Remix Your Own' button. A copy of the project will be created for you.
- In the top-left corner, click the dropdown menu, then copy the public URL below the project description. This will be the base URL for your webhook.
Follow our app setup guide to subscribe your webhook to your Facebook app. Your webhook URL will be the Glitch URL appended with
Before you build your first Messenger bot, start by setting up the credentials for your app.
Build the Bot
In this tutorial we will build a simple Messenger bot that does the following:
Parses the message and sender's page-scoped ID from an incoming webhook event.
messaging_postbacks webhook events.
Sends messages via the Send API.
Responds to text messages with a text message.
Responds to an image attachment with a generic template that uses the received image.
Responds conditionally to a postback payload.