Message formats

Text

say "His palms are sweaty, knees weak, arms are heavy" // short form
say Text("There's vomit on his sweater already, mom's spaghetti") // long form

Markdown support is scarce for Messenger, and various clients may render it differently. As mentioned in the documentation, text formatting is only visible on a computer, and will not appear in the Messenger app on mobile.

Markdown content on mobile
Markdown content on desktop

Typing, Wait

Obviously, Wait is also supported (it simply does not display a typing indicator or anything for the given duration).

Question, Button

Both Button() and Url() button types are supported:

You can also take advantage of Facebook's "quick_reply" buttons. Here they are shown with a given payload (which would also work on the above example). There are 2 main differences between regular buttons and quick_replies:

  • you can have a maximum of 3 buttons, but up to 13 quick_reply buttons

  • quick_reply buttons go away once the user clicks on one or says something, regular buttons stay forever

  • quick_reply buttons do not support Url() types

Video, Audio, Image, File

The media components behave exactly as the Attachment Upload API does in Messenger, with the same limitations.

If for some reason, we are unable to send a file, it will fallback to a simple Url component. For this reason, third-party media players will be rendered as simple links to those players, while raw media can show as a regular file/audio/video/image in the conversation.

The main limitations to know about are:

  • file must be publicly accessible (not behind firewall, not requiring any authentication)

  • file must be < 25MB in size

  • file must be able to upload to messenger in a reasonable amount of time

Url

Send the given URL in a simple text component.

If a text parameter is present, it will be ignored, as Messenger is unable to display hyperlinks. The raw URL will always be used.

To display a nice URL, wrap it as a button to a Question or Card component.

A Carousel is essentially a collection of Card elements A single Card will display as a Carousel of 1 element.

The Card component on Messenger supports up to 3 Button or Url buttons. You can also define an optional default_action with a Url component on each card to make the card itself clickable.

Raw object

You can send any valid message as per Messenger's Send API as a raw object. For instance, taking this example from the documentation without any modification:

Full reference

For a complete reference of all the code presented on this page, refer to the following gist:

Last updated

Was this helpful?