Business Messages 服務專員可直接整合
如要將 Business Messages 代理程式與其他 Dialogflow ES 或 Dialogflow CX 的功能整合,請參閱每項產品的說明文件。
當使用者傳送訊息到有 Dialogflow 整合的代理程式時,Business Messages 會將使用者訊息傳送至 Dialogflow,並在訊息的 dialogflowResponse
物件中傳送 Dialogflow 的回覆給代理程式。您可以設定代理程式,讓系統自動傳送 Dialogflow 的回覆給使用者,您無須採取任何行動。詳情請參閱自動回應。
Dialogflow 整合
您必須先啟用 Dialogflow 整合作業,才能透過 Business Messages 使用 Dialogflow 的自動化功能。
必要條件
首先,您需要
- Business Messages 代理程式
- 「全球」區域中的 Dialogflow 虛擬服務專員,其根語言為英文 (en)
如果您沒有 Dialogflow 虛擬服務專員,請建立一個。
Dialogflow ES
您需要 Dialogflow 代理程式的專案 ID 才能啟用 Dialogflow ES 整合。如要找出專案 ID,請按照下列步驟操作:
- 前往 Dialogflow 主控台。
- 選取要連結至 Business Messages 的 Dialogflow 代理程式,然後按一下代理程式名稱旁的齒輪圖示
。
- 在「Google Project」(Google 專案) 下方,記下「Project ID」(專案 ID) 值。
Dialogflow CX
您必須具備 Dialogflow 服務專員的專案 ID 和服務專員 ID,才能啟用 Dialogflow CX 整合作業。如要找出這些 ID,
- 前往 Dialogflow CX 控制台。
- 選取 Dialogflow 專案。
- 在代理程式選取器中,按一下 Dialogflow 代理程式旁邊的溢位選單
。
- 按一下 [複製名稱]。這項操作會複製代理程式的完整名稱,格式如下:
projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID
。 - 記下專案 ID 和代理程式 ID 值。
建立整合項目
向
dialogflowServiceAccountEmail
取得合作夥伴的 Dialogflow 服務帳戶電子郵件。然後將 PARTNER_ID 替換成您的合作夥伴 ID。cURL
# This code gets the partner. # Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/partners/get # Replace the __PARTNER_ID__ # Make sure a service account key file exists at ./service_account_key.json curl -X GET \ "https://businesscommunications.googleapis.com/v1/partners/__PARTNER_ID__" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)"
Node.js
/** * This code snippet gets a partner. * Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/partners/get * * 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 PARTNER_ID = 'EDIT_HERE'; 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 partnerName = 'partners/' + PARTNER_ID; if (authClient) { // Setup the parameters for the API call const apiParams = { auth: authClient, name: partnerName, }; bcApi.partners.get(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();
Python
"""This code gets a partner. Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/partners/get 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, BusinesscommunicationsPartnersGetRequest, ) # Edit the values below: PARTNER_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) partners_service = BusinesscommunicationsV1.PartnersService(client) partner_name = 'partners/' + PARTNER_ID partner = partners_service.Get(BusinesscommunicationsPartnersGetRequest( name=partner_name )) print(partner)
複製服務帳戶的電子郵件地址。這個帳戶會連結您的 Business Messages 和 Dialogflow 代理程式。
在 Google Cloud Console 中選取您的 Dialogflow 專案。
前往身分與存取權管理權限頁面。
按一下 [新增],然後輸入「新成員」的服務帳戶電子郵件地址。
在「請選擇角色」中選取「Dialogflow Console 代理程式編輯者」。
按一下「Add another role」(新增其他角色),然後選取「Dialogflow API Client」(Dialogflow API 用戶端)。
按一下「儲存」。
將 Dialogflow 專案與 Business Messages 代理程式整合。
根據您是否想要讓 Business Messages 自動回應 Dialogflow 回應,將 AUTO_RESPONSE_STATUS 替換為 Enabled 或 DISABLED。
Dialogflow ES
cURL
# This code creates a Dialogflow ES integration. # Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#dialogflow_es # Replace the __BRAND_ID__, __AGENT_ID__, __DIALOGFLOW_ES_PROJECT_ID__ and __AUTO_RESPONSE_STATUS__ # Make sure a service account key file exists at ./service_account_key.json curl -X POST \ "https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__/integrations" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -d '{ "dialogflowEsIntegration": { "dialogflowProjectId": "__DIALOGFLOW_ES_PROJECT_ID__", "autoResponseStatus": "__AUTO_RESPONSE_STATUS__" } }'
Node.js
/** * This code snippet creates a Dialogflow ES integration. * Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#dialogflow_es * * 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 DIALOGFLOW_ES_PROJECT_ID = 'EDIT_HERE' const PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json'; const businesscommunications = require('businesscommunications'); const {google} = require('googleapis'); const uuidv4 = require('uuid').v4; // 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) { const integrationObject = { dialogflowEsIntegration: { dialogflowProjectId: DIALOGFLOW_ES_PROJECT_ID, autoResponseStatus: 'ENABLED' } }; // Setup the parameters for the API call const apiParams = { auth: authClient, parent: agentName, resource: integrationObject }; bcApi.brands.agents.integrations.create(apiParams, {}, (err, response) => { if (err !== undefined && err !== null) { console.dir(err); } else { // Agent created 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();
Python
"""This code snippet creates a Dialogflow ES integration. Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#dialogflow_es 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 ( BusinesscommunicationsBrandsAgentsIntegrationsCreateRequest, DialogflowEsIntegration ) # Edit the values below: BRAND_ID = 'EDIT_HERE' AGENT_ID = 'EDIT_HERE' DIALOGFLOW_ES_PROJECT_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) integrations_service = BusinesscommunicationsV1.BrandsAgentsIntegrationsService(client) agent_name = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID integration = integrations_service.Create(BusinesscommunicationsBrandsAgentsIntegrationsCreateRequest( integration=DialogflowEsIntegration( autoResponseStatus=DialogflowEsIntegration.AutoResponseStatusValueValuesEnum.ENABLED, dialogflowProjectId=DIALOGFLOW_ES_PROJECT_ID ), parent=agent_name )) print(integration)
Dialogflow CX
cURL
# This code creates a Dialogflow CX integration. # Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#dialogflow_cx # Replace the __BRAND_ID__, __AGENT_ID__, __DIALOGFLOW_CX_PROJECT_ID__, __DIALOGFLOW_CX_AGENT_ID__ and __AUTO_RESPONSE_STATUS__ # Make sure a service account key file exists at ./service_account_key.json curl -X POST \ "https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__/integrations" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -d '{ "dialogflowCxIntegration": { "dialogflowProjectId": "__DIALOGFLOW_CX_PROJECT_ID__", "dialogflowAgentId": "__DIALOGFLOW_CX_AGENT_ID__", "autoResponseStatus": "__AUTO_RESPONSE_STATUS__" } }'
Node.js
/** * This code snippet creates a Dialogflow CX integration. * Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#dialogflow_cx * * 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 DIALOGFLOW_CX_AGENT_ID = 'EDIT_HERE' const DIALOGFLOW_CX_PROJECT_ID = 'EDIT_HERE' const PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json'; const businesscommunications = require('businesscommunications'); const {google} = require('googleapis'); const uuidv4 = require('uuid').v4; // 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) { const integrationObject = { dialogflowCxIntegration: { dialogflowProjectId: DIALOGFLOW_CX_PROJECT_ID, dialogflowAgentId: DIALOGFLOW_CX_AGENT_ID, autoResponseStatus: 'ENABLED' } }; // Setup the parameters for the API call const apiParams = { auth: authClient, parent: agentName, resource: integrationObject }; bcApi.brands.agents.integrations.create(apiParams, {}, (err, response) => { if (err !== undefined && err !== null) { console.dir(err); } else { // Agent created 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();
Python
"""This code snippet creates a Dialogflow CX integration. Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#dialogflow_cx 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 ( BusinesscommunicationsBrandsAgentsIntegrationsCreateRequest, DialogflowCxIntegration ) # Edit the values below: BRAND_ID = 'EDIT_HERE' AGENT_ID = 'EDIT_HERE' DIALOGFLOW_CX_AGENT_ID = 'EDIT_HERE' DIALOGFLOW_CX_PROJECT_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) integrations_service = BusinesscommunicationsV1.BrandsAgentsIntegrationsService(client) agent_name = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID integration = integrations_service.Create(BusinesscommunicationsBrandsAgentsIntegrationsCreateRequest( integration=DialogflowCxIntegration( autoResponseStatus=DialogflowCxIntegration.AutoResponseStatusValueValuesEnum.ENABLED, dialogflowAgentId=DIALOGFLOW_CX_AGENT_ID, dialogflowProjectId=DIALOGFLOW_CX_PROJECT_ID ), parent=agent_name )) print(integration)
如需格式設定和值選項,請參閱
Integration
。
連結 Business Messages 和 Dialogflow 大約需要兩分鐘。如要查看整合狀態,請取得整合項目 OperationInfo
。
更新整合作業
如要更新代理程式的自動回覆設定,請執行下列指令。根據您是否希望 Business Messages 會自動回應 Dialogflow 回應,將 AUTO_RESPONSE_STATUS 替換為「已啟用」或「已停用」。
Dialogflow ES
cURL
# This code updates the Dialogflow association. # Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/updateDialogflowAssociation # Replace the __BRAND_ID__ and __AGENT_ID__ # 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__/dialogflowAssociation?updateMask=enableAutoResponse" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \ -d '{ "enableAutoResponse": true }'
Dialogflow CX
cURL
# This code updates the Dialogflow association. # Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/updateDialogflowAssociation # Replace the __BRAND_ID__ and __AGENT_ID__ # 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__/dialogflowAssociation?updateMask=enableAutoResponse" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \ -d '{ "enableAutoResponse": true }'
如需格式設定和值選項,請參閱 Integration
。
切換 Dialogflow 版本
Business Messages 服務專員一次只能支援一項 Dialogflow 整合。 如要從某個 Dialogflow 版本切換至另一個版本,您必須先移除目前的整合作業,再建立新版本。
刪除整合
如果需要從 Business Messages 代理程式中移除 Dialogflow,請使用下列指令刪除整合。
cURL
# This code deletes an integration. # Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#delete_the_integration # Replace the __BRAND_ID__, __AGENT_ID__ and __INTEGRATION_ID__ # Make sure a service account key file exists at ./service_account_key.json curl -X DELETE \ "https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__/integrations/__INTEGRATION_ID__" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)"
Node.js
/** * This code snippet deletes an integration. * Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#delete_the_integration * * 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 INTEGRATION_ID = 'EDIT_HERE'; const PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json'; const businesscommunications = require('businesscommunications'); const {google} = require('googleapis'); const uuidv4 = require('uuid').v4; // 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 integrationName = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID + '/integrations/' + INTEGRATION_ID; if (authClient) { // Setup the parameters for the API call const apiParams = { auth: authClient, name: integrationName, }; bcApi.brands.agents.integrations.delete(apiParams, {}, (err, response) => { if (err !== undefined && err !== null) { console.dir(err); } else { // Agent created 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();
Python
"""This code snippet deletes an integration. Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#delete_the_integration 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 ( BusinesscommunicationsBrandsAgentsIntegrationsDeleteRequest ) # Edit the values below: BRAND_ID = 'EDIT_HERE' AGENT_ID = 'EDIT_HERE' INTEGRATION_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) integrations_service = BusinesscommunicationsV1.BrandsAgentsIntegrationsService(client) integration_name = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID + '/integrations/' + INTEGRATION_ID integration = integrations_service.Delete(BusinesscommunicationsBrandsAgentsIntegrationsDeleteRequest( name=integration_name )) print(integration)
如需格式設定和值選項,請參閱 Integration
。
取得整合資訊
如要取得整合的相關資訊,只要具備整合的 name
值,即可使用 Business Communications API。
取得單一整合的相關資訊
如要取得整合資訊,請執行下列指令。
cURL
# This code gets information about an integration. # Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#get_info_for_a_single_integration # Replace the __BRAND_ID__, __AGENT_ID__ and __INTEGRATION_ID__ # Make sure a service account key file exists at ./service_account_key.json curl -X GET \ "https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__/integrations/__INTEGRATION_ID__" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)"
Node.js
/** * This code snippet gets information about an integration. * Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#get_info_for_a_single_integration * * 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 INTEGRATION_ID = 'EDIT_HERE'; const PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json'; const businesscommunications = require('businesscommunications'); const {google} = require('googleapis'); const uuidv4 = require('uuid').v4; // 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 integrationName = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID + '/integrations/' + INTEGRATION_ID; if (authClient) { // Setup the parameters for the API call const apiParams = { auth: authClient, name: integrationName, }; bcApi.brands.agents.integrations.get(apiParams, {}, (err, response) => { if (err !== undefined && err !== null) { console.dir(err); } else { // Agent created 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();
Python
"""This code snippet gets information about an integration. Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#get_info_for_a_single_integration 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 ( BusinesscommunicationsBrandsAgentsIntegrationsDeleteRequest ) # Edit the values below: BRAND_ID = 'EDIT_HERE' AGENT_ID = 'EDIT_HERE' INTEGRATION_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) integrations_service = BusinesscommunicationsV1.BrandsAgentsIntegrationsService(client) integration_name = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID + '/integrations/' + INTEGRATION_ID integration = integrations_service.Get(BusinesscommunicationsBrandsAgentsIntegrationsDeleteRequest( name=integration_name )) print(integration)
如需格式設定和值選項,請參閱 Integration
。
列出代理程式的所有整合功能
如果您不知道整合作業的名稱,只要省略 GET 要求網址的 INTEGRATION_ID 值,即可取得與代理程式相關的所有整合資訊。
cURL
# This code lists all integrations for an agent. # Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#list_all_integrations_for_an_agent # Replace the __BRAND_ID__ and __AGENT_ID__ # Make sure a service account key file exists at ./service_account_key.json curl -X GET \ "https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__/integrations" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)"
Node.js
/** * This code snippet lists all integrations for an agent. * Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#list_all_integrations_for_an_agent * * 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 PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json'; const businesscommunications = require('businesscommunications'); const {google} = require('googleapis'); const uuidv4 = require('uuid').v4; // 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(); if (authClient) { // Setup the parameters for the API call const apiParams = { auth: authClient, parent: 'brands/' + BRAND_ID + '/agents/' + AGENT_ID, }; bcApi.brands.agents.integrations.list(apiParams, {}, (err, response) => { if (err !== undefined && err !== null) { console.dir(err); } else { // Agent created 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();
Python
"""This code snippet lists all integrations for an agent. Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#list_all_integrations_for_an_agent 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 ( BusinesscommunicationsBrandsAgentsIntegrationsListRequest ) # 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) integrations_service = BusinesscommunicationsV1.BrandsAgentsIntegrationsService(client) agent_name = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID integration = integrations_service.List( BusinesscommunicationsBrandsAgentsIntegrationsListRequest(parent=agent_name) ) print(integration)
如需格式設定和值選項,請參閱 Integration
。
意圖比對
為 Business Messages 代理程式啟用 Dialogflow 整合後,服務專員不需修改程式碼,就能使用 Dialogflow 專案設定意圖來瞭解及回覆使用者問題。如要進一步瞭解意圖,請參閱 Dialogflow ES 和 Dialogflow CX 的說明文件。
針對您打算透過自動化功能支援的每個對話選項,設定 Dialogflow 意圖。Business Messages 代理程式必須使用 Dialogflow 來瞭解使用者訊息。
呼叫 Dialogflow API 時,Business Messages 會將使用者訊息酬載傳送至您的意圖和出貨 Webhook。當使用者訊息與意圖相符時,您可以在 QueryParameters
的 business_messages_payload
欄位中以 Struct
格式存取這個酬載。
酬載包含使用者訊息中的所有欄位 (DialogflowResponse
除外)。
針對 Dialogflow CX,Business Messages 也會將工作階段參數,稱為channel
,並將值 google_business_messages
傳送至意圖,而您可以在代理程式中參照下列格式:$session.params.channel
。
這個參數可用於為 Dialogflow 執行要求新增條件,以便支援同一個 Dialogflow 代理程式中的多個管道。
如要進一步瞭解查詢參數,請參閱 Dialogflow ES 和 Dialogflow CX 參考資料。
必要條件
在 Dialogflow 中建立 NLU 模型時,您可以為意圖設定不同的回應類型。Business Messages 支援預設回應,包括:
- 文字
- 自訂酬載
- 線上服務專員轉接服務 (僅限 Dialogflow CX)
自訂酬載必須符合有效的 Business Messages JSON 訊息回應物件。為意圖設定自訂酬載回應時,Business Messages 會忽略下列欄位:
name
messageId
representative
請參閱下列回應範例。
文字與建議
{
"text": "Hello World!",
"fallback": "Hello World!\n\nReply with \"Hello\" or \"Hi!\"",
"suggestions": [
{
"reply": {
"text": "Hello",
"postbackData": "hello-formal"
}
},
{
"reply": {
"text": "Hi!",
"postbackData": "hello-informal"
}
}
]
}
複合式資訊卡
{
"fallback": "Hello, world!\nSent with Business Messages\n\nReply with \"Suggestion #1\" or \"Suggestion #2\"",
"richCard": {
"standaloneCard": {
"cardContent": {
"title": "Hello, world!",
"description": "Sent with Business Messages.",
"media": {
"height": "TALL",
"contentInfo":{
"altText": "Google logo",
"fileUrl": "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png",
"forceRefresh": "false"
}
},
"suggestions": [
{
"reply": {
"text": "Suggestion #1",
"postbackData": "suggestion_1"
}
},
{
"reply": {
"text": "Suggestion #2",
"postbackData": "suggestion_2"
}
}
]
}
}
}
}
複合式資訊卡輪轉介面
{
"fallback": "Card #1\nThe description for card #1\n\nCard #2\nThe description for card #2\n\nReply with \"Card #1\" or \"Card #2\"",
"richCard": {
"carouselCard": {
"cardWidth": "MEDIUM",
"cardContents": [
{
"title": "Card #1",
"description": "The description for card #1",
"suggestions": [
{
"reply": {
"text": "Card #1",
"postbackData": "card_1"
}
}
],
"media": {
"height": "MEDIUM",
"contentInfo": {
"fileUrl": "https://my.files/cute-dog.jpg",
"forceRefresh": false
}
}
},
{
"title": "Card #2",
"description": "The description for card #2",
"suggestions": [
{
"reply": {
"text": "Card #2",
"postbackData": "card_2"
}
}
],
"media": {
"height": "MEDIUM",
"contentInfo": {
"fileUrl": "https://my.files/elephant.jpg",
"forceRefresh": false
}
}
}
]
}
}
}
線上服務專員轉接
{
"metadata": {}
}
常見問題機器人
為 Business Messages 代理程式啟用 Dialogflow ES 整合後,您可以建立 FAQ 機器人。當您以支援的知識文件提供問題與解答時,Business Messages 和 Dialogflow 會建立必要的基礎架構,讓您瞭解並回答使用者的問題,而無需編寫程式碼。
如要查看常見問題的機器人,請與 Business Messages 常見問題機器人進行即時通訊。
必要條件
在建立 FAQ 機器人之前,您需要將問題和答案做為知識文件 (上限 50 MB) 提供給您:公開發布的 HTML 檔案或 CSV 檔案。
一般而言,知識文件
- 可在答案中加入有限的 Markdown,如 RTF 格式中所述。
- 大小上限為 50 MB。
- 不得超過 2000 個問題/答案組合。
- 請勿以不同答案回答重複的問題。
如果是 HTML 檔案:
- 公開網址的檔案必須由 Google 搜尋索引器檢索,確保檔案出現在搜尋索引中。您可以使用 Google Search Console 進行檢查,請注意,索引工具不會持續更新內容。來源內容變更時,您必須明確更新文件。
- Dialogflow 在建立回應時會將內容中的 HTML 標記移除。因此,最好避免使用 HTML 標記,並盡可能使用純文字,
- 不支援含有單一問題/答案組合的檔案。
CSV 檔案:
- 第一欄必須包含問題,第二欄必須包含答案,不含標題。
- 檔案必須使用半形逗號做為分隔符號。
建立 FAQ 機器人
如要建立 FAQ 機器人,請先建立知識庫來儲存所有機器人的資料,然後將一或多個含有問題/答案組合的文件新增至知識庫。
建立知識庫
如要建立知識庫,請執行下列指令。將 BRAND_ID、AGENT_ID 和 INTEGRATION_ID 替換為文件 name
中的不重複值。請將 KNOWLEDGE_BASE_DISPLAY_NAME 替換為您選擇的識別字串。
建立知識庫後,您可以在其中建立文件。
cURL
# This code creates a knowledge base. # Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#create-knowledge-base # Replace the __BRAND_ID__, __AGENT_ID__, __INTEGRATION_ID__ and __KNOWLEDGE_BASE_DISPLAY_NAME__ # 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__/integrations/__INTEGRATION_ID__?updateMask=dialogflowEsIntegration.dialogflowKnowledgeBases" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \ -d '{ "dialogflowEsIntegration": { "dialogflowKnowledgeBases": [ { "displayName": "__KNOWLEDGE_BASE_DISPLAY_NAME__" } ] } }'
如需格式設定和值選項,請參閱 DialogflowKnowledgebase
。
建立知識文件
如要建立知識文件,請執行下列指令。
將文件新增至現有文件清單;如果目前沒有任何文件,請建立新清單。現有文件清單應包含要求中的文件 name
值。
公開 HTML 檔案
替換下列變數:
- BRAND_ID、AGENT_ID 和 INTEGRATION_ID 以及整合作業中的不重複值
name
- KNOWLEDGE_BASE_DISPLAY_NAME 和 DOCUMENT_DISPLAY_NAME ,識別您所選的字串
使用知識文件公開網址的 PUBLIC_URL
cURL
# This code creates a knowledge base document from an HTML document and adds it to the knowledge base. # Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#create-document # Replace the __BRAND_ID__, __AGENT_ID__, __INTEGRATION_ID__, __KNOWLEDGE_BASE_DISPLAY_NAME__, __DOCUMENT_DISPLAY_NAME__ and __PUBLIC_URL__ # 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__/integrations/__INTEGRATION_ID__?updateMask=dialogflowEsIntegration.dialogflowKnowledgeBases" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \ -d '{ "dialogflowEsIntegration": { "dialogflowKnowledgeBases": [ { "displayName": "__KNOWLEDGE_BASE_DISPLAY_NAME__", "documents": [ { "displayName": "__DOCUMENT_DISPLAY_NAME__", "faqUrl": "__PUBLIC_URL__" } ] } ] } }'
本機 CSV 檔案
替換下列變數:
- BRAND_ID、AGENT_ID 和 INTEGRATION_ID 以及整合作業中的不重複值
name
- KNOWLEDGE_BASE_DISPLAY_NAME 和 DOCUMENT_DISPLAY_NAME ,識別您所選的字串
將 CSV 檔案做為 Base64 編碼字串的 CSV_RAW_BYTES
cURL
# This code creates a knowledge base document from a CSV document and adds it to the knowledge base. # Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#create-document # Replace the __BRAND_ID__, __AGENT_ID__, __INTEGRATION_ID__, __KNOWLEDGE_BASE_DISPLAY_NAME__, __DOCUMENT_DISPLAY_NAME__ and __CSV_RAW_BYTES__ # 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__/integrations/__INTEGRATION_ID__?updateMask=dialogflowEsIntegration.dialogflowKnowledgeBases" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \ -d '{ "dialogflowEsIntegration": { "dialogflowKnowledgeBases": [ { "displayName": "__KNOWLEDGE_BASE_DISPLAY_NAME__", "documents": [ { "displayName": "__DOCUMENT_DISPLAY_NAME__", "rawContent": "__CSV_RAW_BYTES__" } ] } ] } }'
如需格式設定和值選項,請參閱 DialogflowKnowledgebase
。
將文件新增至知識庫大約需要兩分鐘。如要查看文件狀態,請取得整合項目 OperationInfo
。
刪除知識文件
如果需要從 Business Messages 代理程式中移除問題/答案組合,請使用下列指令刪除含有這些知識的知識文件。
執行下列指令來刪除單一現有文件。將 BRAND_ID、AGENT_ID 和 INTEGRATION_ID 替換為文件 name
中的不重複值。以適當的字串取代 KNOWLEDGE_BASE_DISPLAY_NAME。
cURL
# This code deletes a knowledge base document. # Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#delete_a_knowledge_document # Replace the __BRAND_ID__, __AGENT_ID__, __INTEGRATION_ID__ and __KNOWLEDGE_BASE_DISPLAY_NAME__ # To delete all knowledge bases, set dialogflowKnowledgeBases to an empty list. Otherwise, the list should contain all existing knowledgebases except the one you would like to remove. # 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__/integrations/__INTEGRATION_ID__?updateMask=dialogflowEsIntegration.dialogflowKnowledgeBases" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \ -d '{ "dialogflowEsIntegration": { "dialogflowKnowledgeBases": [ { "displayName": "__KNOWLEDGE_BASE_DISPLAY_NAME__" } ] } }'
如需格式設定和值選項,請參閱 DialogflowKnowledgebase
。
自動回覆
如果您在 Dialogflow 整合期間啟用自動回覆功能,Business Messages 會自動透過 Dialogflow 回應使用者。您的商家訊息代理程式回應可信度最高。搭配使用 Dialogflow ES 整合後,如果常見問題和自訂意圖都相符,Business Messages 就會回應可信度最高等級的比對結果。
Business Messages 會將所有自動回覆的訊息標示為來自 BOT
代表。如果您的代理程式支援即時服務專員,Business Messages 會在 REPRESENTATIVE_JOINED
事件後暫停自動回應,並在 REPRESENTATIVE_LEFT
事件結束後繼續自動回覆。請參閱從機器人遷移至即時代理程式。
透過常見問題自動回覆
與 Dialogflow ES 整合時,如果常見問題答案的最高可信度等級,Business Messages 會將答案對應至簡訊。如果有相關但不同的答案,訊息會顯示「查看另一個解答」建議。如果沒有,則訊息會含有問題和建議回覆,詢問訊息是否滿足使用者的要求。
透過意圖回應自動回應
意圖回應可以包含下列一或多項回應。
如果意圖回應的信賴水準最高,則適用以下情況。
- 如果回應中至少有一個文字值,Business Messages 會將這個值對應至簡訊。
- 如果回應包含至少一項具備有效 Business Messages JSON 物件結構的自訂酬載,則 Business Messages 會使用提供的 JSON 物件建立訊息。
- 如果回應包含至少一個即時服務專員轉接回應,請參閱「使用即時服務專員要求自動回應」。
由於 Dialogflow 可以在單一意圖比對中納入多個回應,因此 Business Messages 會以每則訊息的形式傳送每個文字、自訂酬載或即時代理程式轉接回應。如果意圖相符結果中有多則訊息,但有些訊息的格式有誤,Business Messages 只會傳送有效訊息做為自動回覆。
透過即時服務專員要求自動回覆
Dialogflow CX 支援即時服務專員轉接回應。並指示對話應交由真人代表使用,並允許您傳遞自訂程序的中繼資料。如果意圖回應的可信度等級最高,且包含即時代理程式轉接功能,Business Messages 就會傳送即時代理程式要求事件至您的 Webhook。如要處理這個事件,請參閱從機器人遷移至即時代理程式。
自動回覆訊息
如果 Dialogflow 沒有偵測到可信度高的級別,Business Messages 就會傳送備用回應。Dialogflow ES 和 Dialogflow CX 中的備用廣告處理方式不同。
Dialogflow ES
針對常見問題機器人,如果與常見問題的答案不符,Business Messages 就會傳送備用訊息,但找不到答案。
針對已設定的意圖,如果找不到與意圖回應的相符內容,商家訊息就會傳送備用意圖回應。您可以使用 Dialogflow 提供的備用文字,或者透過其他文字和自訂酬載設定備用廣告。
以下是 Webhook 可接收的備用意圖回應範例:
{
"intentResponses": [
{
"intentName": "projects/df-integration/agent/intents/12345",
"intentDisplayName": "Default Fallback Intent",
"intentDetectionConfidence": "1.0",
"fulfillmentMessages": [
{
"text": "One more time?"
}
]
}
]
}
Dialogflow 會預先填入 intent_name
和 intent_display_name
。
Dialogflow CX
Dialogflow CX 會將備用意圖回應視為內建事件處理。如果沒有任何意圖與意圖回應相符,Business Messages 就會從 Dialogflow 中的「不相符」預設事件傳送備用訊息。您可以使用 Dialogflow 提供的備用文字,也可以使用其他文字、自訂酬載和真人服務專員轉接選項設定備用文字。
以下是 Webhook 可接收的備用意圖回應範例:
{
"intentResponses": [
{
"intentName": "sys.no-match-default",
"intentDisplayName": "Default Fallback Intent",
"intentDetectionConfidence": "0.3",
"fulfillmentMessages": [
{
"text": "I missed that, say that again?"
}
]
}
]
}
Business Messages 會以硬式編碼的方式寫入 intent_name
和 intent_display_name
。
Dialogflow 專屬欄位
啟用 Dialogflow 整合後,代理程式接收的使用者訊息就會包含 dialogflowResponse
物件。Webhook 會接收所有使用者訊息的酬載,無論 Business Messages 是否代表您自動回覆訊息。如要檢查自動回覆,請查看 autoResponded
欄位的值,判斷您是否需要回應使用者。
Dialogflow ES
... "dialogflowResponse": { "queryText": "TEXT", "intentResponse": { "intentName": "INTENT_ID", "intentDisplayName": "INTENT_NAME", "intentDetectionConfidence": "CONFIDENCE_NUMERIC", "fulfillmentMessages": [{ "text": "FULFILLMENT_TEXT", "jsonPayload": "JSON", "error": "ERROR_STATUS", }], "faqResponse": { "userQuestion": "USER_QUESTION", "answers": [{ "faqQuestion": "FAQ_QUESTION", "faqAnswer": "FAQ_ANSWER", "matchConfidenceLevel": "CONFIDENCE_LEVEL", "matchConfidence": "CONFIDENCE_NUMERIC", }], }, "autoResponded": "BOOLEAN", "autoRespondedMessages": [{ "message": "MESSAGE_JSON", "responseSource": "SOURCE", }], }, ...
欄位 | 說明 |
---|---|
queryText
|
原始對話查詢文字。如果 Dialogflow 模型已啟用自動拼字修正功能,queryText 會納入修正後的使用者輸入內容。 |
intentName |
相符意圖的專屬 ID。 |
intentDisplayName |
相符意圖的名稱。 |
intentDetectionConfidence
|
比對相符項目 queryText 與 intentName 之間的數字可信度評分。 |
text |
文字回應。 |
jsonPayload
|
自訂酬載回應。這個字串與 Dialogflow 中定義的自訂酬載相符。如果酬載沒有有效的 Business Messages JSON 物件結構,error 會說明問題。 |
error |
包含意圖出貨訊息的錯誤說明。 |
userQuestion |
使用者提出的問題,由 Dialogflow 剖析。 |
faqQuestion |
Dialogflow 比對到使用者問題的問題。 |
faqAnswer |
Dialogflow 提供的回答與使用者的問題相符。 |
matchConfidenceLevel
|
userQuestion 和 faqQuestion 之間相符項目的信賴程度。 |
matchConfidence
|
比對 userQuestion 與 faqQuestion 之間的數字可信度評分。 |
autoResponded
|
指出 Business Messages 是否會自動回覆來自 Dialogflow 的答案。 |
message |
自動回應的酬載。 |
responseSource
|
自動回覆的來源。請參閱 ResponseSource 。 |
Dialogflow CX
... "dialogflowResponse": { "queryText": "TEXT", "intentResponse": { "intentName": "INTENT_ID", "intentDisplayName": "INTENT_NAME", "intentDetectionConfidence": "CONFIDENCE_NUMERIC", "fulfillmentMessages": [{ "text": "FULFILLMENT_TEXT", "jsonPayload": "JSON", "error": "ERROR_STATUS", "liveAgentHandoff": { "metadata": {} } }], "autoResponded": "BOOLEAN", "autoRespondedMessages": [{ "message": "MESSAGE_JSON", "responseSource": "SOURCE", }], }, ...
欄位 | 說明 |
---|---|
queryText
|
原始對話查詢文字。如果 Dialogflow 模型已啟用自動拼字修正功能,queryText 會納入修正後的使用者輸入內容。 |
intentName |
相符意圖的專屬 ID。 |
intentDisplayName |
相符意圖的名稱。 |
intentDetectionConfidence
|
比對相符項目 queryText 與 intentName 之間的數字可信度評分。 |
text |
文字回應。 |
jsonPayload
|
自訂酬載回應。這個字串與 Dialogflow 中定義的自訂酬載相符。如果酬載沒有有效的 Business Messages JSON 物件結構,error 會說明問題。 |
error |
包含意圖出貨訊息的錯誤說明。 |
liveAgentHandoff |
即時服務專員轉接程序的自訂中繼資料。 |
autoResponded
|
指出 Business Messages 是否會自動回覆來自 Dialogflow 的答案。 |
message |
自動回應的酬載。 |
responseSource
|
自動回覆的來源。請參閱 ResponseSource 。 |