إضافة ميزات التشغيل الآلي باستخدام Dialogflow

تعتبر منصة Dialogflow هي أداة فهم اللغة (NLU) التي تعالج إدخالات المستخدم، وتربطه بالعناصر وأغراضه، ويجيب بالردود المناسبة. يتوفّر إصداران. من Dialogflow. من خلال دمج وكيل "الرسائل التجارية" مع Dialogflow ES يمكنك بسهولة إنشاء عملية تشغيل آلي بسيطة لتعزيز عملية تطوير موظفي الدعم. من من خلال الدمج مع Dialogflow CX، يمكنك إنشاء عمليات مبرمَجة متقدّمة والمحادثات المعقدة.

يقدّم الوكلاء في ميزة "الرسائل التجارية" إمكانية الدمج المباشر مع

لدمج وكيل في ميزة "الرسائل التجارية" مع ميزات أخرى في Dialogflow ES أو Dialogflow CX، يُرجى الرجوع إلى وثائق كل منتج.

عندما يرسل المستخدم رسالة إلى وكيل لديه عملية دمج Dialogflow، تنقل ميزة "الرسائل التجارية" رسالة المستخدم إلى Dialogflow وترسل للوكيل في الرسالة dialogflowResponse. يمكنك إعداد الوكلاء إرسال رد Dialogflow تلقائيًا إلى المستخدم بدون الحاجة إلى اتخاذ أي إجراء الجزء. الاطّلاع على الردود التلقائية لمزيد من التفاصيل.

دمج Dialogflow

قبل أن تتمكّن من الاستفادة من الأساليب المبرمَجة المستنِدة إلى Dialogflow من خلال ميزة "الرسائل التجارية"، عليك تفعيل عملية دمج Dialogflow.

المتطلبات الأساسية

للبدء، تحتاج إلى

  • الرسائل التجارية agent
  • وكيل Dialogflow في المنطقة العالمية باستخدام لغة الجذر الإنجليزية (ar)

إذا لم يكن لديك وكيل Dialogflow، يمكنك إنشاء وكيل.

Dialogflow ES

لتتمكّن من تفعيل عملية دمج Dialogflow ES، ستحتاج إلى رقم تعريف مشروع وكيل Dialogflow. لتحديد موقع رقم تعريف المشروع،

  1. انتقِل إلى وحدة تحكُّم Dialogflow.
  2. اختَر وكيل Dialogflow الذي تريد ربطه بميزة "الرسائل التجارية". ثم انقر على رمز الترس بجانب اسم الوكيل.
  3. ضمن مشروع Google، دوِّن قيمة رقم تعريف المشروع.

Dialogflow CX

لتفعيل عملية دمج Dialogflow CX، عليك رقم تعريف المشروع لوكيل Dialogflow ورقم تعريف الوكيل لتحديد موقع هذه المعرفات،

  1. انتقِل إلى وحدة تحكُّم Dialogflow CX.
  2. اختيار مشروع Dialogflow
  3. ضمن أداة اختيار الوكيل، انقر على القائمة الكاملة. بجانب وكيل Dialogflow.
  4. انقر على نسخ الاسم. يؤدي هذا إلى نسخ الاسم الكامل لوكيلك في التنسيق التالي: projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID
  5. دوِّن قيم رقم تعريف المشروع ومعرِّفات الوكيل.

إنشاء عملية الدمج

  1. الحصول على عنوان البريد الإلكتروني لحساب خدمة Dialogflow الخاص بالشريك من dialogflowServiceAccountEmail استبدال PARTNER_ID باستخدام رقم تعريف الشريك.

    cURL

    
    # This code gets the partner.
    # Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/partners/get
    
    # Replace the __PARTNER_ID__
    # Make sure a service account key file exists at ./service_account_key.json
    
    curl -X GET \
    "https://businesscommunications.googleapis.com/v1/partners/__PARTNER_ID__" \
    -H "Content-Type: application/json" \
    -H "User-Agent: curl/business-communications" \
    -H "$(oauth2l header --json ./service_account_key.json businesscommunications)"
    

    Node.js

    
    /**
     * This code snippet gets a partner.
     * Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/partners/get
     *
     * This code is based on the https://github.com/google-business-communications/nodejs-businesscommunications Node.js
     * Business Communications client library.
     */
    
    /**
     * Edit the values below:
     */
     const PARTNER_ID = 'EDIT_HERE';
     const PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json';
    
     const businesscommunications = require('businesscommunications');
     const {google} = require('googleapis');
    
     // Initialize the Business Communications API
     const bcApi = new businesscommunications.businesscommunications_v1.Businesscommunications({});
    
     // Set the scope that we need for the Business Communications API
     const scopes = [
       'https://www.googleapis.com/auth/businesscommunications',
     ];
    
     // Set the private key to the service account file
     const privatekey = require(PATH_TO_SERVICE_ACCOUNT_KEY);
    
     async function main() {
       const authClient = await initCredentials();
    
       const partnerName = 'partners/' + PARTNER_ID;
    
       if (authClient) {
         // Setup the parameters for the API call
         const apiParams = {
           auth: authClient,
           name: partnerName,
         };
    
         bcApi.partners.get(apiParams, {}, (err, response) => {
           if (err !== undefined && err !== null) {
             console.dir(err);
           } else {
             // Agent found
             console.log(response.data);
           }
         });
       }
       else {
         console.log('Authentication failure.');
       }
     }
    
     /**
      * Initializes the Google credentials for calling the
      * Business Messages API.
      */
      async function initCredentials() {
       // Configure a JWT auth client
       const authClient = new google.auth.JWT(
         privatekey.client_email,
         null,
         privatekey.private_key,
         scopes,
       );
    
       return new Promise(function(resolve, reject) {
         // Authenticate request
         authClient.authorize(function(err, tokens) {
           if (err) {
             reject(false);
           } else {
             resolve(authClient);
           }
         });
       });
     }
    
     main();
    

    Python

    
    """This code gets a partner.
    
    Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/partners/get
    
    This code is based on the https://github.com/google-business-communications/python-businessmessages
    Python Business Messages client library.
    """
    
    from oauth2client.service_account import ServiceAccountCredentials
    from businesscommunications.businesscommunications_v1_client import BusinesscommunicationsV1
    from businesscommunications.businesscommunications_v1_messages import (
        Agent,
        BusinesscommunicationsPartnersGetRequest,
    )
    
    # Edit the values below:
    PARTNER_ID = 'EDIT_HERE'
    SCOPES = ['https://www.googleapis.com/auth/businesscommunications']
    SERVICE_ACCOUNT_FILE = './service_account_key.json'
    
    credentials = ServiceAccountCredentials.from_json_keyfile_name(
        SERVICE_ACCOUNT_FILE, scopes=SCOPES)
    
    client = BusinesscommunicationsV1(credentials=credentials)
    
    partners_service = BusinesscommunicationsV1.PartnersService(client)
    
    partner_name = 'partners/' + PARTNER_ID
    
    partner = partners_service.Get(BusinesscommunicationsPartnersGetRequest(
            name=partner_name
        ))
    
    print(partner)
    
  2. انسخ عنوان البريد الإلكتروني لحساب الخدمة. يربط هذا الحساب رسائلك التجارية. ووكلاء Dialogflow.

  3. في Google Cloud Console، اختَر مشروع Dialogflow.

  4. انتقِل إلى إدارة الهوية وإمكانية الوصول (IAM) الأذونات.

  5. انقر على إضافة، وأدخِل عنوان البريد الإلكتروني لحساب الخدمة الخاص بالأعضاء الجدد.

  6. من أجل اختيار دور، اختَر محرِّر وكيل وحدة تحكُّم Dialogflow.

  7. انقر على إضافة دور آخر واختَر عميل واجهة برمجة تطبيقات Dialogflow.

  8. انقر على حفظ.

  9. دمج مشروع 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 لفهم والإجابة على أسئلة المستخدمين دون الحاجة إلى كتابة التعليمات البرمجية. لمزيد من المعلومات حول intent، يمكنك الاطّلاع على مستندات Dialogflow ES وDialogflow CX.

اضبط عناصر Dialogflow لكل خيار محادثة تريد تنفيذه. والدعم من خلال التشغيل الآلي. يعتمد موظّفو ميزة "الرسائل التجارية" على Dialogflow فهم رسائل المستخدمين.

عند طلب واجهات برمجة تطبيقات Dialogflow، تمرر "الرسائل التجارية" حمولة رسائل المستخدم لمعرفة نواياك والردّ التلقائي على الإنترنت لتوصيل الطلبات. عند مطابقة رسالة مستخدم بغرض، يمكنك الوصول إلى هذه الحمولة بتنسيق Struct من خلال business_messages_payload داخل QueryParameters.

تحتوي الحمولة على جميع الحقول من رسالة المستخدم باستثناء DialogflowResponse.

بالنسبة إلى Dialogflow CX، تمرِّر ميزة "الرسائل التجارية" أيضًا مَعلمة جلسة تُسمى channel بقيمة google_business_messages إلى أهدافك، ويمكنك الرجوع إليها في وكيلك بالتنسيق التالي: $session.params.channel.

يمكن استخدام هذه المَعلمة لإضافة شروط إلى عمليات تنفيذ Dialogflow من أجل إتاحة قنوات متعدّدة في وكيل Dialogflow نفسه.

لمزيد من المعلومات عن مَعلمات طلب البحث، اطّلِع على مرجعَي Dialogflow ES وDialogflow CX.

المتطلبات الأساسية

عند إنشاء نماذج NLU ضمن Dialogflow، يمكنك ضبط أنواع الردود لهدف ما. تتيح ميزة "الرسائل التجارية" الردّ التلقائي والتي يمكن أن تشمل ما يلي:

  • النص
  • حمولة البيانات المخصّصة
  • تسليم الوكيل المباشر (Dialogflow CX فقط)

يجب أن تتطابق الحمولة المخصّصة مع ردّ صالح على رسالة 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.

بشكل عام، وثائق المعرفة

  • يمكن أن يتضمن محتوى Markdown محدودًا في الإجابات، على النحو المحدّد في حقل العناصر المنسَّقة. النص.
  • يجب ألّا يزيد حجمها عن 50 ميغابايت.
  • يجب ألا يتجاوز عددها 2,000 زوج من الأسئلة والأجوبة.
  • لا تدعم الأسئلة المكررة ذات الأجوبة المختلفة.

بالنسبة لملفات HTML،

  • يجب أن يكون محرّك بحث Google قد زحف إلى الملفات الواردة من عناوين URL العلنية، لكي تكون موجودة في فهرس البحث. يمكنك التحقق من ذلك باستخدام . 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 الملف كسلسلة بترميز base64

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، إذا كانت إحدى الإجابات عن الأسئلة الشائعة بأعلى مستوى ثقة فإن ميزة "الرسائل التجارية" تربط الإجابة برسالة نصية. إذا كان هناك تتوفر إجابة أخرى ذات صلة لكنها مختلفة، تعرض الرسالة رسالة مفادها "عرض إجابة" اقتراحنا. إذا لم يكن كذلك، ستتضمّن الرسالة سؤالاً ومقترحًا. الردود التي تسأل عما إذا كانت الرسالة قد استوفت طلب المستخدم.

الرد التلقائي باستخدام ردّ حسب النية

يمكن أن تتضمن الردود على شكل نية واحدة أو أكثر من الردود التالية.

إذا كانت الاستجابة حسب النية بالشراء ذات أعلى مستوى من الثقة، يتم وصف ما يلي: تنطبق.

  • إذا كان الردّ يحتوي على قيمة نصية واحدة على الأقل، يتم ربط ذلك في ميزة "الرسائل التجارية" في رسالة نصية.
  • في حال كان الردّ يحتوي على حمولة بيانات مخصّصة واحدة على الأقل مع نشاط تجاري صالح بنية كائن JSON لتطبيق "الرسائل"، تنشئ ميزة "الرسائل التجارية" رسالة باستخدام تم تقديم كائن JSON.
  • إذا كان الردّ يتضمّن ردًا واحدًا على الأقل لتسليم أحد موظفي الدعم المباشر، يمكنك الاطّلاع على الردّ التلقائي من خلال طلب موظّف دعم يقدّم خدمة مباشرة.

ولأنّ Dialogflow يمكن أن تتضمن ردودًا متعددة ضمن مطابقة intent واحدة، ترسِل ميزة "الرسائل التجارية" كل عملية تسليم رسائل نصية أو حمولة مخصَّصة أو موظفين مباشرين. الرد كرسالة منفصلة. في حال وجود رسائل متعددة في قصد معيّنة مطابقة، ولكن بعضها مكتوب بشكلٍ غير صحيح، لا ترسل "الرسائل التجارية" سوى معلومات صالحة الرسائل كردود تلقائية.

الرد التلقائي من خلال طلب موظّف دعم يقدّم خدمة مباشرة

يتيح Dialogflow CX إمكانية تسليم الوكيل المباشر. الاستجابة. يشير إلى أنه يجب تسليم المحادثة إلى شخص ويسمح لك بتمرير بيانات وصفية مخصصة لتسليمك الإجراء. إذا كان لاستجابة النية بالشراء ذات أعلى مستوى ثقة تسليمًا لوكيل مباشر، فسترسل ميزة "الرسائل التجارية" حدث طلبه موظّف دعم يقدّم خدمة مباشرة إلى الرد التلقائي على الويب. لمعالجة هذا الحدث، يُرجى الاطّلاع على الانتقال من برنامج التتبُّع إلى موظّف الدعم المباشر

الرد التلقائي باستخدام رسالة احتياطية

في حال لم يحصل Dialogflow على مستوى ثقة عالٍ، يتم إرسال الرسائل التجارية استجابة احتياطية. يتم التعامل مع العناصر الاحتياطية بشكل مختلف في Dialogflow ES Dialogflow CX.

Dialogflow ES

في حال عدم تطابق أي إجابة عن الأسئلة الشائعة حول برامج تتبُّع، ترسل ميزة "الرسائل التجارية" رسالة احتياطية تفيد بأنه لم يتمكن من العثور على إجابة.

بالنسبة إلى الأهداف التي تم ضبطها، إذا لم يكن هناك تطابق مع ردّ حسب النية بالشراء، يتم استخدام "النشاط التجاري" يرسل تطبيق "الرسائل" ردًّا احتياطيًّا للنية. يمكنك استخدام النص الاحتياطي الذي يوفره 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 مع الردود الاحتياطية حسب النية بالشراء. الأحداث المضمَّنة. في حال عدم تطابق ردّ حسب النية، ستُرسِل ميزة "الرسائل التجارية" رسالة احتياطية من الحدث التلقائي "عدم تطابق" في 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

بعد تفعيل عملية دمج 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