Search code examples
facebookfacebook-messengerchatbotfacebook-messenger-botfacebook-chatbot

Send message as user to Facebook Chatbot


We develop a chatbot based on the Facebook Messenger Platform.

In the middle of the conversation, we do want to show a complex UI as a WebView. When the user clicks on a button in the WebView, it should close the webview and invoke a user-question in the conversation which will be answered by our bot.

I've managed to show the WebView, send back a message to my backend and give an answer to the user.

But how can I create a new message as "the user" out of my WebView?

Sample Dialog:

Bot (in the conversation): Which hat do you want? [Button to open hat-selection-WebView]

User (in the WebView): [Click on a button in the hat-selection-WebView]

User (in the conversation): I want the green one < How can I create this message here

Bot (in the conversation): Ok, I'll send it to you soon


Solution

  • You can use "Quick Replies" for this: https://developers.facebook.com/docs/messenger-platform/send-api-reference/quick-replies

    The button text will be the message from the user.