ตัวแทน Business Messages รองรับการผสานรวมกับ
- Dialogflow ES: การจับคู่ความตั้งใจและบ็อตคำถามที่พบบ่อย
- Dialogflow CX: การจับคู่ความตั้งใจและการส่งต่อตัวแทนแบบเรียลไทม์
เพื่อผสานรวมตัวแทน Business Messages กับฟีเจอร์อื่นๆ ของ Dialogflow ES หรือ Dialogflow CX โปรดอ่านเอกสารประกอบของแต่ละผลิตภัณฑ์
เมื่อผู้ใช้ส่งข้อความถึงตัวแทนที่มีการผสานรวม Dialogflow
Business Messages จะส่งข้อความแจ้งผู้ใช้ไปยัง Dialogflow และส่ง
ตอบกลับของตัวแทนในข้อความ
dialogflowResponse
คุณสามารถกําหนดค่า Agent ให้
ส่งคำตอบของ Dialogflow ไปยังผู้ใช้โดยอัตโนมัติ โดยไม่ต้องดำเนินการใดๆ
ดูการตอบกลับอัตโนมัติ
เพื่อดูรายละเอียด
การผสานรวม Dialogflow
ก่อนที่คุณจะใช้ประโยชน์จากการทำงานอัตโนมัติที่ใช้ Dialogflow ผ่าน Business Messages ได้ คุณต้องเปิดใช้การผสานรวม Dialogflow
ข้อกำหนดเบื้องต้น
ในการเริ่มใช้งาน คุณต้องมีสิ่งต่อไปนี้
- Business Messages agent
- ตัวแทน Dialogflow ในภูมิภาคทั่วโลกที่ใช้ภาษาอังกฤษ (th)
หากไม่มี Agent ของ Dialogflow ให้สร้าง Agent
Dialogflow ES
ก่อนที่คุณจะเปิดใช้งานการผสานรวม Dialogflow ES คุณต้องมี รหัสโปรเจ็กต์ของตัวแทน Dialogflow วิธีค้นหารหัสโปรเจ็กต์
- ไปที่ Dialogflow Console
- เลือก Agent ของ Dialogflow ที่ต้องการเชื่อมต่อกับ Business Messages
แล้วคลิกไอคอนรูปเฟือง
ถัดจากชื่อตัวแทน
- จดบันทึกค่ารหัสโปรเจ็กต์ในส่วนโปรเจ็กต์ Google
Dialogflow CX
ก่อนที่คุณจะเปิดใช้งานการผสานรวม Dialogflow CX ได้ คุณต้องมี รหัสโปรเจ็กต์และรหัสตัวแทนของ Dialogflow หากต้องการค้นหารหัสเหล่านี้
- ไปที่ Dialogflow CX Console
- เลือกโปรเจ็กต์ Dialogflow
- ในตัวเลือกตัวแทน ให้คลิกเมนูรายการเพิ่มเติม
ถัดจาก Agent ของ Dialogflow
- คลิกคัดลอกชื่อ โดยจะคัดลอกชื่อและนามสกุลของตัวแทนของคุณใน
รูปแบบต่อไปนี้:
projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID
- จดบันทึกค่ารหัสโปรเจ็กต์และรหัสตัวแทน
สร้างการผสานรวม
รับอีเมลบัญชีบริการ Dialogflow ของพาร์ทเนอร์จาก
dialogflowServiceAccountEmail
แทนที่ PARTNER_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 ของคุณ และ Agent ของ Dialogflow
ในGoogle Cloud คอนโซล เลือกโปรเจ็กต์ Dialogflow
ไปยัง IAM สิทธิ์
คลิกเพิ่ม แล้วป้อนอีเมลบัญชีบริการสำหรับสมาชิกใหม่
สำหรับเลือกบทบาท ให้เลือกเครื่องมือแก้ไข Agent ของ Dialogflow Console
คลิกเพิ่มบทบาทอื่น แล้วเลือกไคลเอ็นต์ Dialogflow API
คลิกบันทึก
ผสานรวมโปรเจ็กต์ Dialogflow กับตัวแทน Business Messages ของคุณ
แทนที่ AUTO_RESPONSE_STATUS ด้วย "เปิดใช้อยู่" หรือ "ปิดใช้" โดยขึ้นอยู่กับ คุณต้องการให้ Business Messages ตอบกลับโดยอัตโนมัติหรือไม่ ผู้ใช้ด้วยคำตอบใน Dialogflow
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 จะใช้เวลาประมาณ 2 นาที ถึง
ตรวจสอบสถานะของการผสานรวม รับ
OperationInfo
อัปเดตการผสานรวม
หากต้องการอัปเดตการตั้งค่าการตอบกลับอัตโนมัติของ Agent ให้เรียกใช้คำสั่งต่อไปนี้ แทนที่ AUTO_RESPONSE_STATUS ด้วย Enabled หรือ ปิดใช้โดยขึ้นอยู่กับว่าคุณต้องการให้ Business Messages โดยอัตโนมัติหรือไม่ โต้ตอบกับผู้ใช้ด้วยคำตอบของ Dialogflow
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 ได้ครั้งละ 1 รายการเท่านั้น หากต้องการเปลี่ยนจาก Dialogflow รุ่นหนึ่งไปเป็นอีกรุ่น คุณต้องนำ การผสานรวมปัจจุบันก่อนที่จะสร้างรายการใหม่
ลบการผสานรวม
หากต้องการนำ Dialogflow ออกจากตัวแทน Business Messages ให้ลบ ด้วยคำสั่งต่อไปนี้
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
ดูข้อมูลการผสานรวม
หากต้องการข้อมูลเกี่ยวกับการผสานรวม คุณสามารถใช้ Business Communications
API ตราบใดที่คุณมีค่า name
ของการผสานรวม
รับข้อมูลสำหรับการผสานรวมเดียว
หากต้องการรับข้อมูลการผสานรวม ให้เรียกใช้คำสั่งต่อไปนี้
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
แสดงรายการการผสานรวมทั้งหมดสำหรับตัวแทน
หากไม่ทราบชื่อการผสานรวม คุณสามารถดูข้อมูล การผสานรวมที่เชื่อมโยงกับตัวแทนโดยละเว้น INTEGRATION_ID จาก URL คำขอ GET เท่านั้น
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
การจับคู่ Intent
หลังจากที่คุณเปิดใช้การผสานรวม Dialogflow สำหรับตัวแทน Business Messages แล้ว Agent สามารถใช้ Intent ที่กำหนดค่าของโปรเจ็กต์ Dialogflow เพื่อทำความเข้าใจและ ตอบคำถามของผู้ใช้โดยที่คุณไม่ต้องเขียนโค้ด หากต้องการทราบข้อมูลเพิ่มเติมเกี่ยวกับ โปรดดูเอกสารสำหรับ Dialogflow ES และ Dialogflow CX
กำหนดค่า Intent ของ Dialogflow สำหรับตัวเลือกการสนทนาทั้งหมดที่ต้องการ การสนับสนุนผ่านระบบอัตโนมัติ ตัวแทน Business Messages อาศัย Dialogflow ทำความเข้าใจข้อความของผู้ใช้
เมื่อเรียกใช้ Dialogflow API แล้ว Business Messages จะส่งฟิลด์
เพย์โหลดข้อความของผู้ใช้
ของ Intent และเว็บฮุคของการดำเนินการตามคำสั่งซื้อ เมื่อมีการจับคู่ข้อความของผู้ใช้
โดยมีเจตนา คุณสามารถเข้าถึงเพย์โหลดนี้ในรูปแบบ Struct
ใน
business_messages_payload
ภายใน QueryParameters
เพย์โหลดจะมีทุกช่องจากข้อความของผู้ใช้ ยกเว้น DialogflowResponse
สำหรับ Dialogflow CX นั้น Business Messages จะส่งพารามิเตอร์เซสชันที่เรียกว่า channel
ที่มีค่า google_business_messages
ไปยัง Intent ด้วย ซึ่งคุณสามารถอ้างอิงพารามิเตอร์นี้ใน Agent โดยใช้รูปแบบ $session.params.channel
คุณใช้พารามิเตอร์นี้ในการเพิ่มเงื่อนไขไปยังการดำเนินการตามคำสั่งซื้อ Dialogflow เพื่อรองรับหลายแชแนลใน Agent ของ Dialogflow เดียวกันได้
ดูข้อมูลเพิ่มเติมเกี่ยวกับพารามิเตอร์การค้นหาได้ที่ข้อมูลอ้างอิงของ Dialogflow ES และ Dialogflow CX
ข้อกำหนดเบื้องต้น
เมื่อสร้างโมเดล NLU ภายใน Dialogflow คุณสามารถกำหนดค่า ประเภทการตอบสนองสำหรับ Intent Business Messages รองรับคำตอบเริ่มต้น ซึ่งอาจรวมถึงข้อมูลต่อไปนี้
- ข้อความ
- เพย์โหลดที่กำหนดเอง
- การส่งมอบตัวแทนแบบสด (Dialogflow CX เท่านั้น)
เพย์โหลดที่กำหนดเองต้องตรงกับการตอบกลับข้อความ JSON ของ Business Messages ที่ถูกต้อง ของ Google 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"
}
}
]
}
Rich Card
{
"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"
}
}
]
}
}
}
}
ภาพสไลด์ Rich Card
{
"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": {}
}
คำถามที่พบบ่อยเกี่ยวกับบ็อต
หลังจากที่คุณเปิดใช้การผสานรวม Dialogflow ES สำหรับตัวแทน Business Messages คุณจะ สามารถสร้างบ็อตคำถามที่พบบ่อยได้ เมื่อคุณใส่คำถามและคำตอบ เอกสารความรู้ที่รองรับ Business Messages และ Dialogflow โครงสร้างพื้นฐานที่จำเป็นต่อการทำความเข้าใจและตอบคำถามของผู้ใช้ คุณต้องเขียนโค้ดด้วย
หากต้องการดูการทำงานของบ็อตคำถามที่พบบ่อย ให้แชทกับคำถามที่พบบ่อยเกี่ยวกับ Business Messages บ็อต
ข้อกำหนดเบื้องต้น
ก่อนที่จะสร้างบ็อตคำถามที่พบบ่อย คุณต้องมีคำถามและคำตอบ เอกสารความรู้ (สูงสุด 50 MB): ไฟล์ HTML ที่เผยแพร่ต่อสาธารณะหรือไฟล์ CSV
โดยทั่วไป เอกสารความรู้
- อาจใส่มาร์กดาวน์แบบจำกัดในคำตอบ ตามที่ระบุไว้ในส่วน Rich ข้อความ
- มีขนาดสูงสุด 50 MB
- ไม่ควรเกิน 2,000 คู่คำถาม/คำตอบ
- อย่าสนับสนุนคำถามที่ซ้ำกันซึ่งมีคำตอบต่างกัน
สำหรับไฟล์ HTML
- ไฟล์จาก URL สาธารณะต้องได้รับการรวบรวมข้อมูลโดยโปรแกรมจัดทำดัชนีการค้นหาของ Google เพื่อให้มีอยู่ในดัชนีการค้นหา คุณสามารถตรวจสอบได้ด้วย Google Search Console โปรดทราบว่าตัวจัดทำดัชนีจะไม่อัปเดตเนื้อหาอยู่ตลอดเวลา คุณต้องแสดงอย่างชัดแจ้งว่า อัปเดตเอกสารเมื่อมีการเปลี่ยนแปลงเนื้อหาต้นฉบับ
- Dialogflow นำแท็ก HTML ออกจากเนื้อหาเมื่อสร้างการตอบกลับ เพราะ ทางที่ดีควรหลีกเลี่ยงการใช้แท็ก HTML และใช้ข้อความธรรมดาหากเป็นไปได้
- ระบบไม่รองรับไฟล์ที่มีคู่คำถาม/คำตอบเดียว
สำหรับไฟล์ CSV
- ไฟล์ต้องมีคำถามในคอลัมน์แรกและคำตอบในคอลัมน์ที่สอง ที่ไม่มีส่วนหัว
- ไฟล์ต้องใช้คอมมาเป็นตัวคั่น
สร้างบ็อตคำถามที่พบบ่อย
หากต้องการสร้างบ็อตคำถามที่พบบ่อย ก่อนอื่นคุณต้องสร้างฐานความรู้เพื่อจัดเก็บ ของบ็อต แล้วเพิ่มเอกสารอย่างน้อย 1 รายการที่มีคู่คำถาม/คำตอบลงใน ฐานความรู้
สร้างฐานความรู้
หากต้องการสร้างฐานความรู้ ให้เรียกใช้คำสั่งต่อไปนี้ แทนที่
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 อย่างมีความรู้ 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_RAW_BYTES กับ CSV ไฟล์เป็นสตริงที่เข้ารหัสฐาน 64
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
การเพิ่มเอกสารไปยังฐานความรู้จะใช้เวลาประมาณ 2 นาที หากต้องการตรวจสอบ
สถานะของเอกสาร รับ
OperationInfo
ลบเอกสารความรู้
หากต้องการนำคู่คำถาม/คำตอบออกจากตัวแทน Business Messages ลบเอกสารความรู้ที่มีเอกสารเหล่านั้นด้วยคำสั่งต่อไปนี้
เรียกใช้คำสั่งต่อไปนี้เพื่อลบเอกสารที่มีอยู่ 1 ฉบับ แทนที่
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 Messages จะตอบผู้ใช้โดยอัตโนมัติผ่าน Dialogflow ธุรกิจของคุณ ตัวแทนของ Messages ตอบกลับด้วยการจับคู่ระดับความเชื่อมั่นสูงสุด พร้อม การผสานรวม Dialogflow ES ถ้ามีทั้งคำตอบคำถามที่พบบ่อยและ Business Messages ตอบกลับด้วยการจับคู่ที่มีความตั้งใจที่กำหนดเองสูงสุด ระดับความเชื่อมั่น
Business Messages จะทำเครื่องหมายข้อความตอบกลับอัตโนมัติทั้งหมดว่ามาจาก BOT
หากตัวแทนของคุณรองรับตัวแทนแบบเรียลไทม์
Business Messages จะระงับการตอบกลับอัตโนมัติหลังจากวันที่ REPRESENTATIVE_JOINED
กิจกรรม
และระบบจะกลับมาตอบกลับอัตโนมัติหลังจากเหตุการณ์ REPRESENTATIVE_LEFT
เหตุการณ์ ดู Handoff
ตั้งแต่บ็อตไปจนถึงตัวแทนแบบเรียลไทม์
ตอบกลับอัตโนมัติด้วยคำตอบของคำถามที่พบบ่อย
เมื่อใช้การผสานรวม Dialogflow ES หากคําตอบของคําถามที่พบบ่อยมีความมั่นใจสูงสุด Business Messages จะแมปคำตอบกับ SMS หากมี เกี่ยวข้องแต่มีคำตอบต่างกัน ข้อความจะแสดงลิงก์ "ดูข้ออื่น รับสาย" แนะนำ หากไม่ใช่ ข้อความจะมีทั้งคำถามและคำแนะนำ จะถามว่าข้อความตอบสนองต่อคำขอของผู้ใช้หรือไม่
ตอบกลับอัตโนมัติด้วยการตอบสนองตามความตั้งใจ
การตอบกลับด้วยความตั้งใจอาจมีการตอบกลับต่อไปนี้อย่างน้อย 1 รายการ
- Dialogflow ES: ข้อความ เพย์โหลดที่กำหนดเอง
- Dialogflow CX: ข้อความ เพย์โหลดที่กำหนดเอง การส่งมอบตัวแทนแบบเรียลไทม์
หากการตอบสนองของ Intent มีระดับความเชื่อมั่นที่ตรงกันสูงสุด ระบบจะดำเนินการดังต่อไปนี้ นำไปใช้ได้
- หากคำตอบมีค่า Text อย่างน้อย 1 ค่า Business Messages จะแมปค่านี้ เป็นข้อความตัวอักษร
- หากการตอบสนองมีเพย์โหลดที่กำหนดเองอย่างน้อย 1 รายการที่มี Business ที่ถูกต้อง โครงสร้างออบเจ็กต์ JSON ของ Messages โดย Business Messages จะสร้างข้อความโดยใช้ ออบเจ็กต์ JSON ที่ให้ไว้
- หากการตอบกลับมีการตอบกลับด้วยการส่งตัวแทนแบบเรียลไทม์อย่างน้อย 1 รายการ โปรดดู ตอบกลับอัตโนมัติด้วยคำขอตัวแทนแบบเรียลไทม์
เนื่องจาก Dialogflow สามารถมี หลายคำตอบภายใน Intent เดียวที่ตรงกัน Business Messages จะส่งข้อความแต่ละรายการ เพย์โหลดที่กำหนดเอง หรือการส่งต่อตัวแทนแบบเรียลไทม์ เป็นข้อความแยกต่างหาก หากมีหลายข้อความใน Intent ตรงกัน แต่ข้อความบางส่วนมีรูปแบบไม่ถูกต้อง Business Messages จะส่งเฉพาะข้อมูลที่ถูกต้อง การตอบกลับอัตโนมัติ
ตอบกลับอัตโนมัติด้วยคำขอตัวแทนแบบเรียลไทม์
Dialogflow CX รองรับการส่งมอบไปยังตัวแทนแบบเรียลไทม์ คำตอบ สัญญาณนี้บ่งบอกว่าควรส่งต่อการสนทนาให้กับมนุษย์ และให้คุณส่งข้อมูลเมตาที่กำหนดเองสำหรับการส่งต่อ หากการตอบสนองของ Intent มีระดับความเชื่อมั่นที่ตรงกันสูงสุด รวมถึงการส่งมอบตัวแทนแบบสด โดย Business Messages จะส่ง กิจกรรมที่ตัวแทนแบบเรียลไทม์ขอ ไปยังเว็บฮุคของคุณ หากต้องการจัดการกิจกรรมนี้ โปรดดู ส่งต่อจากบ็อตเป็นตัวแทนแบบเรียลไทม์
ตอบกลับอัตโนมัติด้วยข้อความสำรอง
หาก Dialogflow ไม่ได้รับการจับคู่ในระดับความเชื่อมั่นสูง Business Messages จะส่ง การตอบกลับสำรอง มีการจัดการสำรองใน Dialogflow ES และ Dialogflow CX
Dialogflow ES
สำหรับบ็อตคำถามที่พบบ่อย หากไม่มีคำตอบที่ตรงกับคำถามที่พบบ่อย Business Messages จะส่ง ข้อความสำรองที่ไม่พบคำตอบ
สำหรับ Intent ที่กำหนดค่า หากไม่ตรงกับการตอบกลับ Intent ธุรกิจ Messages จะส่งการตอบสนอง Intent สำรอง คุณสามารถใช้ข้อความสำรองที่ Dialogflow มีให้ หรือกำหนดค่า วิดีโอสำรองพร้อมข้อความเพิ่มเติมและเพย์โหลดที่กำหนดเอง
ตัวอย่างการตอบสนอง Intent สำรองที่เว็บฮุคของคุณมีดังนี้ สามารถรับ:
{
"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 จัดการการตอบสนอง Intent สำรองเป็น เหตุการณ์ในตัว หากไม่มีการตอบสนอง Intent ใด Business Messages จะส่งข้อความ ข้อความสำรองจากเหตุการณ์เริ่มต้นที่ไม่มีการจับคู่ใน Dialogflow คุณสามารถ ใช้ข้อความสำรองที่ Dialogflow ให้ไว้ หรือกำหนดค่าวิดีโอสำรอง พร้อมด้วยข้อความเพิ่มเติม เพย์โหลดที่กำหนดเอง และตัวเลือกการโอนตัวแทนแบบสด
ตัวอย่างการตอบสนอง Intent สำรองที่ เว็บฮุคสามารถรับสิ่งต่อไปนี้ได้
{
"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 แล้ว ผู้ใช้จะส่งข้อความถึง Agent
ที่ได้รับ
มี
dialogflowResponse
ออบเจ็กต์ เว็บฮุคจะได้รับเพย์โหลดสำหรับข้อความผู้ใช้ทั้งหมดโดยไม่คำนึงถึง
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 |
ตัวระบุที่ไม่ซ้ำกันของความตั้งใจที่ตรงกัน |
intentDisplayName |
ชื่อของความตั้งใจที่ตรงกัน |
intentDetectionConfidence
|
ตัวเลขคะแนนความเชื่อมั่นในการแข่งขัน
ระหว่าง queryText ถึง intentName |
text |
ข้อความตอบกลับ |
jsonPayload
|
การตอบสนองของเพย์โหลดที่กำหนดเอง
สตริงนี้ตรงกับ
เพย์โหลดที่กำหนดไว้ใน Dialogflow
หากเพย์โหลดไม่มี Business Messages JSON ที่ถูกต้อง
โครงสร้างออบเจ็กต์ error อธิบายถึงปัญหา |
error |
คำอธิบายของข้อผิดพลาดที่มีข้อความดำเนินการตาม Intent |
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 |
ตัวระบุที่ไม่ซ้ำกันของความตั้งใจที่ตรงกัน |
intentDisplayName |
ชื่อของความตั้งใจที่ตรงกัน |
intentDetectionConfidence
|
ตัวเลขคะแนนความเชื่อมั่นในการแข่งขัน
ระหว่าง queryText ถึง intentName |
text |
ข้อความตอบกลับ |
jsonPayload
|
การตอบสนองของเพย์โหลดที่กำหนดเอง
สตริงนี้ตรงกับ
เพย์โหลดที่กำหนดไว้ใน Dialogflow
หากเพย์โหลดไม่มี Business Messages JSON ที่ถูกต้อง
โครงสร้างออบเจ็กต์ error อธิบายถึงปัญหา |
error |
คำอธิบายของข้อผิดพลาดที่มีข้อความดำเนินการตาม Intent |
liveAgentHandoff |
ข้อมูลเมตาที่กำหนดเองสำหรับขั้นตอนการโอนตัวแทนแบบสด |
autoResponded
|
Business Messages ตอบกลับโดยอัตโนมัติหรือไม่ ผู้ใช้ด้วยคำตอบจาก Dialogflow |
message |
เพย์โหลดของการตอบกลับอัตโนมัติ |
responseSource
|
แหล่งที่มาของการตอบกลับอัตโนมัติ โปรดดู
ResponseSource |