Skip to main content

raw

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

Properties

PropertyTypeRequiredDescription
bodyObjectYesReply body. Contains channel-specific properties.
methodStringNoChannel-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:
caution
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.

caution
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": {
"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
  • Microsoft Teams
  • Salut
  • Telegram
  • Viber
  • WhatsApp (direct connection)

How to use

Send a contact in Telegram

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": {
"phone_number": "16012345678", // Required property for sendContact
"first_name": "Example company" // Required property for sendContact
},
"method": "sendContact"
});

Sending file attachments in Microsoft Teams

For scripts made for the Microsoft Teams channel, you can use the attachments property in body to send file attachments to the chat.

  • When switching to the SendFile state, the bot will send a card asking for permission to upload the file to OneDrive.
  • Depending on whether the user allows or declines the upload, an acceptFile or declineFile event will be triggered in the script.
state: SendFile
script:
$response.replies = $response.replies || [];
$response.replies.push({
"type": "raw",
"body": {
"type": "message",
"from": $request.rawRequest.from,
"recipient": $request.rawRequest.recipient,
"conversation": $request.rawRequest.conversation,
"attachments": [{
"name": "example.txt",
"contentType": "application/vnd.microsoft.teams.card.file.consent",
"content": {
"description": "This is an example text file.",
"acceptContext": {
"fileUrl": "https://example.com/file.txt"
},
"declineContext": {}
}
}],
"replyToId": $request.rawRequest.id
}
});

state: AcceptFile
event: acceptFile
a: Here is the document with all the information you need:
script:
$response.replies = $response.replies || [];
$response.replies.push({
"type": "raw",
"body": {
"type": "message",
"from": $request.rawRequest.from,
"recipient": $request.rawRequest.recipient,
"conversation": $request.rawRequest.conversation,
"attachments": [{
"contentType": "application/vnd.microsoft.teams.card.file.info",
"content": {
"uniqueId": $request.data.eventData.uniqueId
},
"contentUrl": $request.data.eventData.contentUrl,
"name": $request.data.eventData.name
}],
"replyToId": $request.rawRequest.id
}
});

state: Decline
event: declineFile
a: Unfortunately, I can’t send you the file without your consent.