This site is no longer updated.Go to new Conversational Cloud docs

raw


Use the raw reply type for using channel-specific methods.

Properties

Property Type Required Description
body Object Yes Reply body. Contains channel-specific properties.
method String No Channel-specific method.

Alice

You can pass the response properties into the body object.

  • card is a description of a message that supports images. The content depends on the value of the card.type field:
  • directives. The content depends on the directive type:

If you use the raw reply type, you need to specify the required properties for response. Otherwise, an error occurs while processing this reply in Alice.

Example:

  • Creating a card.

    {
      "type": "raw",
      "body": {
        "text": "Listen to your favorite music anywhere you are", // Required property for response
        "end_session": false,                                  // Required property for response
        "card": {
          "type": "BigImage",
          "image_id": "10123456789",
          "title": "Listen to your favorite music anywhere you are"
        }
      }
    }
  • Specifying a directive for linking accounts.

    {
      "type": "raw",
      "body": {
        "text": "Buy a book",      // Required property for response
        "end_session": false,      // Required property for response
        "directives": {
          "start_account_linking": {}
        }
      }
    }

Telegram

In method, you can use methods that Telegram supports. For example:

  • editMessageText edits the bot’s last text message.
  • sendSticker sends static, animated, or video stickers.
  • sendVoice sends audio files that are displayed as playable voice messages.

The properties to be passed into body depend on the selected method. You can find more information about methods and properties in the Telegram Bot API documentation.

If you use the raw reply type, you need to specify the required properties for the method selected. Otherwise, an error occurs while processing this reply in Telegram.

Example:

{
  "type": "raw",
  "body": {
    "chat_id": "@example",     // Required property for sendSticker
    "sticker": 12345,          // Required property for sendSticker
    "protect_content": true
   },
  "method": "sendSticker"
}

Channel restrictions

raw is only supported in the following channels:

  • Aimybox
  • Alice
  • Amazon Alexa
  • Chat API
  • Google Assistant
  • Salut
  • Telegram
  • Viber

How to use

Consider an example of using the sendContact method for a Telegram channel. When switching to the SendContact state, the bot will send a card with a phone number to the chat.

state: SendContact
    a: Thanks for the order!
    a: You can check its status by calling this phone number:
    script:
        $response.replies = $response.replies || [];
        $response.replies.push({
            "type": "raw",
            "body": {
                "chat_id": $request.rawRequest.message.chat.id, // Required property for sendContact
                "phone_number": "16012345678",                  // Required property for sendContact
                "first_name": "Example company"                 // Required property for sendContact
            },
            "method": "sendContact"
        });