يتيح وكلاء ميزة "الرسائل التجارية" التكامل المباشر مع
- Dialogflow ES: مطابقة الأهداف وبرامج التتبُّع الشائعة
- Dialogflow CX: مطابقة نيّة الشراء وتسليم الوكيل مباشرةً
لدمج وكيل "الرسائل التجارية" مع ميزات أخرى في Dialogflow ES أو Dialogflow CX، يمكنك الرجوع إلى كل مستندات المنتج.
عندما يُرسل أحد المستخدمين رسالة إلى وكيل لديه دمج Dialogflow، يمرِّر تطبيق "الرسائل التجارية" رسالة المستخدم إلى Dialogflow ويرسل الرد إلى Dialogflow's
إلى موظّف الدعم في العنصر {39;s
dialogflowResponse
. يمكنك ضبط الوكلاء لإرسال استجابة Dialogflow'للمستخدم تلقائيًا بدون اتخاذ أي إجراء من جانبك. يمكنك مراجعة الردود التلقائية
للحصول على التفاصيل.
دمج Dialogflow
قبل أن تتمكّن من الاستفادة من الأساليب المبرمَجة المستندة إلى Dialogflow من خلال الرسائل التجارية، عليك تفعيل عملية دمج Dialogflow.
المتطلبات الأساسية
للبدء، تحتاج إلى
- موظّف دعم الرسائل التجارية
- وكيل Dialogflow في المنطقة العالمية بلغة جذرية باللغة الإنجليزية (en)
إذا لم يكن لديك وكيل Dialogflow، أنشئ واحدًا.
Dialogflow ES
قبل أن تتمكّن من تفعيل عملية دمج Dialogflow ES، ستحتاج إلى رقم تعريف المشروع الخاص بوكيل Dialogflow. للعثور على رقم تعريف المشروع،
- انتقِل إلى Dialogflow Console.
- اختَر وكيل Dialogflow الذي تريد ربطه برسائل الأنشطة التجارية،
ثم انقر على رمز الترس
بجانب اسم الوكيل.
- ضمن مشروع Google، لاحظ قيمة رقم تعريف المشروع.
Dialogflow CX
قبل أن تتمكّن من تفعيل عملية دمج Dialogflow CX، ستحتاج إلى رقم تعريف المشروع ومعرِّف الوكيل في Dialogflow. للعثور على أرقام التعريف هذه،
- انتقِل إلى Dialogflow CX Console.
- اختَر مشروعك على Dialogflow.
- في أداة اختيار الوكيل، انقر على رمز القائمة الكاملة
بجانب وكيل Dialogflow.
- انقر على نسخ الاسم. يؤدي هذا الإجراء إلى نسخ الاسم الكامل لموظّف الدعم
بالتنسيق التالي:
projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID
. - دوِّن رقم تعريف المشروع ورقم تعريف الوكيل.
إنشاء عملية دمج
الحصول على البريد الإلكتروني لحساب خدمة Dialogflow's من الشريك
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)
انسخ البريد الإلكتروني لحساب الخدمة. يربط هذا الحساب بين رسائل الأنشطة التجارية ووكلاء Dialogflow.
في Google Cloud Console، اختَر مشروعك على Dialogflow.
انتقِل إلى أذونات إدارة الهوية وإمكانية الوصول.
انقر على إضافة، وأدخِل البريد الإلكتروني لحساب الخدمة الذي يخص الأعضاء الجدد.
بالنسبة إلى اختيار دور، اختَر محرّر وكيل Dialogflow.
انقر على إضافة دور آخر واختر عميل واجهة برمجة تطبيقات Dialogflow.
انقر على حفظ.
يمكنك دمج مشروع Dialogflow مع وكيل "الرسائل التجارية".
استبدِل AUTO_RESPONSE_STATUS بالتفعيل أو الإيقاف، بناءً على ما إذا كنت تريد استجابة الرسائل التجارية تلقائيًا للمستخدمين من خلال الردود على 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
.
يستغرق ربط الرسائل التجارية وDialogflow حوالي دقيقتين. للتحقّق من حالة عملية الدمج، يُرجى الحصول على الدمج في OperationInfo
.
تعديل عملية الدمج
لتعديل إعداد الرد التلقائي للوكيل، شغِّل الأمر التالي. استبدِل AUTO_RESPONSE_STATUS بالتفعيل أو الإيقاف استنادًا إلى ما إذا كنت تريد استجابة الرسائل التجارية تلقائيًا للمستخدمين من خلال الردود على 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
يمكن لوكيل ميزة "الرسائل التجارية" دعم عملية دمج Dialogflow واحدة في كل مرة. للتبديل من إصدار Dialogflow إلى إصدار آخر، عليك إزالة الدمج الحالي قبل إنشاء الإصدار الجديد.
حذف الدمج
إذا كنت بحاجة إلى إزالة Dialogflow من وكيل رسائل الأنشطة التجارية، احذف الدمج مع الأمر التالي.
عنوان cURL
# This code deletes an integration. # Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#delete_the_integration # Replace the __BRAND_ID__, __AGENT_ID__ and __INTEGRATION_ID__ # Make sure a service account key file exists at ./service_account_key.json curl -X DELETE \ "https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__/integrations/__INTEGRATION_ID__" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)"
Node.js
/** * This code snippet deletes an integration. * Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#delete_the_integration * * This code is based on the https://github.com/google-business-communications/nodejs-businesscommunications Node.js * Business Communications client library. */ /** * Edit the values below: */ const BRAND_ID = 'EDIT_HERE'; const AGENT_ID = 'EDIT_HERE'; const INTEGRATION_ID = 'EDIT_HERE'; const PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json'; const businesscommunications = require('businesscommunications'); const {google} = require('googleapis'); const uuidv4 = require('uuid').v4; // Initialize the Business Communications API const bcApi = new businesscommunications.businesscommunications_v1.Businesscommunications({}); // Set the scope that we need for the Business Communications API const scopes = [ 'https://www.googleapis.com/auth/businesscommunications', ]; // Set the private key to the service account file const privatekey = require(PATH_TO_SERVICE_ACCOUNT_KEY); async function main() { const authClient = await initCredentials(); const integrationName = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID + '/integrations/' + INTEGRATION_ID; if (authClient) { // Setup the parameters for the API call const apiParams = { auth: authClient, name: integrationName, }; bcApi.brands.agents.integrations.delete(apiParams, {}, (err, response) => { if (err !== undefined && err !== null) { console.dir(err); } else { // Agent created console.log(response.data); } }); } else { console.log('Authentication failure.'); } } /** * Initializes the Google credentials for calling the * Business Messages API. */ async function initCredentials() { // Configure a JWT auth client const authClient = new google.auth.JWT( privatekey.client_email, null, privatekey.private_key, scopes, ); return new Promise(function(resolve, reject) { // Authenticate request authClient.authorize(function(err, tokens) { if (err) { reject(false); } else { resolve(authClient); } }); }); } main();
Python
"""This code snippet deletes an integration. Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#delete_the_integration This code is based on the https://github.com/google-business-communications/python-businessmessages Python Business Messages client library. """ from oauth2client.service_account import ServiceAccountCredentials from businesscommunications.businesscommunications_v1_client import BusinesscommunicationsV1 from businesscommunications.businesscommunications_v1_messages import ( BusinesscommunicationsBrandsAgentsIntegrationsDeleteRequest ) # Edit the values below: BRAND_ID = 'EDIT_HERE' AGENT_ID = 'EDIT_HERE' INTEGRATION_ID = 'EDIT_HERE' SCOPES = ['https://www.googleapis.com/auth/businesscommunications'] SERVICE_ACCOUNT_FILE = './service_account_key.json' credentials = ServiceAccountCredentials.from_json_keyfile_name( SERVICE_ACCOUNT_FILE, scopes=SCOPES) client = BusinesscommunicationsV1(credentials=credentials) integrations_service = BusinesscommunicationsV1.BrandsAgentsIntegrationsService(client) integration_name = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID + '/integrations/' + INTEGRATION_ID integration = integrations_service.Delete(BusinesscommunicationsBrandsAgentsIntegrationsDeleteRequest( name=integration_name )) print(integration)
لمعرفة خيارات التنسيق والقيمة، يُرجى الاطّلاع على
Integration
.
الحصول على معلومات حول الدمج
للحصول على معلومات حول عملية الدمج، يمكنك استخدام واجهة برمجة التطبيقات
لاتصالات الأنشطة التجارية، طالما لديك القيمة name
الخاصة بعملية الدمج.
الحصول على معلومات لدمج واحد
للحصول على معلومات الدمج، شغِّل الأمر التالي.
عنوان 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
.
مطابقة النيّة بالشراء
بعد تفعيل عملية دمج Dialogflow لوكيل ميزة "الرسائل التجارية"، يمكن لوكيلك استخدام مشاريع Dialogflow التي تم ضبطها للمساعدة في فهم أسئلة المستخدم والردّ عليها بدون الحاجة إلى كتابة الرمز. للحصول على مزيد من المعلومات حول ترغب في الشراء، يُرجى الاطّلاع على وثائق Dialogflow ES وDialogflow CX.
يمكنك ضبط عناصر Dialogflow لكل خيار محادثة تنوي استخدامه من خلال الأساليب المبرمَجة. يعتمد وكلاء ميزة "الرسائل التجارية" على Dialogflow لفهم رسائل المستخدمين.
عند استدعاء واجهات برمجة تطبيقات Dialogflow، يمرّر تطبيق "الرسائل التجارية"
حمولة رسالة المستخدم
إلى أهدافك وعلى الرد التلقائي على الويب لتوصيل الطلب. عند مطابقة رسالة مستخدم مع غرض معيّن، يمكنك الوصول إلى هذه الحمولة بتنسيق Struct
في الحقل business_messages_payload
ضمن QueryParameters
.
تحتوي الحمولة على جميع الحقول من رسالة المستخدم باستثناء DialogflowResponse
.
بالنسبة إلى Dialogflow CX، يمرِّر تطبيق "الرسائل التجارية" أيضًا مَعلمة جلسة تُسمى channel
بالقيمة google_business_messages
إلى نقاط intent ويمكنك الرجوع إليها في وكيلك بالتنسيق التالي: $session.params.channel
.
يمكن استخدام هذه المعلّمة لإضافة شروط إلى عمليات تنفيذ Dialogflow من أجل إتاحة قنوات متعددة في وكيل Dialogflow نفسه.
لمزيد من المعلومات عن معلَمات طلب البحث، يُرجى الاطّلاع على مرجعَي Dialogflow ES وDialogflow CX.
المتطلبات الأساسية
عند إنشاء نماذج NLU ضمن Dialogflow، يمكنك ضبط أنواع استجابة مختلفة لغرض معيّن. يتيح تطبيق "الرسائل التجارية" الاستجابة التلقائية التي يمكن أن تشمل ما يلي:
- نصية
- حمولة مخصّصة
- نقل العميل المباشر (Dialogflow CX فقط)
يجب أن تتطابق الحمولة المخصّصة مع كائن ردّ رسالة JSON بتنسيق JSON صالح. عند ضبط ردود الحمولة المخصّصة لغرض معيّن، تتجاهل ميزة "الرسائل التجارية" الحقول التالية:
name
messageId
representative
اطّلِع على نماذج الردود التالية.
النص مع الاقتراحات
{
"text": "Hello World!",
"fallback": "Hello World!\n\nReply with \"Hello\" or \"Hi!\"",
"suggestions": [
{
"reply": {
"text": "Hello",
"postbackData": "hello-formal"
}
},
{
"reply": {
"text": "Hi!",
"postbackData": "hello-informal"
}
}
]
}
بطاقة تفاعلية
{
"fallback": "Hello, world!\nSent with Business Messages\n\nReply with \"Suggestion #1\" or \"Suggestion #2\"",
"richCard": {
"standaloneCard": {
"cardContent": {
"title": "Hello, world!",
"description": "Sent with Business Messages.",
"media": {
"height": "TALL",
"contentInfo":{
"altText": "Google logo",
"fileUrl": "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png",
"forceRefresh": "false"
}
},
"suggestions": [
{
"reply": {
"text": "Suggestion #1",
"postbackData": "suggestion_1"
}
},
{
"reply": {
"text": "Suggestion #2",
"postbackData": "suggestion_2"
}
}
]
}
}
}
}
منصّة العرض بعناصر متغيّرة للبطاقة التفاعلية
{
"fallback": "Card #1\nThe description for card #1\n\nCard #2\nThe description for card #2\n\nReply with \"Card #1\" or \"Card #2\"",
"richCard": {
"carouselCard": {
"cardWidth": "MEDIUM",
"cardContents": [
{
"title": "Card #1",
"description": "The description for card #1",
"suggestions": [
{
"reply": {
"text": "Card #1",
"postbackData": "card_1"
}
}
],
"media": {
"height": "MEDIUM",
"contentInfo": {
"fileUrl": "https://my.files/cute-dog.jpg",
"forceRefresh": false
}
}
},
{
"title": "Card #2",
"description": "The description for card #2",
"suggestions": [
{
"reply": {
"text": "Card #2",
"postbackData": "card_2"
}
}
],
"media": {
"height": "MEDIUM",
"contentInfo": {
"fileUrl": "https://my.files/elephant.jpg",
"forceRefresh": false
}
}
}
]
}
}
}
نقل موظّف الدعم مباشرةً
{
"metadata": {}
}
الأسئلة الشائعة حول برامج التتبُّع
بعد تفعيل دمج Dialogflow ES لوكيل ميزة "الرسائل التجارية"، يمكنك إنشاء برنامج تتبُّع للأسئلة الشائعة. عند تقديم الأسئلة والأجوبة كمستند معرفة متوافق، تعمل ميزة "الرسائل التجارية" وDialogflow على إنشاء البنية الأساسية اللازمة لفهم أسئلة المستخدمين والرد عليها بدون الحاجة إلى كتابة أي رموز.
للاطّلاع على برنامج تتبُّع للأسئلة الشائعة، يمكنك إجراء محادثة مع برنامج الأسئلة الشائعة حول ميزة "الرسائل التجارية".
المتطلبات الأساسية
قبل إنشاء برنامج تتبُّع للأسئلة الشائعة، يجب أن تتوفّر أسئلتك وإجاباتك كمستند معلومات (بحد أقصى 50 ميغابايت)، ويجب أن يكون ملف HTML متاحًا للجميع أو ملف CSV.
بوجه عام، مستندات المعرفة
- يمكن أن تتضمن هذه العلامة مقاسًا محدودًا في الإجابات، كما هو محدّد في النص المنسّق.
- الحد الأقصى للحجم 50 ميغابايت.
- يجب ألا تتجاوز 2000 زوج من الأسئلة/الإجابات.
- لا تتيح الإجابة عن الأسئلة المكرّرة بإجابات مختلفة.
وبالنسبة إلى ملفات HTML،
- يجب أن يكون محرّك بحث Google قد زحف إلى الملفات الواردة من عناوين URL المتاحة للجميع، بحيث تكون متوفرة في فهرس البحث. يمكنك التحقق من ذلك باستخدام Google Search Console. يُرجى ملاحظة أن الفهرس لا يحافظ على تحديث المحتوى الخاص بك. يجب تحديث المستند صراحةً عند تغيير محتوى المصدر.
- تزيل Dialogflow علامات HTML من المحتوى عند إنشاء الردود. ولهذا السبب، من الأفضل تجنّب علامات HTML واستخدام نص عادي متى أمكن ذلك.
- الملفات التي تحتوي على زوج واحد من الأسئلة أو الإجابات غير متوافقة.
وبالنسبة إلى ملفات CSV،
- يجب أن تتضمّن الملفات أسئلة في العمود الأول وإجابات عنها في العمود الثاني، بدون عنوان.
- يجب أن تستخدم الملفات فواصل كمُحدِّدات.
إنشاء برنامج تتبُّع للأسئلة الشائعة
لإنشاء برنامج تتبُّع للأسئلة الشائعة، عليك أولاً إنشاء قاعدة معلومات لتخزين جميع بيانات برامج التتبُّع، ثم إضافة مستند واحد أو أكثر باستخدام أزواج الأسئلة/الإجابات إلى قاعدة المعلومات الخاصة بك.
إنشاء قاعدة معلومات
لإنشاء قاعدة معلومات، شغِّل الأمر التالي. استبدِل 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 كسلسلة مشفّرة
عنوان cURL
# This code creates a knowledge base document from a CSV document and adds it to the knowledge base. # Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#create-document # Replace the __BRAND_ID__, __AGENT_ID__, __INTEGRATION_ID__, __KNOWLEDGE_BASE_DISPLAY_NAME__, __DOCUMENT_DISPLAY_NAME__ and __CSV_RAW_BYTES__ # Make sure a service account key file exists at ./service_account_key.json curl -X PATCH \ "https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__/integrations/__INTEGRATION_ID__?updateMask=dialogflowEsIntegration.dialogflowKnowledgeBases" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \ -d '{ "dialogflowEsIntegration": { "dialogflowKnowledgeBases": [ { "displayName": "__KNOWLEDGE_BASE_DISPLAY_NAME__", "documents": [ { "displayName": "__DOCUMENT_DISPLAY_NAME__", "rawContent": "__CSV_RAW_BYTES__" } ] } ] } }'
لمعرفة خيارات التنسيق والقيمة، يُرجى الاطّلاع على
DialogflowKnowledgebase
.
تستغرق إضافة مستند إلى قاعدة معلومات حوالي دقيقتين. للتحقّق من حالة المستند، اطّلِع على عملية الدمج OperationInfo
.
حذف مستند معلومات
إذا كنت بحاجة إلى إزالة أزواج الأسئلة/الإجابات من وكيل الرسائل التجارية، احذِف مستند المعرفة الذي يحتوي عليها باستخدام الأمر التالي.
شغِّل الأمر التالي لحذف مستند واحد حالي. استبدِل 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، سترد "الرسائل التجارية" على المستخدم تلقائيًا من خلال Dialogflow. يردّ موظّف الدعم التجاري على ميزة "الرسائل" بالاستناد إلى أعلى مستوى من المطابقة. من خلال دمج Dialogflow ES، إذا كان هناك تطابقات مع إجابة للأسئلة الشائعة وقصد مخصّص، تستجيب ميزة "الرسائل التجارية" بالمطابقة التي حصلت على أعلى مستوى من الثقة.
تعمل ميزة "الرسائل التجارية" على وضع علامة على جميع الرسائل التي يتم الردّ عليها تلقائيًا على أنها واردة من ممثلين عن BOT
. إذا كان وكيلك يدعم وكلاء الدعم المباشرين،
يعلّق تطبيق "الرسائل التجارية" الردود التلقائية بعد REPRESENTATIVE_JOINED
الأحداث
ويستأنف الردود التلقائية بعد REPRESENTATIVE_LEFT
أحداث. يمكنك الاطّلاع على Handoff
من برنامج التتبُّع إلى موظّف الدعم مباشرةً.
الرد التلقائي بإجابة عن الأسئلة الشائعة
مع دمج Dialogflow ES، إذا كانت الإجابة عن الأسئلة الشائعة هي أعلى مستوى من الثقة، ستربط ميزة "الرسائل التجارية" الإجابة برسالة نصية. إذا كان هناك إجابة ذات صلة ولكن مختلفة، ستظهر الرسالة اقتراح &عرض آخر. إذا كانت الإجابة لا، ستشمل الرسالة سؤالًا مطروحًا والرد على أسئلة المستخدمين بشأن ما إذا كانت الرسالة تلبي طلب المستخدم.
الرد التلقائي باستجابة للقصد
يمكن أن تتضمّن الردود على النية بالشراء واحدًا أو أكثر من الردود التالية.
- Dialogflow ES: النص، الحمولة المخصّصة
- Dialogflow CX: النص، والشحن المخصّص، تسليم الوكيل مباشرةً
إذا تضمّنت الاستجابة للقصد أعلى مستوى من الثقة، ينطبق ما يلي.
- إذا كانت الاستجابة تحتوي على قيمة نصية واحدة على الأقل، تربط ميزة "الرسائل التجارية" هذه القيمة برسالة نصية.
- إذا كانت الاستجابة تحتوي على حمولة مخصّصة واحدة على الأقل مع بنية عنصر JSON صالح للرسائل، تُنشئ ميزة "الرسائل التجارية" رسالة باستخدام كائن JSON المقدَّم.
- إذا كان الردّ يتضمّن ردًا واحدًا على الأقل لموظّف الدعم المباشر، يُرجى الاطّلاع على الاستجابة التلقائية لطلب الوكيل المباشر.
بما أنّ Dialogflow يمكن أن يتضمّن عدة ردود ضمن هدف واحد، تُرسل ميزة "الرسائل التجارية" كل رد نصي أو ردّ مخصَّص أو ردّ تلقائي على موظّف الدعم كرسالة منفصلة. إذا كانت هناك عدة رسائل في تطابق هدف، ولكن بعضها تمت صياغته بشكل غير صحيح، لا يُرسل "الرسائل التجارية" إلا رسائل صالحة كردود تلقائية.
الرد التلقائي على طلب موظف الدعم المباشر
يتيح Dialogflow CX الردّ على النقل المباشر لوكيل المستخدم. وهو يشير إلى أنّه يجب تسليم المحادثة إلى أحد ممثلي المؤسسة، وأنّه يسمح لك بتمرير البيانات الوصفية المخصّصة لعملية التسليم. إذا كانت الاستجابة للنية بالشراء لديها أعلى مستوى للثقة، وهي تتضمّن تسليم موظف الدعم المباشر، ترسل ميزة "الرسائل التجارية" حدثًا مطلوبًا من موظّف الدعم إلى الردّ التلقائي على الويب. للتعامل مع هذا الحدث، يمكنك الاطّلاع على Handoff من برنامج التتبُّع إلى موظّف الدعم مباشرةً.
الرد التلقائي باستخدام رسالة احتياطية
إذا لم تحصل Dialogflow على مطابقة عالية الثقة لمستوى الأداء، سترسل ميزة "الرسائل التجارية" ردًا احتياطيًا. يتم التعامل مع عمليات الاحتياطي بشكل مختلف في Dialogflow ES و Dialogflow CX.
Dialogflow ES
في حال توفُّر "إجابة عن الأسئلة الشائعة" في برامج تتبُّع الأسئلة الشائعة، تُرسل ميزة "الرسائل التجارية" رسالة احتياطية تعذّر عليها العثور على الإجابة المطلوبة.
بالنسبة إلى الأهداف التي تم ضبطها، إذا لم يكن هناك تطابق مع استجابة intent، ترسل ميزة "الرسائل التجارية" ردًا احتياطيًا حسب النية بالشراء. يمكنك استخدام النص الاحتياطي المقدَّم من Dialogflow أو ضبط الإجراء الاحتياطي باستخدام نص إضافي وحمولات مخصّصة.
في ما يلي مثال على ردّ بديل حسب النية بالشراء يمكن أن يتلقّاه الرد التلقائي على الويب:
{
"intentResponses": [
{
"intentName": "projects/df-integration/agent/intents/12345",
"intentDisplayName": "Default Fallback Intent",
"intentDetectionConfidence": "1.0",
"fulfillmentMessages": [
{
"text": "One more time?"
}
]
}
]
}
تتم تعبئة intent_name
وintent_display_name
تلقائيًا في Dialogflow.
Dialogflow CX
تتعامل لعبة Dialogflow CX مع الردود على النية بالشراء باعتبارها أحداث مضمّنة. إذا لم يكن هناك تطابق مع استجابة intent، ترسل ميزة "الرسائل التجارية" رسالة احتياطية من الحدث التلقائي "عدم المطابقة" في Dialogflow. ويمكنك استخدام النص الاحتياطي المقدَّم من Dialogflow أو ضبط الإجراء الاحتياطي باستخدام نص إضافي وحمولات مخصّصة وخيارات تسليم الوكيل مباشرةً.
في ما يلي مثال على ردّ بديل بنيّة احتياطية يمكن أن يتلقّاه الردّ التلقائي على الويب:
{
"intentResponses": [
{
"intentName": "sys.no-match-default",
"intentDisplayName": "Default Fallback Intent",
"intentDetectionConfidence": "0.3",
"fulfillmentMessages": [
{
"text": "I missed that, say that again?"
}
]
}
]
}
تُرسل "الرسائل التجارية" رمزَي البيانات الثابتة intent_name
وintent_display_name
.
حقول خاصة بمربع الحوار
بعد تفعيل عملية دمج Dialogflow، ستتضمن رسائل المستخدم
مستلمًا
العنصر
dialogflowResponse
. يتطلّب الرد التلقائي على الويب حمولات لكل رسائل المستخدمين، بغض النظر عمّا إذا كانت الرسائل التجارية قد ردت تلقائيًا على الرسالة نيابةً عنك أم لا. للتحقّق من الرد التلقائي، يمكنك الاطّلاع على قيمة الحقل
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.
إذا لم تكن الحمولة تتضمن بنية كائن JSON صالحة لتطبيق "الرسائل التجارية"، يصف error المشكلة. |
error |
وصف لخطأ مع رسالة القصد من تنفيذ الطلب. |
userQuestion |
السؤال الذي طرحه المستخدم، وفقًا لتحليل Dialogflow. |
faqQuestion |
هناك سؤال من Dialogflow يتطابق مع سؤال المستخدم. |
faqAnswer |
هناك إجابة من Dialogflow تتطابق مع سؤال المستخدم. |
matchConfidenceLevel
|
مستوى الثقة في المطابقة بين userQuestion وfaqQuestion . |
matchConfidence
|
تقييم الثقة الرقمي في المطابقة بين userQuestion وfaqQuestion . |
autoResponded
|
يمكنك اختيار الردّ تلقائيًا على المستخدم بالإجابة من 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.
إذا لم تكن الحمولة تتضمن بنية كائن JSON صالحة لتطبيق"الرسائل التجارية"، يصف error المشكلة. |
error |
وصف لخطأ مع رسالة القصد من تنفيذ الطلب. |
liveAgentHandoff |
بيانات وصفية مخصّصة لإجراء نقل الوكيل المباشر |
autoResponded
|
يمكنك اختيار الردّ تلقائيًا على المستخدم بالإجابة من Dialogflow. |
message |
البيانات الأساسية للاستجابة التلقائية |
responseSource
|
مصدر الاستجابة التلقائية. يمكنك الاطّلاع على
ResponseSource . |