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