建立自訂資訊卡執行要求時,您可以建立文字回覆和自訂酬載。文字回覆用於純文字和 Markdown 代理回覆,自訂酬載則用於豐富回覆。所有回應類型的自訂酬載格式都具有下列基本結構:
{
"richContent": [
[
{
"type": "type-id",
...
},
{
"type": "type-id",
...
}
],
[
{
"type": "type-id",
...
},
{
"type": "type-id",
...
}
]
]
}
其餘子節說明可為自訂酬載設定的各種回覆類型。
文字回覆

文字回覆支援純文字和 Markdown。以下是幾個 Markdown 範例:
*Italic***Bold**# Title[Link text](Link URL)資料表:
Header 1 | Header 2 -------- | -------- Cell 1 | Cell 2
資訊回應類型

資訊回應類型是使用者可點選或輕觸的資訊標題卡。
下表說明各個欄位:
| 名稱 | 類型 | 說明 |
|---|---|---|
type |
string |
回應類型:「info」。 |
title |
string |
資訊卡標題。 |
subtitle |
string |
資訊卡副標題。 |
image |
object |
。 |
image.rawUrl |
string |
圖片的公開網址。 |
anchor |
object |
點選元素時要追蹤的錨定標記。 |
anchor.href |
string |
錨點的網址。 |
anchor.target |
string |
錨點的目標,預設為 _blank。 |
例如:
{
"richContent": [
[
{
"type": "info",
"title": "Info item title",
"subtitle": "Info item subtitle",
"image": {
"rawUrl": "https://example.com/images/logo.png"
},
"anchor": {
"href": "https://example.com"
}
}
]
]
}
說明回應類型

說明回應類型是一種資訊卡,可顯示多行文字。
下表說明各個欄位:
| 名稱 | 類型 | 說明 |
|---|---|---|
type |
string |
回應類型:「description」。 |
title |
string |
資訊卡標題。 |
text |
array<string> |
字串陣列,每個字串都會顯示在新的一行。 |
例如:
{
"richContent": [
[
{
"type": "description",
"title": "Description title",
"text": [
"This is text line 1.",
"This is text line 2."
]
}
]
]
}
圖片回覆類型

圖片回覆類型是使用者可點選或輕觸的圖片資訊卡。回覆類型支援參考資料方塊,可讓您將圖片來源新增為錨點連結,並附上簡短說明文字和圖示。
下表說明各個欄位:
| 名稱 | 類型 | 說明 |
|---|---|---|
type |
string |
回應類型:「image」。 |
rawUrl |
string |
圖片的公開網址。 |
accessibilityText |
string |
圖片的替代文字。 |
reference.text |
string |
參考資料方塊中顯示的文字。 |
reference.anchor.href |
string |
參考資料方塊的網址。 |
reference.anchor.target |
string |
參考方塊中錨點的目標,預設為 _blank。 |
reference.image.rawUrl |
string |
參考資料方塊中顯示的圖片。 |
例如:
{
"richContent": [
[
{
"type": "image",
"rawUrl": "https://example.com/images/logo.png",
"accessibilityText": "Example logo",
"reference": {
"text": "Logo",
"anchor": {
"href": "https://example.com/images/logo.png"
},
"image": {
"rawUrl": "https://example.com/images/logo_small.png"
}
}
}
]
]
}
您可以使用下列 CSS 變數:
| 屬性 | 輸入政策 | 預設值 | 說明 |
|---|---|---|---|
df-messenger-image-border-radius |
選用 | 8px | 圖片的邊框半徑。 |
影片回應類型

影片回覆類型會顯示影片元素,可以是直接從網址播放的影片 (直接在 Messenger 中播放),也可以是影片連結。
下表說明各個欄位:
| 名稱 | 類型 | 說明 |
|---|---|---|
type |
string |
回應類型:「video」。 |
title |
string |
影片標題 (選用)。 |
source |
object |
影片來源。 |
source.type |
string |
影片來源類型,可以是 link 或 raw。 |
source.anchor |
object |
點選元素時要追蹤的錨定標記。 |
source.embeddedPlayer |
string |
link 類型的影片可以嵌入,而非連結至播放器的網頁。這項功能僅適用於一組已知播放器,支援 youtube。 |
source.thumbnail |
object |
anchor要顯示的縮圖。 |
source.thumbnail.rawUrl |
string |
縮圖網址。 |
source.rawUrl |
string |
raw 類型影片的網址。 |
例如:
{
"richContent": [
[
{
"type": "video",
"source": {
"type": "link",
"anchor": {
"href": "https://www.youtube.com/watch?v=example"
}
}
}
]
]
}
您可以使用下列 CSS 變數:
| 屬性 | 輸入政策 | 預設值 | 說明 |
|---|---|---|---|
df-messenger-video-width |
選用 | 自動 | 影片寬度 (受 max-width\: 100% 限制)。 |
df-messenger-video-height |
選用 | 自動 | 影片高度。 |
df-messenger-video-embed-width |
選用 | 560px | 內嵌影片的寬度 (受 max-width\: 100% 限制)。 |
df-messenger-video-embed-height |
選用 | 315px | 內嵌影片的高度。 |
df-messenger-video-border |
選用 | 1px solid #e0e0e0 | 影片邊框。 |
df-messenger-video-border-radius |
選用 | 8px | 影片的邊框圓角半徑。 |
按鈕回應類型

按鈕回應類型是帶有圖示的小按鈕,可供點選或輕觸。
下表說明各個欄位:
| 名稱 | 類型 | 說明 |
|---|---|---|
type |
string |
回應類型:「按鈕」。 |
icon |
object |
按鈕圖示。 |
icon.type |
string |
Material Design 圖示庫中的圖示。預設圖示為箭頭。 |
icon.color |
string |
顏色十六進位代碼。 |
image |
object |
按鈕的圖片,優先順序高於 icon。 |
image.rawUrl |
string |
按鈕圖片的公開網址。 |
mode |
string |
選用。如果設為「blocking」,使用者必須點選按鈕,才能輸入內容。 |
text |
string |
按鈕文字。 |
anchor |
object |
點選元素時要追蹤的錨定標記。 |
anchor.href |
string |
錨點的網址。 |
anchor.target |
string |
錨點的目標,預設為 _blank。 |
event |
object |
Dialogflow CX 事件:點選按鈕時觸發。 |
例如:
{
"richContent": [
[
{
"type": "button",
"icon": {
"type": "chevron_right",
"color": "#FF9800"
},
"mode": "blocking",
"text": "Button text",
"anchor": {
"href": "https://example.com"
},
"event": {
"event": ""
}
}
]
]
}
您可以使用下列 CSS 變數:
| 屬性 | 輸入政策 | 預設值 | 說明 |
|---|---|---|---|
df-messenger-button-border |
選用 | 無 | 按鈕邊框。 |
df-messenger-button-border-radius |
選用 | 8px | 按鈕的邊框半徑。 |
df-messenger-button-font-color |
選用 | #1f1f1f | 按鈕的文字顏色。 |
df-messenger-button-font-family |
選用 | "Google Sans", "Helvetica Neue", sans-serif | 按鈕的字型系列。 |
df-messenger-button-font-size |
選用 | 14px | 按鈕的字型大小。 |
df-messenger-button-padding |
選用 | 12px | 按鈕的邊框間距。 |
df-messenger-button-icon-spacing |
選用 | 12px | 按鈕圖示和文字之間的間距。 |
df-messenger-button-icon-font-size |
選用 | 24px | 按鈕圖示的大小。 |
df-messenger-button-image-size |
選用 | 24px | 按鈕圖片的大小。 |
df-messenger-button-image-offset |
選用 | 0 | 按鈕圖片的偏移量,允許負值來抵消邊框間距。 |
df-messenger-button-text-align |
選用 | center | 按鈕的文字對齊方式。 |
df-messenger-button-text-wrap |
選用 | normal | 使用 nowrap 禁止多行按鈕。 |
清單回應類型

清單回覆類型是一張資訊卡,可讓您從多個選項中選取。回應包含 list 和 divider 回應類型的陣列。
下表說明 list 類型:
| 名稱 | 類型 | 說明 |
|---|---|---|
type |
string |
回應類型:「list」。 |
title |
string |
選項標題。 |
subtitle |
string |
選項副標題。 |
event |
object |
點選選項時觸發的 Dialogflow CX 事件。 |
anchor |
object |
點選元素時要追蹤的錨定標記。 |
anchor.href |
string |
錨點的網址。 |
anchor.target |
string |
錨點的目標,預設為 _blank。 |
image |
object |
。 |
image.rawUrl |
string |
參考圖像的公開網址。 |
event.event |
string |
點選選項時觸發的事件名稱。 |
下表說明 divider 類型:
| 名稱 | 類型 | 說明 |
|---|---|---|
type |
string |
回應類型:「分隔線」。 |
例如:
{
"richContent": [
[
{
"type": "list",
"title": "List item 1 title",
"subtitle": "List item 1 subtitle",
"event": {
"event": ""
}
},
{
"type": "list",
"title": "List item 2 title",
"subtitle": "List item 2 subtitle",
"event": {
"event": ""
}
}
]
]
}
您可以使用下列 CSS 變數:
| 屬性 | 輸入政策 | 預設值 | 說明 |
|---|---|---|---|
df-messenger-list-padding |
選用 | 16px | 清單元素的邊框間距。 |
df-messenger-list-inset |
選用 | 0 | 清單元素的額外水平「內凹」(除了邊框間距外),用於控制元素之間的邊框展開。 |
df-messenger-list-spacing |
選用 | 10px | 清單元素之間的垂直間距。 |
df-messenger-list-border-bottom |
選用 | 1px solid #e0e0e0 | 清單元素之間的框線。 |
摺疊式回應類型

手風琴式回覆類型是一種小型資訊卡,輕觸或點按即可展開並顯示更多文字。
下表說明各個欄位:
| 名稱 | 類型 | 說明 |
|---|---|---|
type |
string |
回覆類型:「accordion」。 |
title |
string |
摺疊元素標題。 |
subtitle |
string |
摺疊元素副標題。 |
image |
object |
。 |
image.rawUrl |
string |
圖片的公開網址。 |
text |
string |
摺疊元素文字。 |
例如:
{
"richContent": [
[
{
"type": "accordion",
"title": "Accordion title",
"subtitle": "Accordion subtitle",
"image": {
"rawUrl": "https://example.com/images/logo.png"
},
"text": "Accordion text"
}
]
]
}
建議方塊回覆類型

建議方塊回覆類型可讓您提供可點選的建議方塊清單。
下表說明各個欄位:
| 名稱 | 類型 | 說明 |
|---|---|---|
type |
string |
回應類型:「chips」。 |
options |
array<object> |
選項物件陣列。 |
options[].mode |
string |
選用。如果設為「blocking」,使用者必須點選方塊,才能輸入內容。 |
options[].text |
string |
選項文字。 |
options[].image |
object |
選用。。 |
options[].image.rawUrl |
string |
圖片的公開網址 (選用)。 |
options[].anchor |
object |
選用。點選元素時要追蹤的錨定標記。 |
options[].anchor.href |
string |
錨點的網址。 |
options[].anchor.target |
string |
錨點的目標,預設為 _blank。 |
例如:
{
"richContent": [
[
{
"type": "chips",
"options": [
{
"mode": "blocking",
"text": "Chip 1",
"image": {
"rawUrl": "https://example.com/images/logo.png"
},
"anchor": {
"href": "https://example.com"
}
},
{
"text": "Chip 2",
"image": {
"rawUrl": "https://example.com/images/logo.png"
},
"anchor": {
"href": "https://example.com"
}
}
]
}
]
]
}
您可以提供下列 CSS 變數:
| 屬性 | 輸入政策 | 預設值 | 說明 |
|---|---|---|---|
df-messenger-chips-spacing |
選用 | 10px | 方塊與前一則訊息之間的間距。 |
df-messenger-chips-border-color |
選用 | #e0e0e0 | 方塊的邊框顏色。 |
df-messenger-chips-border-color-hover |
選用 | #e0e0e0 | 滑鼠懸停時方塊的框線顏色。 |
df-messenger-chips-border-radius |
選用 | 999px | 方塊的邊框半徑。 |
df-messenger-chips-background |
選用 | 白色 | 方塊的背景。 |
df-messenger-chips-background-hover |
選用 | rgba(68, 71, 70, 0.08) |
懸停時方塊的背景。 |
df-messenger-chips-padding |
選用 | 6px 16px | 方塊的邊框間距。 |
df-messenger-chips-font-color |
選用 | 黑色 | 方塊的文字顏色。 |
df-messenger-chips-font-family |
選用 | "Google Sans", "Helvetica Neue", sans-serif | 方塊的字型系列。 |
df-messenger-chips-font-size |
選用 | 14px | 方塊的文字大小。 |
df-messenger-chips-font-weight |
選用 | normal | 方塊的字型粗細。 |
df-messenger-chips-font-weight-hover |
選用 | normal | 懸停時方塊的字型粗細。 |
df-messenger-chips-box-shadow |
選用 | 0 2px 2px 0 rgba(0, 0, 0, 0.24) |
方塊陰影 |
df-messenger-chips-content-align |
選用 | flex-start | 方塊中內容 (例如圖片) 的垂直對齊方式。 |
df-messenger-chips-text-wrap |
選用 | nowrap | 使用 normal 允許顯示多行方塊。 |
引用功能回覆類型

引用內容回覆類型會向使用者提供可點選的引用連結清單。
下表說明各個欄位:
| 名稱 | 類型 | 說明 |
|---|---|---|
type |
string |
回應類型:「match_citations」。 |
citations |
array<object> |
Citation 物件陣列。 |
citations[].title |
string |
引用標題。 |
citations[].subtitle |
string |
引用副標題 (忽略)。 |
citations[].anchor |
object |
點選元素時要追蹤的錨定標記。 |
citations[].anchor.href |
string |
錨點的網址。 |
citations[].anchor.target |
string |
錨點的目標,預設為 _blank。 |
例如:
{
"richContent": [
[
{
"type": "match_citations",
"citations": [
{
"title": "Source 1",
"subtitle": "",
"anchor": {
"href": "https://example.com/1"
}
},
{
"title": "Source 2",
"subtitle": "",
"anchor": {
"href": "https://example.com/2"
}
}
]
}
]
]
}
您可以使用下列 CSS 變數:
| 屬性 | 輸入政策 | 預設值 | 說明 |
|---|---|---|---|
df-messenger-citations-spacing |
選用 | 10px | 引用前一則訊息時,上方會顯示空格。 |
df-messenger-citations-message-display |
選用 | 模塊 | 定義引用內容上方附註的顯示方式,允許的值為 block 或 none。 |
df-messenger-citations-message-font-color |
選用 | #041e49 | 引用內容上方附註的文字顏色。 |
df-messenger-citations-message-font-size |
選用 | 12px | 引用內容上方附註的文字大小。 |
df-messenger-citations-flex-direction |
選用 | 列 | 引文的彈性方向屬性,建議使用 row (水平,含換行符號) 或 column (垂直)。 |
df-messenger-citations-border-color |
選用 | #3279f9 | 引文的邊框顏色。 |
df-messeenger-citations-border-color-hover |
選用 | #3279f9 | 滑鼠游標懸停在引用內容上時的邊框顏色。 |
df-messenger-citations-border-radius |
選用 | 4px | 引用的邊框半徑。 |
df-messenger-citations-padding |
選用 | 8px | 引用內容的邊框間距。 |
df-messenger-citations-background |
選用 | 白色 | 引用內容的背景。 |
df-messenger-citations-background-hover |
選用 | rgba(68, 71, 70, 0.08) |
滑鼠游標懸停在引用資料上時的背景。 |
df-messenger-citations-font-color |
選用 | #3279f9 | 引用的文字顏色。 |
df-messenger-citations-font-family |
選用 | "Google Sans", "Helvetica Neue", sans-serif | 引用內容的字型系列。 |
df-messenger-citations-font-size |
選用 | 11px | 引用文字的大小。 |
df-messenger-citations-icon-font-size |
選用 | 14px | 引用圖示的文字大小。 |
df-messenger-citations-font-weight |
選用 | normal | 引文的字型粗細。 |
df-messenger-citations-font-weight-hover |
選用 | normal | 懸停時引用內容的字型粗細。 |
df-messenger-citations-icon-spacing |
選用 | 4px | 引用內容中圖示和文字之間的間距。 |
df-messenger-citations-box-shadow |
選用 | 無 | 引用的方塊陰影。 |
檔案回覆類型

檔案回應類型會顯示可下載的檔案元素清單。使用者只要點選錨定元素,即可下載檔案。
下表說明各個欄位:
| 名稱 | 類型 | 說明 |
|---|---|---|
type |
string |
回應類型:「files」。 |
files |
array<object> |
檔案物件陣列。 |
files[].name |
string |
檔案名稱。 |
files[].image |
object |
檔案圖片。 |
files[].image.rawUrl |
string |
圖片的檔案公開網址。 |
files[].anchor |
object |
Anchor:下載檔案。 |
files[].anchor.href |
string |
錨點的網址。 |
files[].anchor.target |
string |
錨點的目標,預設為 _blank。 |
例如:
{
"richContent": [
[
{
"type": "files",
"files": [
{
"name": "instructions.pdf",
"image": {
"rawUrl":
"https://fonts.gstatic.com/s/i/short-term/release/googlesymbols/cloud_download/default/24px.svg"
},
"anchor": {
"href": "https://example.com/instructions.pdf"
}
},
{
"name": "data.csv",
"image": {
"rawUrl":
"https://fonts.gstatic.com/s/i/short-term/release/googlesymbols/csv/default/24px.svg"
},
"anchor": {
"href": "https://example.com/data.csv"
}
}
]
}
]
]
}
可提供的 CSS 變數如下:
| 屬性 | 輸入政策 | 預設值 | 說明 |
|---|---|---|---|
df-messenger-files-spacing |
選用 | 10px | 檔案與上一則訊息之間的間距。 |
df-messenger-files-distance |
選用 | 8px | 清單中檔案之間的距離。 |
df-messenger-files-flex-direction |
選用 | 列 | 檔案的彈性方向屬性,建議使用 row (水平,含換行符號) 或 column (垂直)。 |
df-messenger-files-background |
選用 | 白色 | 檔案背景。 |
df-messenger-files-border |
選用 | 1px solid #e0e0e0 | 檔案邊框。 |
df-messenger-files-border-radius |
選用 | 999px | 檔案的邊框半徑。 |
df-messenger-files-box-shadow |
選用 | 0 2px 2px 0 rgba(0, 0, 0, 0.24) |
檔案的方塊陰影。 |
df-messenger-files-padding |
選用 | 6px 16px | 檔案的填補。 |
df-messenger-files-font-color |
選用 | #1f1f1f | 檔案的文字顏色。 |
df-messenger-files-font-family |
選用 | "Google Sans", "Helvetica Neue", sans-serif | 檔案的字型系列。 |
df-messenger-files-font-size |
選用 | 14px | 檔案的文字大小。 |
df-messenger-files-font-weight |
選用 | normal | 檔案的字型粗細。 |
df-messenger-files-background-hover |
選用 | 白色 | 滑鼠游標懸停在檔案上時的背景。 |
df-messenger-files-border-hover |
選用 | 1px solid #e0e0e0 | 滑鼠游標懸停在檔案上時,檔案的邊框。 |
df-messenger-files-font-weight-hover |
選用 | normal | 滑鼠游標懸停在檔案上時的字型粗細。 |
df-messenger-files-image-offset |
選用 | 0 0 0 -8px | 圖片左側的偏移量。 |
df-messenger-files-image-size |
選用 | 18px | 左側圖片的大小。 |
df-messenger-files-text-spacing |
選用 | 8px | 左側圖片文字與右側文字圖示之間的距離。 |
df-messenger-files-icon-offset |
選用 | 0 -8px 0 0 | 下載圖示在右側的偏移量。 |
df-messenger-files-icon-size |
選用 | 18px | 右側下載圖示的大小。 |
df-messenger-files-icon-font-color |
選用 | #444746 | 右側下載圖示的顏色。 |
HTML 回應類型

HTML 回應類型會向使用者提供 HTML 訊息。
下表說明各個欄位:
| 名稱 | 類型 | 說明 |
|---|---|---|
type |
string |
回應類型:「html」。 |
html |
string |
訊息的文字內容,支援 HTML。 |
支援的 HTML 代碼:
a:錨定元素 (用於建立超連結)。b- 粗體元素 (用於將文字設為粗體)。i- 斜體元素 (用於將文字設為斜體)。u:底線元素 (用於為文字加上底線)。h1:標題 1 元素 (用於網頁的主要標題)。h2- 標題 2 元素 (用於副標題)。h3- 標題 3 元素 (用於子副標題)。p- 段落元素 (用於建立文字段落)。br:換行元素 (用於在段落中建立換行)。table:表格元素 (用於建立表格)。tr:表格列元素 (用於在表格中建立列)。thead:表格標頭元素 (用於在表格中建立標頭)。th- 表格標頭資料或儲存格元素 (用於在表格標頭列中建立儲存格)。tbody- 表格主體元素 (用於在表格中建立主體)。td:表格資料或儲存格元素 (用於在表格列中建立儲存格)。ul:未排序的清單元素 (用於建立項目符號清單)。ol:已排序的清單元素 (用於建立編號清單)。li- 清單項目元素 (用於在清單中建立項目)。img- 圖片元素 (用於顯示圖片,另請參閱url-allowlistHTML 自訂)。div- 容器元素。span:內嵌容器元素。
例如:
{
"richContent": [
[
{
"type": "html",
"html": "<b>Bold text</b> <i>Italic text</i> <u>Underlined text</u>"
}
]
]
}
設定 HTML 和 Markdown 樣式
對於錨定元素 (包括 HTML a 元素和 Markdown 連結),您可以提供下列 CSS 變數:
| 屬性 | 輸入政策 | 預設值 | 說明 |
|---|---|---|---|
df-messenger-link-decoration |
選用 | 底線 | 連結元素的裝飾。 |
df-messenger-link-font-color |
選用 | #0b57d0 | 未造訪連結元素的字型顏色。 |
df-messenger-link-visited-font-color |
選用 | #0b57d0 | 已造訪連結元素的字型顏色。 |
df-messenger-link-hover-font-color |
選用 | #0b57d0 | 將游標懸停在連結元素上時的字型顏色。 |
df-messenger-link-background |
選用 | 透明 | 連結元素的背景。 |
df-messenger-link-padding |
選用 | 0 | 連結元素的邊框間距。 |
df-messenger-link-border |
選用 | 無 | 連結元素的框線。 |
df-messenger-link-border-radius |
選用 | 0 | link 元素的邊框半徑。 |
您可以對表格元素 (HTML table 元素和 Markdown 表格) 使用下列 CSS 變數:
| 屬性 | 輸入政策 | 預設值 | 說明 |
|---|---|---|---|
df-messenger-table-font-size |
選用 | 14px | 表格元素中的文字大小。 |
df-messenger-table-font-color |
選用 | #1f1f1f | 表格元素中的文字顏色。 |
df-messenger-table-align |
選用 | 向左鍵 | 表格儲存格中的文字對齊方式。 |
df-messenger-table-padding |
選用 | 0 | 表格儲存格中的邊框間距。 |
df-messenger-table-border-collapse |
選用 | separate | 表格的邊框收合模式,使用 separate 啟用 border-radius。 |
df-messenger-table-border-radius |
選用 | 0 | 表格的邊框圓角半徑。 |
df-messenger-table-header-border-radius |
選用 | 0 | 表格標頭的邊框半徑。 |
df-messenger-table-border-top |
選用 | 無 | 表格列的頂端框線。 |
df-messenger-table-border-top-first |
選用 | 無 | 第一個表格列的上框線。 |
df-messenger-table-border-bottom |
選用 | 無 | 表格列的底部邊框。 |
df-messenger-table-border-bottom-last |
選用 | 無 | 表格最後一列的底部框線。 |
df-messenger-table-border-left |
選用 | 無 | 表格儲存格的左框線。 |
df-messenger-table-border-left-first |
選用 | 無 | 資料列中第一個表格儲存格的左框線。 |
df-messenger-table-border-right |
選用 | 無 | 表格儲存格的右框線。 |
df-messenger-table-border-right-last |
選用 | 無 | 資料列中最後一個表格儲存格的右框線。 |
df-messenger-table-background |
選用 | 透明 | 表格列的背景。 |
df-messenger-table-even-background |
選用 | 透明 | 偶數資料表列的背景。 |
df-messenger-table-odd-background |
選用 | 透明 | 奇數資料表列的背景。 |
df-messenger-table-header-font-size |
選用 | 14px | 表格標頭元素中的文字大小。 |
df-messenger-table-header-font-weight |
選用 | 粗體 | 表格標頭元素的字型粗細。 |
df-messenger-table-header-font-color |
選用 | #1f1f1f | 表格標頭元素的文字顏色。 |
df-messenger-table-header-align |
選用 | 向左鍵 | 表格標題儲存格中的文字對齊方式。 |
df-messenger-table-header-padding |
選用 | 0 | 表格標題儲存格中的邊框間距。 |
df-messenger-table-header-border-top |
選用 | 無 | 表格標題列的頂端邊框。 |
df-messenger-table-header-border-bottom |
選用 | 無 | 表格標題列的底部邊框。 |
df-messenger-table-header-border-left |
選用 | 無 | 表格標題列中儲存格的左框線。 |
df-messenger-table-header-border-left-first |
選用 | 無 | 表格標題列中第一個儲存格的左框線。 |
df-messenger-table-header-border-right |
選用 | 無 | 表格標題列中儲存格的右側框線。 |
df-messenger-table-header-border-right-last |
選用 | 無 | 表格標題列中最後一個儲存格的右側框線。 |
df-messenger-table-header-background |
選用 | 透明 | 表格標題列的背景。 |
自訂範本回覆類型

自訂範本回應類型會轉譯網站上定義的自訂元素。這個元素不會放在資訊卡內,一律單獨顯示。
下表說明各個欄位:
| 名稱 | 類型 | 說明 |
|---|---|---|
type |
string |
回應類型:「custom_template」。 |
name |
string |
自訂元素的名稱。 |
payload |
Object |
要傳遞至自訂元素的酬載。 |
例如:
{
"richContent": [
[
{
"type": "custom_template",
"name": "custom-element-example",
"payload": {
"text": "Hello World"
}
}
]
]
}
在網站上,自訂元素必須以回應中 name 欄位的確切名稱註冊。payload 欄位會在建構後 (但在 connectedCallback 之前) 以 dfPayload 的形式傳遞至自訂元素。欄位可能包含任意 JSON。此外,dfResponseId 會傳遞至元素。
以下是使用範例回應,實作自訂元素的範例:
class CustomElementExample extends HTMLElement {
constructor() {
super();
// The `dfPayload` field will be provided before `connectedCallback` is
// being called.
this.dfPayload = null;
// The `dfResponseId` field will be provided before `connectedCallback` is
// being called.
this.dfResponseId = null;
// It is not strictly required but recommended to contain the custom
// element in a shadow root.
// https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot
this.renderRoot = this.attachShadow({mode: 'open'});
}
/** Web component Lifecycle method. */
connectedCallback() {
const div = document.createElement('div');
// The `.text` must match the payload's structure in `richContent.payload`.
div.innerText = this.dfPayload.text;
this.renderRoot.appendChild(div);
}
}
(function() {
// Registers the element. This name must match the name in
// `richContent.payload`.
customElements.define('custom-element-example', CustomElementExample);
})();
合併回覆類型

您可以使用 Dialogflow CX Messenger 的個別 Rich Message 元素,建構符合需求的自訂資訊卡。
以下範例使用「出貨」一節列出的部分元素:
{
"richContent": [
[
{
"type": "image",
"rawUrl": "https://example.com/images/logo.png",
"accessibilityText": "Dialogflow CX across platforms"
},
{
"type": "info",
"title": "Dialogflow CX",
"subtitle": "Build natural and rich conversational experiences",
"anchor": {
"href": "https://cloud.google.com/dialogflow/docs"
}
},
{
"type": "chips",
"options": [
{
"text": "Case Studies",
"anchor": {
"href": "https://cloud.google.com/dialogflow/case-studies"
}
},
{
"text": "Docs",
"anchor": {
"href": "https://cloud.google.com/dialogflow/docs"
}
}
]
}
]
]
}
您可以使用下列 CSS 變數:
| 屬性 | 輸入政策 | 預設值 | 說明 |
|---|---|---|---|
df-messenger-card-background |
選用 | 白色 | 自訂資訊卡的背景。 |
df-messenger-card-padding |
選用 | 16px | 自訂資訊卡中元素的邊框間距。 |
df-messenger-card-border |
選用 | 1px solid #e0e0e0 | 自訂資訊卡的邊框。 |
df-messenger-card-border-radius |
選用 | 8px | 自訂資訊卡的邊框半徑。 |
df-messenger-card-border-top-left-radius |
選用 | 8px | 自訂資訊卡左上角的邊框半徑。 |
df-messenger-card-border-top-right-radius |
選用 | 8px | 自訂資訊卡右上角的邊框半徑。 |
df-messenger-card-border-bottom-left-radius |
選用 | 8px | 自訂資訊卡左下角的邊框半徑。 |
df-messenger-card-border-bottom-right-radius |
選用 | 8px | 自訂資訊卡右下角的邊框半徑。 |
df-messenger-card-stack-border-top-left-radius |
選用 | 8px | 連續自訂資訊卡的左上角框線半徑會覆寫左上角半徑。 |
df-messenger-card-stack-border-top-right-radius |
選用 | 8px | 連續自訂資訊卡的右上角邊框半徑會覆寫右上角半徑。 |
df-messenger-card-stack-border-bottom-left-radius |
選用 | 8px | 連續自訂資訊卡的左下角邊框半徑會覆寫左下角半徑。 |
df-messenger-card-stack-border-bottom-right-radius |
選用 | 8px | 連續自訂資訊卡的右下角邊框半徑會覆寫右下角半徑。 |
df-messenger-card-box-shadow |
選用 | 0 2px 2px 0 rgba(0, 0, 0, 0.24) |
自訂資訊卡的方塊陰影。 |
來自應對手冊工具的多媒體內容
使用 Playbook 工具,將多媒體內容傳送至 Dialogflow CX Messenger。
步驟 1:在代理中建立 addRichContent 工具
如要建立名為 addRichContent 的函式工具,請使用下列資料:
工具輸入:
properties: {}
type: object
工具輸出內容:
properties:
status:
type: string
reason:
type: string
type: object
步驟 2:告訴代理如何使用這項工具
在指令和範例中,說明代理應如何使用工具。
舉例來說,您可以在指令中加入類似下列內容:
- Greet the user
- Ask the user what their favorite color is.
At the same time run ${TOOL: addRichContent} to display buttons
for blue, red, yellow, and green.
- Thank the user
例如,建立類似下方的範例:

步驟 3:定義 JavaScript
在託管 df-messenger 的網頁程式碼中,建立 JavaScript 程式碼,定義指示 df-messenger 顯示多媒體內容的函式。請向 df-messenger 註冊這個函式,以便在虛擬服務專員需要時執行。
確認變數 dfMessenger 已宣告,並指向 df-messenger 的執行個體。
以下是可用於此目的的程式碼範例:
const dfMessenger = document.querySelector('df-messenger');
function addRichContent(customPayload) {
dfMessenger.renderCustomCard(customPayload.richContent);
// add error handling
return Promise.resolve({ status: "OK", reason: null });
}
// substitute your own tool id
const toolId = 'projects/PROJECT_ID/locations/LOCATION/agents/AGENT_ID/tools/TOOL_ID'
dfMessenger.registerClientSideFunction(toolId, addRichContent.name, addRichContent);