A Botkit middleware to handle Facebook Messenger's quick reply in an intuitive manner.
Using this Botkit middleware allows your controller to "listen" on Facebook Messenger quick reply payloads instead of the quick reply label/text. It also supports backward compatibility to prevent breaking any existing code.
The message object updates to the following:
message.payload = message.quick_reply.payload;
message.text = message.quick_reply.payload;
message.label = message.quick_reply.text;
message.type = eventName || 'facebook_quick_reply';
$ npm install --save botkit-fb-quick-reply
const quickReplyMiddleware = require('botkit-fb-quick-reply');
// Load the middleware
quickReplyMiddleware(controller);
// Now the controller can handle "facebook_quick_reply" events and set messages accordingly
// messages.label = quick reply text label
// message.payload = quick reply payload
// Listen to events by the payload
controller.hears('MY_QUICK_REPLY_PAYLOAD', 'facebook_quick_reply', doSomething);
// Listen to a payload from a postback OR quick reply
controller.hears('MY_QUICK_REPLY_PAYLOAD', ['facebook_quick_reply', 'facebook_postback'], doSomethingElse);
Type: object
A botkit configured controller
Configure the middleware
Type: string
Default: facebook_quick_reply
Override the default quick reply event name. For example, you can use facebook_postback
if you have overlapping functionalities from the menu or quick replies.
Type: boolean
Default: false
Triggers a message_received
in the default behavior, and in the new facebook_quick_reply
event. Thus activate this if you want backward compatibility, but want to use the newer means of handling quick reply events.
MIT © Mako AI