在與 Business Messages 服務專員對話中,歡迎訊息會設定 互動的語氣使用者也能透過應用程式瞭解代理程式的功能 使用者的疑問和期望
代理程式會在使用者每次開啟對話時傳送歡迎訊息。 代理程式也可以顯示對話啟動條件 引導使用者前往已知或常用路徑。
如果使用者嘗試在服務專員的服務時間以外進行對話 服務專員會顯示離線訊息 讓您分享替代管道或建議後續步驟。運用 您也能提高代理程式的可靠性和可用性
服務專員和位置層級設定
您可以在服務專員或地點的層級指定對話設定。
服務專員層級: 這些對話設定會套用到 所有進入點的虛擬服務專員
服務專員層級的歡迎訊息開頭可能會是「感謝您與我們聯絡 Bridgepoint Runners..."對話開場白可以著重在哪些部分 公司層級的動作或資訊。
位置層級:這些設定會覆寫服務專員層級設定, 僅適用於在
PLACESHEET
中與該位置的對話,以及MAPS
進入點。位置層級的歡迎訊息可能會以「感謝您與我們聯絡」開頭 Bridgepoint Runners on Amphitheatre Pkwy..."對話開場白可以聚焦 提供符合地點的工作或資訊離線訊息可能提及 地點的下次營業時間。
語言代碼
服務專員和地點可以針對其語言代碼分別指定設定 聯絡。舉例來說,客服專員可以為 「en」然後為「es」指定西班牙文的歡迎訊息語言代碼。 Business Messages 會解析使用者裝置回報的語言代碼與 代理程式或地點具有對話設定的語言。
系統會在每封郵件中回報這個語言代碼符合項目「resolvedLocale
」欄位。個人中心
可指定服務專員或位置的 defaultLocale
,進而解析其權重
語言代碼比對。請參閱本地化和
語言代碼
Business Messages 會使用已解析的語言代碼判斷哪個對話 選擇要套用的設定
歡迎訊息
代理程式與使用者之間的對話中的第一則訊息是服務專員 歡迎訊息。使用者發起訊息後,系統會自動顯示歡迎訊息 重新對話。歡迎訊息 設定使用者與代理程式互動的期望。編輯歡迎訊息 訊息,請參閱「更新對話設定」。
對話開場白
歡迎訊息簡要介紹服務專員的功能 採取開放式問題,良好的對話開場白 會引導使用者查看常見問題或已知功能。
對話開場白顯示為建議垂直堆疊 並直接閱讀歡迎訊息。使用者輕觸對話時 啟動條件,代理程式會收到您設定的預先定義內容和回傳資料 當您指定啟動條件時
如果服務專員針對特定要求支援自動化功能, 對話啟動條件可能會對應至這些要求,讓您依賴已知 輸入自動化程式碼,並將任意形式的使用者問題傳送給真人服務專員 回答的問題
一個虛擬服務專員最多只能有 5 個對話啟動條件,而每位啟動條件可 長度上限為 35 個半形字元。
如要新增或編輯對話開場白,請參閱「更新對話開場白」 設定。
離線訊息
使用者與運作中的代理程式進行對話時
小時 (根據
MessagingAvailability
),
使用者收到服務專員的離線訊息。僅限真人代表
觸發離線訊息時,系統才會考量有空與否狀態。僅執行的代理程式
機器人代表一律會傳送歡迎訊息。良好的離線訊息
- 分享代理程式無法使用的原因
- 引導使用者採取適當的後續步驟或其他聯絡管道
- 符合歡迎訊息的語氣和對話開場白
離線訊息不佳
「抱歉,我們停業了。」
良好的離線訊息
「我們目前是下班時間,不過明天早上 8 點就會再度上班。如果 如需緊急協助,請撥打 +12223334444 或 support@gtb.com 聯絡支援團隊。」
如要編輯離線訊息,請參閱「更新對話設定」一文。
更新對話設定
如要管理歡迎訊息或對話開場白,請提出 PATCH 要求
企業通訊部門
API
更新虛擬服務專員或地點的 conversationalSettings
欄位。
更新 conversationalSettings
欄位時,必須包含
在所有欄位中
ConversationalSetting
物件。更新要求會覆寫您編輯的所有欄位內容,包括
任何子欄位。例如,您要求修改歡迎訊息
但不包括對話啟動條件,要求會移除先前的所有
對話開場白
必要條件
更新對話設定前,請先備妥以下項目:
- 開發機器上 GCP 專案服務帳戶金鑰的路徑
- 要更新設定的語言代碼
如果是服務專員層級設定,請使用代理程式
name
(例如「brands/12345/agents/67890」)如果您不知道代理程式的
name
,請參閱列出 品牌。如果是地區層級設定,地點
name
(例如「brands/12345/locations/67890」)如果您不知道地點的
name
,請參閱列出 品牌。要更新的語言代碼,採用雙字元 ISO 639-1 語言 程式碼
新的歡迎訊息
隱私權政策網址
(選填) 對話開場白的文字
(選用) 對話啟動條件的回傳資料
(選用) 新增離線訊息
如果不知道目前的 conversationalSettings
值,請參閱取得代理程式
資訊
和取得位置
資訊。
傳送更新要求
如要更新代理程式或位置,請執行下列指令。替換變數 替換成您在必要條件中識別的值。
如果不想保留對話開場白,請省略 conversationStarters
和所有對話
子欄位。
代理程式層級設定
cURL
# This code updates the conversational settings of a Business Messages agent. # Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/patch # Replace the __BRAND_ID__, __AGENT_ID__ and __LOCALE__ # Make sure a service account key file exists at ./service_account_key.json curl -X PATCH \ "https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__?updateMask=businessMessagesAgent.conversationalSettings.__LOCALE__" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \ -d '{ "businessMessagesAgent": { "conversationalSettings": { "__LOCALE__": { "welcomeMessage": { "text": "My first welcome message" }, "offlineMessage": { "text": "My first offline message" }, "privacyPolicy": { "url": "https://www.your-company-website.com/privacy" }, "conversationStarters": [ { "suggestion": { "reply": { "text": "Suggestion 1", "postbackData": "post_back_suggestion_1" } } } ] } } } }'
Node.js
/** * This code snippet updates the conversationalSettings of a Business Messages agent. * Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/patch * * This code is based on the https://github.com/google-business-communications/nodejs-businesscommunications Node.js * Business Communications client library. */ /** * Edit the values below: */ const BRAND_ID = 'EDIT_HERE'; const AGENT_ID = 'EDIT_HERE'; const LOCALE = 'en'; const PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json'; const businesscommunications = require('businesscommunications'); const {google} = require('googleapis'); // Initialize the Business Communications API const bcApi = new businesscommunications.businesscommunications_v1.Businesscommunications({}); // Set the scope that we need for the Business Communications API const scopes = [ 'https://www.googleapis.com/auth/businesscommunications', ]; // Set the private key to the service account file const privatekey = require(PATH_TO_SERVICE_ACCOUNT_KEY); async function main() { const authClient = await initCredentials(); const agentName = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID; if (authClient) { // Setup the parameters for the API call const apiParams = { auth: authClient, name: agentName, updateMask: 'businessMessagesAgent.conversationalSettings.' + LOCALE, resource: { businessMessagesAgent: { conversationalSettings: { [LOCALE]: { privacyPolicy: { url: 'https://www.your-company-website.com/privacy' }, welcomeMessage: { text: 'My updated welcome message' }, offlineMessage: { text: 'My updated offline message' }, conversationStarters: [ { suggestion: { reply: { 'text': 'Suggestion 2', 'postbackData': 'post_back_suggestion_2', }, }, } ], }, } } } }; bcApi.brands.agents.patch(apiParams, {}, (err, response) => { if (err !== undefined && err !== null) { console.dir(err); } else { // Agent found console.log(response.data); } }); } else { console.log('Authentication failure.'); } } /** * Initializes the Google credentials for calling the * Business Messages API. */ async function initCredentials() { // Configure a JWT auth client const authClient = new google.auth.JWT( privatekey.client_email, null, privatekey.private_key, scopes, ); return new Promise(function(resolve, reject) { // Authenticate request authClient.authorize(function(err, tokens) { if (err) { reject(false); } else { resolve(authClient); } }); }); } main();
Java
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; import com.google.api.client.http.HttpTransport; import com.google.api.client.json.jackson2.JacksonFactory; import com.google.api.services.businesscommunications.v1.BusinessCommunications; import com.google.api.services.businesscommunications.v1.model.*; import com.google.common.collect.ImmutableMap; import java.io.FileInputStream; import java.util.Arrays; class Main { /** * Initializes credentials used by the Business Communications API. */ private static BusinessCommunications.Builder getBusinessCommunicationsBuilder() { BusinessCommunications.Builder builder = null; try { GoogleCredential credential = GoogleCredential .fromStream(new FileInputStream("PATH_TO_SERVICE_ACCOUNT_KEY")); credential = credential.createScoped(Arrays.asList( "https://www.googleapis.com/auth/businesscommunications")); credential.refreshToken(); HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport(); JacksonFactory jsonFactory = JacksonFactory.getDefaultInstance(); // Create instance of the Business Communications API builder = new BusinessCommunications .Builder(httpTransport, jsonFactory, null) .setApplicationName(credential.getServiceAccountProjectId()); // Set the API credentials and endpoint builder.setHttpRequestInitializer(credential); } catch (Exception e) { e.printStackTrace(); } return builder; } public static void main(String args[]) { try { // Create client library reference BusinessCommunications.Builder builder = getBusinessCommunicationsBuilder(); String agentName = "brands/BRAND_ID/agents/AGENT_ID"; Agent agent = new Agent().setBusinessMessagesAgent( new BusinessMessagesAgent().setConversationalSettings(ImmutableMap.of("LOCALE", new ConversationalSetting() .setPrivacyPolicy(new PrivacyPolicy().setUrl("PRIVACY_POLICY_URL")) .setWelcomeMessage(new WelcomeMessage().setText("WELCOME_MESSAGE")) .setOfflineMessage(new OfflineMessage().setText("OFFLINE_MESSAGE")) .setConversationStarters(Arrays.asList( new ConversationStarters().setSuggestion(new Suggestion() .setReply(new SuggestedReply() .setText("REPLY_TEXT") .setPostbackData("POSTBACK_DATA"))), ))))); BusinessCommunications.Brands.Agents.Patch request = builder .build().brands().agents().patch(agentName, agent); request.setUpdateMask("businessMessagesAgent.conversationalSettings.LOCALE"); Agent updatedAgent = request.execute(); System.out.println(updatedAgent.toPrettyString()); } catch (Exception e) { e.printStackTrace(); } } }
Python
"""This code updates the conversational settings of a Business Messages agent. Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/patch This code is based on the https://github.com/google-business-communications/python-businessmessages Python Business Messages client library. """ from oauth2client.service_account import ServiceAccountCredentials from businesscommunications.businesscommunications_v1_client import BusinesscommunicationsV1 from businesscommunications.businesscommunications_v1_messages import ( Agent, BusinessMessagesAgent, ConversationStarters, ConversationalSetting, OfflineMessage, PrivacyPolicy, WelcomeMessage, NegativeBotFeedbackMessage, BusinesscommunicationsBrandsAgentsPatchRequest, ) # Edit the values below: BRAND_ID = 'EDIT_HERE' AGENT_ID = 'EDIT_HERE' SCOPES = ['https://www.googleapis.com/auth/businesscommunications'] SERVICE_ACCOUNT_FILE = './service_account_key.json' credentials = ServiceAccountCredentials.from_json_keyfile_name( SERVICE_ACCOUNT_FILE, scopes=SCOPES) client = BusinesscommunicationsV1(credentials=credentials) agents_service = BusinesscommunicationsV1.BrandsAgentsService(client) agent_name = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID agent=Agent( businessMessagesAgent=BusinessMessagesAgent( conversationalSettings=BusinessMessagesAgent.ConversationalSettingsValue( additionalProperties=[BusinessMessagesAgent.ConversationalSettingsValue.AdditionalProperty( key='en', value=ConversationalSetting( privacyPolicy=PrivacyPolicy(url='https://www.your-company-website.com/privacy'), welcomeMessage=WelcomeMessage(text='Welcome to Business Messages'), offlineMessage=OfflineMessage(text='This is an offline message'), conversationStarters=[ ConversationStarters( suggestion=Suggestion( reply=SuggestedReply(text='Option 1', postbackData='option_1') ) )] ) ) ] ) ) ) updated_agent = agents_service.Patch( BusinesscommunicationsBrandsAgentsPatchRequest( agent=agent, name=agent_name, updateMask='businessMessagesAgent.conversationalSettings.en' ) ) print(updated_agent)
地區層級設定
# This code updates the agent interaction of a bot and human representatives. # Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/patch # Replace the __BRAND_ID__, __AGENT_ID__, __LOCATION_ID__, __LOCALE__ # Make sure a service account key file exists at ./service_account_key.json curl -X PATCH \ "https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/locations/__LOCATION_ID__?updateMask=conversationalSettings.__LOCALE__" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \ -d '{ "conversationalSettings": { "__LOCALE__": { "welcomeMessage": { "text": "My second welcome message" }, "offlineMessage": { "text": "My second offline message" }, "privacyPolicy": { "url": "https://www.your-company-website.com/privacy" }, "conversationStarters": [ { "suggestion": { "reply": { "text": "Suggestion 2", "postbackData": "post_back_suggestion_2" } } } ] } } }'
如需格式設定和值的相關資訊,請參閱
brands.agents.patch
、
brands.locations.patch
,
和
ConversationalSetting
。
範例
代理程式層級設定
curl -X PATCH \ "https://businesscommunications.googleapis.com/v1/brands/BRAND_ID/agents/AGENT_ID?updateMask=businessMessagesAgent.conversationalSettings.en" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY businesscommunications)" \ -d "{ 'businessMessagesAgent': { 'conversationalSettings': { 'en': { 'welcomeMessage': { 'text': 'Thanks for contacting Growing Tree Bank. What can I help with today?', }, 'offlineMessage': { 'text': 'We\'re closed for the night. Please reach out to us again tomorrow.', }, 'privacyPolicy': { 'url': 'https://www.growingtreebank.com/privacy', }, 'conversationStarters': [ { 'suggestion': { 'reply': { 'text': 'Set up an account', 'postbackData': 'new-account', }, }, }, { 'suggestion': { 'reply': { 'text': 'Look up account information', 'postbackData': 'account-lookup', }, }, }, ], }, }, }, }"
地區層級設定
curl -X PATCH \ "https://businesscommunications.googleapis.com/v1/brands/12345/locations/67890?updateMask=conversationalSettings.en" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json /path/to/service/account/key businesscommunications)" \ -d "{ 'conversationalSettings': { 'en': { 'welcomeMessage': { 'text': 'Thanks for contacting Growing Tree Bank on Amphitheatre Pkwy. What can I help with today?', }, 'offlineMessage': { 'text': 'We\'re closed for the night. Please reach out to us again tomorrow.', }, 'privacyPolicy': { 'url': 'https://www.growingtreebank.com/privacy', }, 'conversationStarters': [ { 'suggestion': { 'reply': { 'text': 'What are your hours?', 'postbackData': 'hours', }, }, }, { 'suggestion': { 'reply': { 'text': 'Set up an account', 'postbackData': 'new-account', }, }, }, { 'suggestion': { 'reply': { 'text': 'Look up account information', 'postbackData': 'account-lookup', }, }, }, { 'suggestion': { 'action': { 'text': 'Call us', 'postbackData': 'call', 'dialAction': { 'phoneNumber': '+12223334444', }, }, }, }, ], }, }, }"