API reference

class Messenger()

Messenger

Messenger.pageSend(pageId, recipientId, responseMessage)

Send a response to a user at a page. This is the long way of sending a message. You probably want to use shortcut Response.reply() instead.

The SDK sets the messaging_type for all messages to RESPONSE because most users will only send messages in response to their users’ actions. While it’s possible to use the SDK to send other message types, setting another messaging_type is currently unsupported.

Arguments:
  • pageId (string) – Page ID
  • recipientId (string) – Recipient ID
  • responseMessage (Object) – The response message to send back
Returns:

Promise – A promise for sending the response

Messenger.send(recipientId, responseMessage)

Send a response to the default page

Deprecated since version 1.4.0: Use Response.reply() instead

Arguments:
  • recipientId (number) – Recipient ID
  • responseMessage (Object) – The response message to send back
Returns:

Promise – A promise for sending the response

Messenger.start()

Start the web server and listen for messages

Returns:void
class Response(messenger, options)

Class representing a Messenger response

Response.reply(responseMessage)

Reply with a response

Arguments:
  • responseMessage (Object) – The response message to send back
Returns:

Promise – When the reply is done