notice

This is documentation for Rasa Open Source Documentation v2.0.x, which is no longer actively maintained.
For up-to-date documentation, see the latest version (2.1.x).

Version: 2.0.x

rasa.core.channels.facebook

Messenger Objects

class Messenger()

Implement a fbmessenger to parse incoming webhooks and send msgs.

message

| async message(message: Dict[Text, Any], metadata: Optional[Dict[Text, Any]]) -> None

Handle an incoming event from the fb webhook.

postback

| async postback(message: Dict[Text, Any], metadata: Optional[Dict[Text, Any]]) -> None

Handle a postback (e.g. quick reply button).

MessengerBot Objects

class MessengerBot(OutputChannel)

A bot that uses fb-messenger to communicate.

send

| send(recipient_id: Text, element: Any) -> None

Sends a message to the recipient using the messenger client.

send_text_message

| async send_text_message(recipient_id: Text, text: Text, **kwargs: Any) -> None

Send a message through this channel.

send_image_url

| async send_image_url(recipient_id: Text, image: Text, **kwargs: Any) -> None

Sends an image. Default will just post the url as a string.

send_action

| async send_action(recipient_id: Text, sender_action: Text) -> None

Sends a sender action to facebook (e.g. "typing_on").

Arguments:

  • recipient_id - recipient
  • sender_action - action to send, e.g. "typing_on" or "mark_seen"

send_text_with_buttons

| async send_text_with_buttons(recipient_id: Text, text: Text, buttons: List[Dict[Text, Any]], **kwargs: Any, ,) -> None

Sends buttons to the output.

send_quick_replies

| async send_quick_replies(recipient_id: Text, text: Text, quick_replies: List[Dict[Text, Any]], **kwargs: Any, ,) -> None

Sends quick replies to the output.

send_elements

| async send_elements(recipient_id: Text, elements: Iterable[Dict[Text, Any]], **kwargs: Any) -> None

Sends elements to the output.

send_custom_json

| async send_custom_json(recipient_id: Text, json_message: Dict[Text, Any], **kwargs: Any) -> None

Sends custom json data to the output.

FacebookInput Objects

class FacebookInput(InputChannel)

Facebook input channel implementation. Based on the HTTPInputChannel.

__init__

| __init__(fb_verify: Text, fb_secret: Text, fb_access_token: Text) -> None

Create a facebook input channel.

Needs a couple of settings to properly authenticate and validate messages. Details to setup:

https://github.com/rehabstudio/fbmessenger#facebook-app-setup

Arguments:

  • fb_verify - FB Verification string (can be chosen by yourself on webhook creation)
  • fb_secret - facebook application secret
  • fb_access_token - access token to post in the name of the FB page

validate_hub_signature

| @staticmethod
| validate_hub_signature(app_secret, request_payload, hub_signature_header) -> bool

Make sure the incoming webhook requests are properly signed.

Arguments:

  • app_secret - Secret Key for application
  • request_payload - request body
  • hub_signature_header - X-Hub-Signature header sent with request

Returns:

  • bool - indicated that hub signature is validated