Facebook Messenger

Integration published by Jovo | 2,353 downloads

Build apps for Facebook's Messenger platform

Facebook Messenger Platform Integration

Learn more about the Facebook Messenger Platform and its platform-specific features that can be used with the Jovo Framework.

Installation

Install the module:

Import the installed module, initialize and add it to the app object:

Configure the module:

Configurations

Automatically set greeting-text

To set the greeting-text on startup you have to set the following configuration:

Automatically set launch-payload

To set the launch-payload on startup you have to set the following configuration:

Introduction to Messenger Specific Features

You can access the messengerBot object like this:

The returned object will be an instance of MessengerBot if the current request comes from Facebook Messenger. Otherwise undefined will be returned.

Output

These sections provide an overview of Facebook Messenger specific features for output. For the basic concept, take a look here: Docs: Basic Concepts > Output.

No Reprompts

Facebook Messenger does not support reprompts. Any reprompt passed to ask will be ignored.

Multiple Messages

Facebook Messenger allows sending multiple messages.

Read more about sending messages here.

Overwrite default-output

The speech of tell and ask can be overwritten:

Additionally, quick-replies can be overwritten and added:

Sending Text

The following example shows how to send a text-message:

INFO: The text-message that was created by calling tell or ask will always be the first message to be displayed. Even if the text-method was called first.

Text Message Options

When calling the text-method an object with the following properties can be passed:

property type description
text string Required. The text that will be displayed
quickReplies QuickReply | string Optional. Quick-Replies that will be shown below the text.
messageType MessageType Optional. The type of the message. Defaults to MessageType.Response.

Sending Quick Replies

Quick-replies can be sent by passing the quickReplies property to the options of the text- or attachment-method:

Read more about quick-replies here.

In addition to manually creating a QuickReply-object, the helper classes TextQuickReply and BuiltInQuickReply can be used.

INFO: When passing a string, a TextQuickReply will be created from that string.

TextQuickReply

TextQuickReply can be used to create a QuickReply-object that displays text.

BuiltInQuickReply

BuiltInQuickReply can be used to create QuickReply-object that either displays the user's email or phone number and provides an easy to way for the user to reply with this information.

Read more about built-in quick-replies here and here.

Sending Attachments

Facebook Messenger allows sending attachments, which includes audio, videos, images and files.

Read more about sending attachments here.

Attachment Options

property type description
type AttachmentType Required. The type of the attachment.
data Buffer | string | number Required. The data to be sent with the attachment.
quickReplies QuickReply[] Optional. Quick-Replies that will be shown below the attachment.
isReusable boolean Optional. Determines whether the resource is reusable.

Sending an Action

Actions allow controlling indicators for typing and read receipts.

SenderActionType

The following actions are supported:

  • MarkSeen = 'mark_seen'
  • TypingOn = 'typing_on'
  • TypingOff = 'typing_off'

Read more here.

Sending Templates

Facebook Messenger allows sending templates.

Read more here.

GenericTemplate

The following example shows how to send a generic template:

Read more here.

ButtonTemplate

The following example shows how to send a button template:

Read more here.

MediaTemplate

The following example shows how to send a media template:

Read more here.

ReceiptTemplate

The following example shows how to send a receipt template:

Read more here.

AirlineTemplate

The following example shows how to send an airline template:

Read more here.

Facebook Messenger Changelog

Current version might be higher than the latest changes displayed below because of updates of dependencies.

3.0.15 (2020-05-04)

  • jovo-platform-facebookmessenger Improve session handling
  • jovo-platform-facebookmessenger Add configurable fetchProfile functionality

Committers: 1

3.0.11 (2020-04-06)

  • Updated Typescript to 3.8.x
  • Updated Prettier to 2.x

Committers: 2

2.x

Find the 2.x changelog here.

Join Our Newsletter

Be the first to get our free tutorials, courses, and other resources for voice app developers.