How to Add a Persistent Menu in Facebook Messenger Bot

How to Add a Persistent Menu in Facebook Messenger Bot

The persistent menu allows you to have an always-on user interface element inside Messenger conversations. This is an easy way to help people discover and access the core functionality of your Messenger bot at any point in the conversation.

There are several applications that offer the same feature. All you need to do is signup on their website using your Facebook profile and they will be able to see all the Facebook pages that you managed and link the pages you want to manage from their app.

Before you can add a persistent menu to your Facebook Messenger Bot, you need to Enable the “Get Started” button first.

Just like how we set up the “Get Started” button, the persistent menu setup is only a few steps away.

Installing the Persistent Menu

1. Open the Postman application and create a new “POST” request project.

2. Copy and paste the following in the Request URL field.

https://graph.facebook.com/v6.0/me/messenger_profile?access_token=**PAGE_ACCESS_TOKEN**

3. Set the “access_token” field using the Facebook Page Access Token.

Add a Persistent Menu Params

4. In the “Headers” section, set the “Content/Type” to “application/json“.

Add a Persistent Menu Headers

5. In the “Body” section, select “raw” format and copy and paste the following json. The following code will create 3 menu items such as (Help, Contact Us, and Visit Website).

{
    "persistent_menu": [
        {
            "locale": "default",
            "composer_input_disabled": false,
            "call_to_actions": [
                {
                    "type": "postback",
                    "title": "Help",
                    "payload": "HELP_PAYLOAD"
                },
                {
                    "type": "postback",
                    "title": "Contact Us",
                    "payload": "CONTACT_US_PAYLOAD"
                },
                {
                    "type": "web_url",
                    "title": "Visit Website",
                    "url": "https://www.omelsoft.com/",
                    "webview_height_ratio": "full"
                }
            ]
        }
    ]
}
Add a Persistent Menu Body

6. Finally, click the “Send” button to make the request. You will see the following result if the request is successful.

Postman New Request Response

To verify that everything worked as expected and to see the persistent menu in action. You have to delete any previous conversation you’ve created with the page and start again by searching for your Facebook bot in messenger.

Persistent Menu in Action

Cromwell Bayon

He is a self-tutored programmer and a Full-Stack Developer. He strives to excel in the newest technology as possible. He has a very high sense of technicality and analytical skills which allows him to resolve any kind of issues related to technology. He also loves woodworking. Read more about him here...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.