Dialogflow CX 的 Google Chat 整合功能可讓您建立 Google Chat 應用程式,並運用 Dialogflow CX 技術理解自然語言。
限制
- 這項整合功能僅支援以代理預設語言輸入文字。
設定 Google Chat
如要為代理設定 Google Chat 整合,您需要:
- 可存取 Google Chat 的 Google Workspace 帳戶。
- Google Cloud 專案。
啟用 Google Chat API
您必須先在 Google Cloud專案中啟用 Google API,才能使用。您可以在單一 Google Cloud專案中啟用一或多個 API。
- 在 https://console.cloud.google.com/中,啟用 Google Chat API 和 Dialogflow API。
- 確認您是在正確的雲端專案中啟用 API,然後按一下「Next」(下一步)。
- 確認您要啟用正確的 API,然後按一下「啟用」。
透過 Dialogflow CX 設定
- 前往 Dialogflow CX 控制台。
- 選取 Google Cloud 專案。
- 選取代理程式。
- 前往導覽選單中的「管理」分頁。
- 選取「整合」。
- 按一下「Google Chat」上的「連結」。
- 填寫下列必要資訊:
- 名稱:使用者與這個應用程式互動,或使用這個應用程式建立的內容時 (例如在訊息、搜尋中或使用 @號提及時),應用程式的顯示名稱。例如:
Dialogflow CX App。 - 顯示圖片網址:與應用程式互動的使用者會看到的顯示圖片。請指定含有正方形 (顯示比例為 1:1) PNG 圖片的 HTTPS 網址。建議大小至少為 256 x 256 像素。例如:
https://developers.google.com/workspace/chat/images/quickstart-app-avatar.png。 - 說明:應用程式的說明,例如
A helpful bot that responds to real human conversation。 - 環境:要連線的環境。視需要選取「Environment」(環境)。
- 名稱:使用者與這個應用程式互動,或使用這個應用程式建立的內容時 (例如在訊息、搜尋中或使用 @號提及時),應用程式的顯示名稱。例如:
- 輸入電子郵件地址,將這個 Chat 擴充應用程式提供給特定使用者和群組 (如適用)。
- 按一下「啟動」。
測試
如要測試設定好的應用程式,請在 Google Chat 聊天室中提及該應用程式,或傳送即時訊息。
例如:
- 開啟 Google Chat。
- 按一下「發起新即時通訊」。
- 在「新增 1 位或多位使用者」欄位中,輸入 Chat 擴充應用程式的名稱。
- 從結果中選取 Chat 應用程式。即時訊息隨即開啟。
複合式回應訊息
您可以使用執行中的自訂酬載,支援豐富的回應訊息。如要瞭解訊息格式,請參閱 Google Chat 訊息 API。
簡訊
下列自訂酬載提供 Google Chat 文字訊息:
{
"text": "Hello, world"
}
如果您使用 Chat 外掛程式,下列自訂酬載會提供 Google Chat 文字訊息:
{
"hostAppDataAction": {
"chatDataAction": {
"createMessageAction": {
"message": {
"text": "Your pizza delivery is here!"
}
}
}
}
}
卡片訊息
下列自訂酬載提供 Google Chat 資訊卡訊息:
{
"cardsV2": [{
"cardId": "createCardMessage",
"card": {
"header": {
"title": "A card message!",
"subtitle": "Sent from Dialogflow CX",
"imageUrl": "https://developers.google.com/chat/images/chat-product-icon.png",
"imageType": "CIRCLE"
},
"sections": [
{
"widgets": [
{
"buttonList": {
"buttons": [
{
"text": "Read the docs!",
"onClick": {
"openLink": {
"url": "https://developers.google.com/workspace/chat"
}
}
}
]
}
}
]
}
]
}
}]
}
如果您使用 Chat 外掛程式,下列自訂酬載會提供 Google Chat 資訊卡訊息:
{
"hostAppDataAction": {
"chatDataAction": {
"createMessageAction": {
"message": {
"cardsV2": [
{
"cardId": "basic1",
"card": {
"header": {
"title": "This is a card!",
"subtitle": "Sent from Conversational Agents (Dialogflow CX)",
"imageUrl": "https://developers.google.com/chat/images/chat-product-icon.png",
"imageType": "CIRCLE"
},
"sections": [
{
"widgets": [
{
"buttonList": {
"buttons": [
{
"text": "Open Google!",
"color": {
"red": 0.101960786,
"green": 0.4509804,
"blue": 0.9098039
},
"onClick": {
"openLink": {
"url": "http://google.com"
}
}
}
]
}
}
]
}
]
}
}
]
}
}
}
}
}
管道專屬回覆
設定完成後,當代理回覆 Google Chat 即時通訊訊息時,系統會自動使用管道 DF_CX_GOOGLE_CHAT 的管道專屬回覆。
相關主題
- 建構 Dialogflow CX Google Chat 應用程式,理解自然語言並做出回應
- 使用 Workspace 外掛程式擴充 Google Chat
- 使用事件物件觸發函式
- 瞭解如何傳送 Google Chat 訊息