TORM JSON模式
此頁面提供以下TORM富媒體元素的 JSON 模式:
- 文字/HTML
- 清單選擇器
- 快速回覆
- 時間選取器
- 富連結
- 自適應卡片
這些是可在指令碼中使用的 TORM 元素。 您可以在SNIPPET動作中構建這些元素以傳送給聯絡人。 在使用元素之前,請先驗證您正在用來用於支援該元素的數位通道。
您可以使用Outbound API直接傳送這些元素。 此頁面上的 TORM 範例顯示傳出 API 的messageContent參數時要遵循的模式。
JSON 結構
此頁面上描述的每個 TORM 元素的 JSON 必須正確嵌套在以下有效負載結構中:
{ "prompts": [{ "mediaSpecificObject": { "dfoMessage": { "messageContent": {
[rich content JSON]} ] } } } } } ] }
範例:
{ "prompts": [{ "mediaSpecificObject": { "dfoMessage": { "messageContent": {
"type": "PLUGIN", "payload": { "elements": [{ "id": "bf2521f4-5e85-413f-b6ed-815d1c3905f0", "type": "FILE", "filename": "photo.jpg", "url": "https://www.nice.com/-/media/niceincontact/layout/nice-logo-web-header/nice-web-logo.ashx", "mimeType": "image/jpeg"
} ] } } } } } ] }
文字/HTML
您可以傳送純文字或標有HTML代碼的文字。
{
"type": "TEXT",
"fallbackText": "Text sent as fallback if external platform can't accept rich messages.",
"payload": {
"text": "<p><b>This</b> is a successfully created outbound message.</p>"
}
}
清單選取器
清單選取器是聯絡人可以從中選擇的選項清單。 這些選項通常以疊加的方式顯示,具有更豐富的格式化功能,例如圖示、標題和副標題。 清單選取器通常允許比快速回覆更多的選項。 TORM 清單選取器有一些基於通道的限制。 選擇在對話中是持久的。
聯絡人可以在Apple Messages for Business通道上選擇多個選項。
{
"type": "LIST_PICKER",
"fallbackText": "Text sent as fallback if external platform can't accept rich messages.",
"payload": {
"title": {
"content": "Choose a color!"
},
"text": {
"content": "What is your favorite color?"
},
"options": {
"multiselect": false
}
"actions": [
{
"type": "REPLY_BUTTON",
"icon": {
"fileName": "place-kitten.jpg",
"url": "https://placekitten.com/200/300",
"mimeType": "image/jpeg"
},
"text": "red",
"description": "Like a tomato",
"postback": "/red"
},
{
"type": "REPLY_BUTTON",
"icon": {
"fileName": "place-kitten.jpg",
"url": "https://placekitten.com/200/300",
"mimeType": "image/jpeg"
},
"text": "Green",
"description": "Like an apple",
"postback": "/green"
}
]
}
快速回覆
快速回覆是帶有按鈕的文字訊息。 聯絡人可以點擊其中一個按鈕。 點擊後,其內容將作為傳出傳送。 通常,當傳送回覆時,無法單擊其他按鈕。 TORM 快速回覆有一些基於通道的限制。
{
"type": "QUICK_REPLIES",
"fallbackText": "Text sent as fallback if external platform can't accept rich messages.",
"payload": {
"text": {
"content": "Hello, we will deliver the package between 12:00 and 16:00. Please specify which day."
},
"actions": [
{
"type": "REPLY_BUTTON",
"text": "Today",
"postback": "{\"id\":\"1\"}"
},
{
"type": "REPLY_BUTTON",
"text": "Tomorrow",
"postback": "{\"id\":\"2\"}"
}
]
}
}
時間選取器
時間選取器允許您為聯絡人提供時間選擇,例如安排約會。 TORM 時間選擇器有一些基於通道的限制。
{
"type": "TIME_PICKER",
"fallbackText": "Text sent as fallback if external platform can't accept rich messages.",
"payload": {
"title": {
"content": "Check our new gadget!"
},
"timeSlots": [
{
"id": "unique-id",
"duration": 3600,
"startTime": "2017-05-26T08:27:55+00:00"
}
],
"location": {
"title": {
"content": "Check our new gadget!"
},
"latitude": 44.44,
"longitude": 55.55,
"radius": 33.3
}
}
}
富連結
富連結是帶有圖像預覽和標題的URL,可以按下這些預覽和標題來打開URL。 TORM 富連結有一些基於通道的限制。
{
"type": "RICH_LINK",
"fallbackText": "Text sent as fallback if external platform can't accept rich messages.",
"payload": {
"media": {
"fileName": "place-kitten.jpg",
"url": "https://placekitten.com/200/300",
"mimeType": "image/jpeg"
},
"title": {
"content": "Check our new gadget!"
},
"url": "https://www.google.com"
}
}
Adaptive Cards
Adaptive Cards是由Microsoft開發的一種獨立於平台的發送富媒體的方法。 Adaptive Cards僅在數位 任何與Digital Experience相關的通道、聯絡或技能。聊天頻道
促進客戶在聯絡中心互動的各種語音和數位通訊媒介。上受支援。
{
"type": "ADAPTIVE_CARD",
"fallbackText": "Url sent: https://placekitten.com",
"payload": {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.5",
"body": [{
"type": "Image",
"url": "https://placekitten.com/200/300",
"spacing": "none",
"size": "stretch"
}],
"actions": [{
"type": "Action.OpenUrl",
"title": "Show me the cats!",
"url": "https://placekitten.com"
}]
}
}