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.
cardis a description of a message that supports images. The content depends on the value of thecard.typefield:BigImageis one image.ImageGalleryis a gallery of images.ItemsListis a list of images.
directives. The content depends on the directive type:audio_playerlaunches the audio player on smart speakers.confirm_purchaseconfirms a purchase made by a skill.start_account_linkingstarts the authorization process in a skill.start_purchasestarts the purchase script.
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:
editMessageTextedits the bot’s last text message.sendStickersends static, animated, or video stickers.sendVoicesends 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.
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
SendFilestate, 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
acceptFileordeclineFileevent 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.