Send rich messages

To send a message, you need to make a post request with your bot’s Request Token available in your bot settings and send specific payload for each message type.

Message format

In the following payloads, buttons can either be:

  • postback: the basic type, once the button is tapped, the value is sent as a normal incoming message
  • web_url: depending on the channel, once this button is tapped, the URL in the value field is loaded
  • phone_number: depending on the channel, once this button is tapped, the phone number in the value field will be called

Text Message

Bot Connector - messenger text format
    {
      "type": "text",
      "content": "MY_TEXT",
    }

Quick Replies

Bot Connector - messenger Quick Replies format
  {
    "type": "quickReplies",
    "content": {
      "title": "TITLE",
      "buttons": [
        {
          "title": "BUTTON_TITLE",
          "value": "BUTTON_VALUE"
        }
      ]
    }
  }

Cards

Bot Connector - Messenger Card format
  {
    "type": "card",
    "content": {
      "title": "CARD_TITLE",
      "subtitle": "CARD_SUBTITLE",
      "imageUrl": "IMAGE_URL",
      "buttons": [
        {
          "title": "BUTTON_TITLE",
          "type": "BUTTON_TYPE",
          "value": "BUTTON_VALUE"
        }
      ]
    }
  }

Buttons

Bot Connector - Messenger Buttons format
  {
    "type": "buttons",
    "content": {
      "title": "BUTTON_TITLE",
      "buttons": [
        {
          "title": "BUTTON_TITLE",
          "type": "BUTTON_TYPE",
          "value": "BUTTON_VALUE"
        }
      ]
    }
  }
Bot Connector - Messenger Carousel format
  {
    "type": "carousel",
    "content": [
      {
        "title": "CARD_1_TITLE",
        "subtitle": "CARD_1_SUBTITLE",
        "imageUrl": "IMAGE_URL",
        "buttons": [
          {
            "title": "BUTTON_1_TITLE",
            "type": "BUTTON_1_TYPE",
            "value": "BUTTON_1_VALUE"
          }
        ]
      }
    ]
  }

List

Bot Connector - Messenger List format
  {
    "type": "list",
    "content": {
      "elements": [
        {
          "title": "ELEM_1_TITLE",
          "imageUrl": "IMAGE_URL",
          "subtitle": "ELEM_1_SUBTITLE",
          "buttons": [
            {
              "title": "BUTTON_1_TITLE",
              "type": "BUTTON_TYPE",
              "value": "BUTTON_1_VALUE"
            }
          ]
        }
      ],
      "buttons": [
        {
          "title": "BUTTON_1_TITLE",
          "type": "BUTTON_TYPE",
          "value": "BUTTON_1_VALUE"
        }
      ]
    }
  }

Picture

Bot Connector - Messenger Picture format
  {
    "type": "picture",
    "content": "IMAGE_URL",
  }

Video

Bot Connector - Messenger Video format
  {
    "type": "video",
    "content": "VIDEO_URL",
  }

Send the message

Sending a message to a conversation

POST https://api.recast.ai/connect/v1/conversations/:conversation_id/messages

Name Type Description Constraints
messages Array[Object] The messages you want to send Required

Broadcast a message to all your bot’s conversations

POST https://api.recast.ai/connect/v1/messages

Name Type Description Constraints
messages Array[Object] The messages you want to send Required

Response

If your call is successful, you should receive a 201.

Errors

A 400: bad_request error is returned if the parameter messages is missing.

A 401: unauthorized error is returned if the token provided in your request is not linked to any of your bots.

A 503: service_unavailable error is returned if the service you interact with (Facebook Messenger, Kik, Slack, etc.) is unavailable.