Add more than 3 buttons in facebook messenger

Facebook messenger is only displaying 3 buttons, more than 3 buttons is being ignored by facebook messenger how can i display more than 3 buttons in facebook messenger???

Do you receieve a logger warning? This is a constraint from facebook, not rasa: rasa/facebook.py at master · RasaHQ/rasa · GitHub

@erohmensing yes i receieve a logger warning

Right, so you can’t display more than 3 buttons, as it says. Facebook’s API won’t let you.

If you can live with the limitations of quick responses (mostly that all the buttons disappear as soon as one is clicked), you can have up to 13 quick responses buttons - the following is an example code snippet from Python custom actions.

Preformatted text message5 = {

                  "text": "What do you want next?",
                  "quick_replies": [
                    {
                      "content_type": "text",
                      "payload": mess4_payload_plot,
                      "title": " ",
                      "image_url":"https://github.com/ryanmark1867/chatbot/raw/master/images/thumb_up.jpg"
                    },
                    {
                      "content_type": "text",
                      "payload": mess4_payload_stars,
                      "title": " ",
                      "image_url":"https://github.com/ryanmark1867/chatbot/raw/master/images/thumb_down.jpg"
                    },
                    {
                      "content_type": "text",
                      "payload": mess4_payload_director,
                      "title": "click to get *director*"
                    },
                    {
                      "content_type": "text",
                      "payload": mess4_payload_plot,
                      "title": "click to get *plot2*"
                    },
                    {
                      "content_type": "text",
                      "payload": mess4_payload_stars,
                      "title": "click to get stars2"
                    },
                    {
                      "content_type": "text",
                      "payload": mess4_payload_director,
                      "title": "click to get director2"
                    },
                    {
                       "content_type": "text",
                      "payload": mess4_payload_plot,
                      "title": "click to get plot3"
                    },
                    {
                      "content_type": "text",
                      "payload": mess4_payload_stars,
                      "title": "click to get stars3"
                    },
                    {
                      "content_type": "text",
                      "payload": mess4_payload_director,
                      "title": "click to get director3"
                    },
                    {
                       "content_type": "text",
                      "payload": mess4_payload_plot,
                      "title": "click to get plot4"
                    },
                    {
                      "content_type": "text",
                      "payload": mess4_payload_stars,
                      "title": "click to get stars4"
                    },
                    {
                      "content_type": "text",
                      "payload": mess4_payload_director,
                      "title": "click to get director4"
                    },
                    {
                      "content_type": "text",
                      "payload": mess4_payload_rating,
                      "title": "click to get rating"
                    }
                  ]
                }

Preformatted textdispatcher.utter_custom_json(message5)

result looks like this:

3 Likes

can we change the number from 3 to 13 something like that?

You can have up to 3 buttons or up to 13 quick respones.

I tried this but can’t see any response in the chat. What could be the issue?

Hi @shivam_soniii - assuming you are using Facebook Messenger as the client, there are a number of things that can go wrong rendering a Rasa chatbot in that client. This article covers some of the possible issues - https://markryan-69718.medium.com/tips-for-using-rasa-chatbots-with-facebook-messenger-ee631e67e30b - but keep in mind that there have been changes on the Rasa and Facebook sides since that article was written, so new issues may have been introduced in addition to what is described in the article.

Thanks, the issue is resolved. Can you please guide me how can I make it dynamic? I want to pass dynamic payload and title through actions instead of writing so many static quick replies. Is there any way I can achieve this?

Hi - if you want to have full control over what is displayed in Messenger (beyond the limited controls that Facebook offers, like quick responses and carousels), then you can try to use webview. This allows you to display an HTML page (with some limitations) in the context of Messenger. This article Using Facebook Messenger Webview with a Rasa chatbot | by Mark Ryan | The Startup | Medium describes an end-to-end example of a Rasa chatbot that uses webview to display content in Messenger. The article links to a repo with the code for the example described in the article: GitHub - ryanmark1867/webview_rasa_example: example of using Rasa with Facebook Messenger webview. Some cautions (1) I haven’t run this code for over a year, so there may be regressions in the Rasa or Facebook platforms that were introduced since I last ran it, (2) you need to get the for-pay subscription to ngrok for this implementation to work - I wasn’t able to find an alternative that provided the https URLs that Facebook insists on (3) even this “hello world” example is not simple - see the diagram in the middle of the article

Thank you for the suggestion. I’ll look into it.

1 Like