在 Business Messages 對話中,事件有助於提供資訊,讓對話內容更豐富 讓使用者和服務專員獲得良好體驗適用對象 使用者,事件會以通知的形式顯示在對話中並觸發 可讓你根據使用者可能採取的行動 來靈活調整服務專員會在 Webhook 及透過 API 呼叫傳送事件。
服務專員應瞭解使用者啟動的事件,而且能進行回應 。例如,使用者要求與真人服務專員交談時, 正面或負面回應要求,都會造成不良的使用者 無須專人管理
事件類型
每個事件都屬於特定類型:
「已要求真人服務專員」事件會指出使用者想發言 直接向真人服務專員諮詢
如果服務專員可將對話轉給真人代表,請傳送 代表已加入事件,然後從中傳送後續訊息給 人類代表。
如果服務專員無法將對話轉給真人代表, 傳送訊息通知使用者,告知對方真人服務專員即將到來 廣告。
代表加入/離開活動會通知使用者即時服務專員加入或 離開對話。這些事件會在對話中顯示通知 讓他們對回應速度以及 他們可以問的問題
輸入事件表示使用者或代理程式正在輸入。
isTyping
布林值表示使用者輸入狀態。每個狀態 變更會觸發新事件服務專員可傳送要顯示的
TYPING_STARTED
和TYPING_STOPPED
事件 在對話中輸入指標輸入代理程式事件會讓使用者 表示真人代表正在撰寫回應 自動化功能正在處理他們的問題或要求
傳送事件
如要傳送事件,請執行下列指令。替換下列項目:
- 將 CONVERSATION_ID 替換為您要的對話 ID 傳送問卷調查
- 將 EVENT_ID 替換為事件的專屬 ID
- 將 PATH_TO_SERVICE_ACCOUNT_KEY 替換為服務帳戶路徑 存放在機器上的金鑰
- EVENT_TYPE,其值來自:
EventType
- REPRESENTATIVE_NAME 是真人服務專員向使用者顯示的名稱 也就是自動建立事件
- REPRESENTATIVE_TYPE,其值來自:
RepresentativeType
curl -X POST "https://businessmessages.googleapis.com/v1/conversations/CONVERSATION_ID /events?eventId=EVENT_ID " \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-messages" \ -H "`oauth2l header --jsonPATH_TO_SERVICE_ACCOUNT_KEY businessmessages`" \ -d "{ 'eventType': 'EVENT_TYPE ', 'representative': { 'avatarImage': 'REPRESENTATIVE_AVATAR_URL ', 'displayName': 'REPRESENTATIVE_NAME ', 'representativeType': 'REPRESENTATIVE_TYPE ', }, }"
如需格式設定和值選項,請參閱:
conversations.events
。
範例:傳送代表加入事件
# Copyright 2021 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # https://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # This code sends a REPRESENTATIVE_JOINED event to the user. # Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/message/events#send # Replace the __CONVERSATION_ID__ with a conversation id that you can send messages to # Make sure a service account key file exists at ./service_account_key.json curl -X POST "https://businessmessages.googleapis.com/v1/conversations/__CONVERSATION_ID__/events?eventId=6a0af2c6-787d-4097-870d-93fe20351747" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-messages" \ -H "$(oauth2l header --json ./service_account_key.json businessmessages)" \ -d "{ 'eventType': 'REPRESENTATIVE_JOINED', 'representative': { 'avatarImage': 'https://developers.google.com/identity/images/g-logo.png', 'displayName': 'Chatbot', 'representativeType': 'HUMAN' } }"
接收事件
使用者在裝置上觸發事件時,代理程式會在以下位置收到事件: Webhook接收及處理事件的方式與接收及處理事件的方式相同 訊息。
使用者啟動的事件會使用以下格式。
{ "agent": "brands/BRAND_ID /agents/AGENT_ID ", "requestId": "REQUEST_ID ", "conversationId": "CONVERSATION_ID ", "customAgentId": "CUSTOM_AGENT_ID ", "sendTime": "SEND_TIME ", "userStatus": { "isTyping": "BOOLEAN ", "requestedLiveAgent": "BOOLEAN ", "createTime": "CREATION_TIME ", } }
如需格式設定和值選項,請參閱:
UserMessage
。