Skip to content

Messenger Response

Caleb Hiebert edited this page Nov 19, 2018 · 1 revision

The Facebook Messenger integration for GOBBL includes a number of helpers to make building messages easier.

There are 2 main types of messenger responses, standard and immediate.

Standard Responses

A standard response is created as follows

r := fb.CreateRespose(c)

This will create a standard response and add it to the context. Any changes you make to this response object will be automatically sent when the response is finished

Immediate Responses

An immediate response is created as follows

r := fb.CreateImmediateResponse(c)

The difference between the two types of responses is that the immediate response has a .Send() function, that will send the messages before the response is finished

Response Helpers

The response object has a number of helper functions for building responses.

  • r.M(*OutgoingMessage) - Adds an outgoing message to the response
  • r.Text(string) - Adds a single text message to the response
  • r.RandomText(...string) - Adds 1 random text message from the list provided to the response
  • r.Image(string) - Adds an image to the response, it accepts a url as it's only argument
  • r.QR(...QuickReply) - Adds one or more quick replies to the response

Misc Helpers

The fb package has some other methods to help with responses. These do not modify the response directly, but are still helpful.

  • fb.QRText(string, string) - Builds a text quick reply

Clone this wiki locally