הוספת פעולות אוטומטיות באמצעות Dialogflow

Dialogflow הוא תחום טבעי כלי להבנת שפה (NLU) שמעבד קלט של משתמשים, ממפה אותו את הכוונות שלו, ומגיבים בהתאם. קיימות שתי מהדורות של Dialogflow. בעזרת שילוב הנציג של Business Messages עם Dialogflow ES, תוכלו ליצור בקלות אוטומציה פשוטה כדי להתניע את פיתוח הנציגים. על ידי בשילוב עם Dialogflow CX, תוכלו ליצור אוטומציה מתקדמת לשיחות מורכבות.

נציגי Business Messages תומכים בשילובים ישירים עם

איך לשלב נציג של Business Messages עם תכונות אחרות של Dialogflow ES או Dialogflow CX, עיינו במסמכי התיעוד של כל מוצר.

כשמשתמש שולח הודעה לנציג שיש לו שילוב עם Dialogflow, Business Messages מעבירה את ההודעה למשתמש ל-Dialogflow ושולחת את תשובה לנציג בהודעה אובייקט dialogflowResponse. אפשר להגדיר נציגים שליחה אוטומטית של התשובה של Dialogflow למשתמש בלי לבצע פעולה כלשהי חלק. למידע נוסף, ניתן לעיין בקטע תגובות אוטומטיות לקבלת פרטים.

שילוב עם Dialogflow

כדי להשתמש באוטומציה שמבוססת על Dialogflow באמצעות Business Messages, צריך להפעיל את השילוב עם Dialogflow.

דרישות מוקדמות

כדי להתחיל, צריך:

  • Business Messages סוכן
  • נציג של Dialogflow באזור Global עם שפת הבסיס של אנגלית (he)

אם אין לכם סוכן Dialogflow, יוצרים אחד.

Dialogflow ES

כדי להפעיל שילוב של Dialogflow ES, צריך מזהה הפרויקט של הנציג ב-Dialogflow. כדי לאתר את מזהה הפרויקט:

  1. נכנסים אל Dialogflow Console.
  2. בוחרים את הנציג ב-Dialogflow שרוצים לקשר ל-Business Messages. לאחר מכן לוחצים על סמל גלגל השיניים ליד שם הנציג.
  3. בקטע Google Project, מעיינים בערך Project ID.

Dialogflow CX

כדי להפעיל שילוב עם Dialogflow CX, צריך את מזהה הפרויקט ומזהה הנציג ב-Dialogflow. כדי לאתר את המזהים האלה,

  1. נכנסים אל Dialogflow CX Console.
  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. מעתיקים את כתובת האימייל של חשבון השירות. החשבון הזה מחבר את Business Messages וסוכני Dialogflow.

  3. בGoogle Cloud Console, בוחרים את הפרויקט ב-Dialogflow.

  4. כניסה אל IAM הרשאות.

  5. לוחצים על Add (הוספה) ומזינים את כתובת האימייל של חשבון השירות בשביל New members (חברים חדשים).

  6. בקטע Select a role, בוחרים Dialogflow Console Agent Editor.

  7. לוחצים על הוספת תפקיד נוסף ובוחרים באפשרות Dialogflow API Client.

  8. לוחצים על שמירה.

  9. משלבים את הפרויקט ב-Dialogflow עם נציג של Business Messages.

    מחליפים את AUTO_RESPONSE_STATUS בערך 'מופעל' או 'מושבת', בהתאם אם אתם רוצים שאפליקציית Business Messages תגיב באופן אוטומטי משתמשים עם תשובות של Dialogflow.

    Dialogflow ES

    cURL

    
    # This code creates a Dialogflow ES integration.
    # Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#dialogflow_es
    
    # Replace the __BRAND_ID__, __AGENT_ID__, __DIALOGFLOW_ES_PROJECT_ID__ and __AUTO_RESPONSE_STATUS__
    # Make sure a service account key file exists at ./service_account_key.json
    
    curl -X POST \
    "https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__/integrations" \
    -H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \
    -H "Content-Type: application/json"  \
    -H "User-Agent: curl/business-communications" \
    -d '{
       "dialogflowEsIntegration": {
         "dialogflowProjectId": "__DIALOGFLOW_ES_PROJECT_ID__",
         "autoResponseStatus": "__AUTO_RESPONSE_STATUS__"
       }
    }'
    

    Node.js

    
    /**
     * This code snippet creates a Dialogflow ES integration.
     * Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#dialogflow_es
     *
     * This code is based on the https://github.com/google-business-communications/nodejs-businesscommunications Node.js
     * Business Communications client library.
     */
    
    /**
     * Edit the values below:
     */
     const BRAND_ID = 'EDIT_HERE';
     const AGENT_ID = 'EDIT_HERE';
     const DIALOGFLOW_ES_PROJECT_ID = 'EDIT_HERE'
     const PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json';
    
     const businesscommunications = require('businesscommunications');
     const {google} = require('googleapis');
     const uuidv4 = require('uuid').v4;
    
     // Initialize the Business Communications API
     const bcApi = new businesscommunications.businesscommunications_v1.Businesscommunications({});
    
     // Set the scope that we need for the Business Communications API
     const scopes = [
       'https://www.googleapis.com/auth/businesscommunications',
     ];
    
     // Set the private key to the service account file
     const privatekey = require(PATH_TO_SERVICE_ACCOUNT_KEY);
    
     async function main() {
       const authClient = await initCredentials();
       const agentName = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID;
    
       if (authClient) {
         const integrationObject = {
           dialogflowEsIntegration: {
             dialogflowProjectId: DIALOGFLOW_ES_PROJECT_ID,
             autoResponseStatus: 'ENABLED'
           }
         };
    
         // Setup the parameters for the API call
         const apiParams = {
           auth: authClient,
           parent: agentName,
           resource: integrationObject
         };
    
         bcApi.brands.agents.integrations.create(apiParams, {}, (err, response) => {
           if (err !== undefined && err !== null) {
             console.dir(err);
           } else {
             // Agent created
             console.log(response.data);
           }
         });
       }
       else {
         console.log('Authentication failure.');
       }
     }
    
     /**
      * Initializes the Google credentials for calling the
      * Business Messages API.
      */
      async function initCredentials() {
       // Configure a JWT auth client
       const authClient = new google.auth.JWT(
         privatekey.client_email,
         null,
         privatekey.private_key,
         scopes,
       );
    
       return new Promise(function(resolve, reject) {
         // Authenticate request
         authClient.authorize(function(err, tokens) {
           if (err) {
             reject(false);
           } else {
             resolve(authClient);
           }
         });
       });
     }
    
     main();
    

    Python

    
    """This code snippet creates a Dialogflow ES integration.
    
    Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#dialogflow_es
    
    This code is based on the https://github.com/google-business-communications/python-businessmessages
    Python Business Messages client library.
    """
    
    from oauth2client.service_account import ServiceAccountCredentials
    from businesscommunications.businesscommunications_v1_client import BusinesscommunicationsV1
    from businesscommunications.businesscommunications_v1_messages import (
        BusinesscommunicationsBrandsAgentsIntegrationsCreateRequest,
        DialogflowEsIntegration
    )
    
    # Edit the values below:
    BRAND_ID = 'EDIT_HERE'
    AGENT_ID = 'EDIT_HERE'
    DIALOGFLOW_ES_PROJECT_ID = 'EDIT_HERE'
    SCOPES = ['https://www.googleapis.com/auth/businesscommunications']
    SERVICE_ACCOUNT_FILE = './service_account_key.json'
    
    credentials = ServiceAccountCredentials.from_json_keyfile_name(
        SERVICE_ACCOUNT_FILE, scopes=SCOPES)
    
    client = BusinesscommunicationsV1(credentials=credentials)
    
    integrations_service = BusinesscommunicationsV1.BrandsAgentsIntegrationsService(client)
    
    agent_name = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID
    
    integration = integrations_service.Create(BusinesscommunicationsBrandsAgentsIntegrationsCreateRequest(
      integration=DialogflowEsIntegration(
        autoResponseStatus=DialogflowEsIntegration.AutoResponseStatusValueValuesEnum.ENABLED,
        dialogflowProjectId=DIALOGFLOW_ES_PROJECT_ID
      ),
      parent=agent_name
    ))
    
    print(integration)
    

    Dialogflow CX

    cURL

    
    # This code creates a Dialogflow CX integration.
    # Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#dialogflow_cx
    
    # Replace the __BRAND_ID__, __AGENT_ID__, __DIALOGFLOW_CX_PROJECT_ID__, __DIALOGFLOW_CX_AGENT_ID__ and __AUTO_RESPONSE_STATUS__
    # Make sure a service account key file exists at ./service_account_key.json
    
    curl -X POST \
    "https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__/integrations" \
    -H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \
    -H "Content-Type: application/json"  \
    -H "User-Agent: curl/business-communications" \
    -d '{
       "dialogflowCxIntegration": {
         "dialogflowProjectId": "__DIALOGFLOW_CX_PROJECT_ID__",
         "dialogflowAgentId": "__DIALOGFLOW_CX_AGENT_ID__",
         "autoResponseStatus": "__AUTO_RESPONSE_STATUS__"
       }
    }'
    

    Node.js

    
    /**
     * This code snippet creates a Dialogflow CX integration.
     * Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#dialogflow_cx
     *
     * This code is based on the https://github.com/google-business-communications/nodejs-businesscommunications Node.js
     * Business Communications client library.
     */
    
    /**
     * Edit the values below:
     */
    const BRAND_ID = 'EDIT_HERE';
    const AGENT_ID = 'EDIT_HERE';
    const DIALOGFLOW_CX_AGENT_ID = 'EDIT_HERE'
    const DIALOGFLOW_CX_PROJECT_ID = 'EDIT_HERE'
    const PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json';
    
    const businesscommunications = require('businesscommunications');
    const {google} = require('googleapis');
    const uuidv4 = require('uuid').v4;
    
    // Initialize the Business Communications API
    const bcApi = new businesscommunications.businesscommunications_v1.Businesscommunications({});
    
    // Set the scope that we need for the Business Communications API
    const scopes = [
      'https://www.googleapis.com/auth/businesscommunications',
    ];
    
    // Set the private key to the service account file
    const privatekey = require(PATH_TO_SERVICE_ACCOUNT_KEY);
    
    async function main() {
      const authClient = await initCredentials();
      const agentName = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID;
    
      if (authClient) {
        const integrationObject = {
          dialogflowCxIntegration: {
            dialogflowProjectId: DIALOGFLOW_CX_PROJECT_ID,
            dialogflowAgentId: DIALOGFLOW_CX_AGENT_ID,
            autoResponseStatus: 'ENABLED'
          }
        };
    
        // Setup the parameters for the API call
        const apiParams = {
          auth: authClient,
          parent: agentName,
          resource: integrationObject
        };
    
        bcApi.brands.agents.integrations.create(apiParams, {}, (err, response) => {
          if (err !== undefined && err !== null) {
            console.dir(err);
          } else {
            // Agent created
            console.log(response.data);
          }
        });
      }
      else {
        console.log('Authentication failure.');
      }
    }
    
    /**
     * Initializes the Google credentials for calling the
     * Business Messages API.
     */
     async function initCredentials() {
      // Configure a JWT auth client
      const authClient = new google.auth.JWT(
        privatekey.client_email,
        null,
        privatekey.private_key,
        scopes,
      );
    
      return new Promise(function(resolve, reject) {
        // Authenticate request
        authClient.authorize(function(err, tokens) {
          if (err) {
            reject(false);
          } else {
            resolve(authClient);
          }
        });
      });
    }
    
    main();
    

    Python

    
    """This code snippet creates a Dialogflow CX integration.
    
    Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#dialogflow_cx
    
    This code is based on the https://github.com/google-business-communications/python-businessmessages
    Python Business Messages client library.
    """
    
    from oauth2client.service_account import ServiceAccountCredentials
    from businesscommunications.businesscommunications_v1_client import BusinesscommunicationsV1
    from businesscommunications.businesscommunications_v1_messages import (
        BusinesscommunicationsBrandsAgentsIntegrationsCreateRequest,
        DialogflowCxIntegration
    )
    
    # Edit the values below:
    BRAND_ID = 'EDIT_HERE'
    AGENT_ID = 'EDIT_HERE'
    DIALOGFLOW_CX_AGENT_ID = 'EDIT_HERE'
    DIALOGFLOW_CX_PROJECT_ID = 'EDIT_HERE'
    SCOPES = ['https://www.googleapis.com/auth/businesscommunications']
    SERVICE_ACCOUNT_FILE = './service_account_key.json'
    
    credentials = ServiceAccountCredentials.from_json_keyfile_name(
        SERVICE_ACCOUNT_FILE, scopes=SCOPES)
    
    client = BusinesscommunicationsV1(credentials=credentials)
    
    integrations_service = BusinesscommunicationsV1.BrandsAgentsIntegrationsService(client)
    
    agent_name = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID
    
    integration = integrations_service.Create(BusinesscommunicationsBrandsAgentsIntegrationsCreateRequest(
      integration=DialogflowCxIntegration(
        autoResponseStatus=DialogflowCxIntegration.AutoResponseStatusValueValuesEnum.ENABLED,
        dialogflowAgentId=DIALOGFLOW_CX_AGENT_ID,
        dialogflowProjectId=DIALOGFLOW_CX_PROJECT_ID
      ),
      parent=agent_name
    ))
    
    print(integration)
    

    לאפשרויות עיצוב וערך: Integration

תהליך החיבור של Business Messages ל-Dialogflow נמשך כ-2 דקות. שפת תרגום את הסטטוס של השילוב, לקבל את OperationInfo

עדכון השילוב

כדי לעדכן את הגדרות התשובה האוטומטית של הנציג, מריצים את הפקודה הבאה. מחליפים את AUTO_RESPONSE_STATUS ב-מופעל או ההגדרה מושבתת אם רוצים ש-Business Messages יופעל אוטומטית לתת תשובות למשתמשים באמצעות התשובות של Dialogflow.

Dialogflow ES

cURL


# This code updates the Dialogflow association.
# Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/updateDialogflowAssociation

# Replace the __BRAND_ID__ and __AGENT_ID__
# Make sure a service account key file exists at ./service_account_key.json

curl -X PATCH \
"https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__/dialogflowAssociation?updateMask=enableAutoResponse" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-communications" \
-H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \
-d '{
  "enableAutoResponse": true
}'

Dialogflow CX

cURL


# This code updates the Dialogflow association.
# Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/updateDialogflowAssociation

# Replace the __BRAND_ID__ and __AGENT_ID__
# Make sure a service account key file exists at ./service_account_key.json

curl -X PATCH \
"https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__/dialogflowAssociation?updateMask=enableAutoResponse" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-communications" \
-H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \
-d '{
  "enableAutoResponse": true
}'

לאפשרויות עיצוב וערך: Integration

מעבר בין מהדורות של Dialogflow

נציג של Business Messages יכול לתמוך רק בשילוב אחד עם Dialogflow בכל פעם. כדי לעבור ממהדורת Dialogflow אחת לאחרת, צריך להסיר את השילוב הנוכחי לפני יצירת השילוב החדש.

מחיקת השילוב

כדי להסיר את Dialogflow לנציג של Business Messages, צריך למחוק את באמצעות הפקודה הבאה.

cURL


# This code deletes an integration.
# Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#delete_the_integration

# Replace the __BRAND_ID__, __AGENT_ID__ and __INTEGRATION_ID__
# Make sure a service account key file exists at ./service_account_key.json

curl -X DELETE \
"https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__/integrations/__INTEGRATION_ID__" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-communications" \
-H "$(oauth2l header --json ./service_account_key.json businesscommunications)"

Node.js


/**
 * This code snippet deletes an integration.
 * Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#delete_the_integration
 *
 * This code is based on the https://github.com/google-business-communications/nodejs-businesscommunications Node.js
 * Business Communications client library.
 */

/**
 * Edit the values below:
 */
 const BRAND_ID = 'EDIT_HERE';
 const AGENT_ID = 'EDIT_HERE';
 const INTEGRATION_ID = 'EDIT_HERE';
 const PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json';

 const businesscommunications = require('businesscommunications');
 const {google} = require('googleapis');
 const uuidv4 = require('uuid').v4;

 // Initialize the Business Communications API
 const bcApi = new businesscommunications.businesscommunications_v1.Businesscommunications({});

 // Set the scope that we need for the Business Communications API
 const scopes = [
   'https://www.googleapis.com/auth/businesscommunications',
 ];

 // Set the private key to the service account file
 const privatekey = require(PATH_TO_SERVICE_ACCOUNT_KEY);

 async function main() {
   const authClient = await initCredentials();
   const integrationName = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID + '/integrations/' + INTEGRATION_ID;

   if (authClient) {
     // Setup the parameters for the API call
     const apiParams = {
       auth: authClient,
       name: integrationName,
     };

     bcApi.brands.agents.integrations.delete(apiParams, {}, (err, response) => {
       if (err !== undefined && err !== null) {
         console.dir(err);
       } else {
         // Agent created
         console.log(response.data);
       }
     });
   }
   else {
     console.log('Authentication failure.');
   }
 }

 /**
  * Initializes the Google credentials for calling the
  * Business Messages API.
  */
  async function initCredentials() {
   // Configure a JWT auth client
   const authClient = new google.auth.JWT(
     privatekey.client_email,
     null,
     privatekey.private_key,
     scopes,
   );

   return new Promise(function(resolve, reject) {
     // Authenticate request
     authClient.authorize(function(err, tokens) {
       if (err) {
         reject(false);
       } else {
         resolve(authClient);
       }
     });
   });
 }

 main();

Python


"""This code snippet deletes an integration.

Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#delete_the_integration

This code is based on the https://github.com/google-business-communications/python-businessmessages
Python Business Messages client library.
"""

from oauth2client.service_account import ServiceAccountCredentials
from businesscommunications.businesscommunications_v1_client import BusinesscommunicationsV1
from businesscommunications.businesscommunications_v1_messages import (
    BusinesscommunicationsBrandsAgentsIntegrationsDeleteRequest
)

# Edit the values below:
BRAND_ID = 'EDIT_HERE'
AGENT_ID = 'EDIT_HERE'
INTEGRATION_ID = 'EDIT_HERE'
SCOPES = ['https://www.googleapis.com/auth/businesscommunications']
SERVICE_ACCOUNT_FILE = './service_account_key.json'

credentials = ServiceAccountCredentials.from_json_keyfile_name(
    SERVICE_ACCOUNT_FILE, scopes=SCOPES)

client = BusinesscommunicationsV1(credentials=credentials)

integrations_service = BusinesscommunicationsV1.BrandsAgentsIntegrationsService(client)

integration_name = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID + '/integrations/' + INTEGRATION_ID

integration = integrations_service.Delete(BusinesscommunicationsBrandsAgentsIntegrationsDeleteRequest(
  name=integration_name
))

print(integration)

לאפשרויות עיצוב וערך: Integration

קבלת מידע על השילוב

כדי לקבל מידע על שילוב, אפשר להשתמש ב'תקשורת עסקית'. API, כל עוד יש לכם את הערך name של השילוב.

קבלת מידע לגבי שילוב יחיד

כדי לקבל את פרטי השילוב, מריצים את הפקודה הבאה.

cURL


# This code gets information about an integration.
# Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#get_info_for_a_single_integration

# Replace the __BRAND_ID__, __AGENT_ID__ and __INTEGRATION_ID__
# Make sure a service account key file exists at ./service_account_key.json

curl -X GET \
"https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__/integrations/__INTEGRATION_ID__" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-communications" \
-H "$(oauth2l header --json ./service_account_key.json businesscommunications)"

Node.js


/**
 * This code snippet gets information about an integration.
 * Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#get_info_for_a_single_integration
 *
 * This code is based on the https://github.com/google-business-communications/nodejs-businesscommunications Node.js
 * Business Communications client library.
 */

/**
 * Edit the values below:
 */
 const BRAND_ID = 'EDIT_HERE';
 const AGENT_ID = 'EDIT_HERE';
 const INTEGRATION_ID = 'EDIT_HERE';
 const PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json';

 const businesscommunications = require('businesscommunications');
 const {google} = require('googleapis');
 const uuidv4 = require('uuid').v4;

 // Initialize the Business Communications API
 const bcApi = new businesscommunications.businesscommunications_v1.Businesscommunications({});

 // Set the scope that we need for the Business Communications API
 const scopes = [
   'https://www.googleapis.com/auth/businesscommunications',
 ];

 // Set the private key to the service account file
 const privatekey = require(PATH_TO_SERVICE_ACCOUNT_KEY);

 async function main() {
   const authClient = await initCredentials();
   const integrationName = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID + '/integrations/' + INTEGRATION_ID;

   if (authClient) {
     // Setup the parameters for the API call
     const apiParams = {
       auth: authClient,
       name: integrationName,
     };

     bcApi.brands.agents.integrations.get(apiParams, {}, (err, response) => {
       if (err !== undefined && err !== null) {
         console.dir(err);
       } else {
         // Agent created
         console.log(response.data);
       }
     });
   }
   else {
     console.log('Authentication failure.');
   }
 }

 /**
  * Initializes the Google credentials for calling the
  * Business Messages API.
  */
  async function initCredentials() {
   // Configure a JWT auth client
   const authClient = new google.auth.JWT(
     privatekey.client_email,
     null,
     privatekey.private_key,
     scopes,
   );

   return new Promise(function(resolve, reject) {
     // Authenticate request
     authClient.authorize(function(err, tokens) {
       if (err) {
         reject(false);
       } else {
         resolve(authClient);
       }
     });
   });
 }

 main();

Python


"""This code snippet gets information about an integration.

Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#get_info_for_a_single_integration

This code is based on the https://github.com/google-business-communications/python-businessmessages
Python Business Messages client library.
"""

from oauth2client.service_account import ServiceAccountCredentials
from businesscommunications.businesscommunications_v1_client import BusinesscommunicationsV1
from businesscommunications.businesscommunications_v1_messages import (
    BusinesscommunicationsBrandsAgentsIntegrationsDeleteRequest
)

# Edit the values below:
BRAND_ID = 'EDIT_HERE'
AGENT_ID = 'EDIT_HERE'
INTEGRATION_ID = 'EDIT_HERE'
SCOPES = ['https://www.googleapis.com/auth/businesscommunications']
SERVICE_ACCOUNT_FILE = './service_account_key.json'

credentials = ServiceAccountCredentials.from_json_keyfile_name(
    SERVICE_ACCOUNT_FILE, scopes=SCOPES)

client = BusinesscommunicationsV1(credentials=credentials)

integrations_service = BusinesscommunicationsV1.BrandsAgentsIntegrationsService(client)

integration_name = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID + '/integrations/' + INTEGRATION_ID

integration = integrations_service.Get(BusinesscommunicationsBrandsAgentsIntegrationsDeleteRequest(
  name=integration_name
))

print(integration)

לאפשרויות עיצוב וערך: Integration

הצגת רשימה של כל השילובים עם נציג

אם אינך יודע את שם השילוב, תוכל לקבל מידע על כל שילובים שמשויכים לנציג על ידי השמטת INTEGRATION_ID מכתובת URL של בקשת GET.

cURL


# This code lists all integrations for an agent.
# Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#list_all_integrations_for_an_agent

# Replace the __BRAND_ID__ and __AGENT_ID__
# Make sure a service account key file exists at ./service_account_key.json

curl -X GET \
"https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__/integrations" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-communications" \
-H "$(oauth2l header --json ./service_account_key.json businesscommunications)"

Node.js


/**
 * This code snippet lists all integrations for an agent.
 * Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#list_all_integrations_for_an_agent
 *
 * This code is based on the https://github.com/google-business-communications/nodejs-businesscommunications Node.js
 * Business Communications client library.
 */

/**
 * Edit the values below:
 */
 const BRAND_ID = 'EDIT_HERE';
 const AGENT_ID = 'EDIT_HERE';
 const PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json';

 const businesscommunications = require('businesscommunications');
 const {google} = require('googleapis');
 const uuidv4 = require('uuid').v4;

 // Initialize the Business Communications API
 const bcApi = new businesscommunications.businesscommunications_v1.Businesscommunications({});

 // Set the scope that we need for the Business Communications API
 const scopes = [
   'https://www.googleapis.com/auth/businesscommunications',
 ];

 // Set the private key to the service account file
 const privatekey = require(PATH_TO_SERVICE_ACCOUNT_KEY);

 async function main() {
   const authClient = await initCredentials();

   if (authClient) {
     // Setup the parameters for the API call
     const apiParams = {
       auth: authClient,
       parent: 'brands/' + BRAND_ID + '/agents/' + AGENT_ID,
     };

     bcApi.brands.agents.integrations.list(apiParams, {}, (err, response) => {
       if (err !== undefined && err !== null) {
         console.dir(err);
       } else {
         // Agent created
         console.log(response.data);
       }
     });
   }
   else {
     console.log('Authentication failure.');
   }
 }

 /**
  * Initializes the Google credentials for calling the
  * Business Messages API.
  */
  async function initCredentials() {
   // Configure a JWT auth client
   const authClient = new google.auth.JWT(
     privatekey.client_email,
     null,
     privatekey.private_key,
     scopes,
   );

   return new Promise(function(resolve, reject) {
     // Authenticate request
     authClient.authorize(function(err, tokens) {
       if (err) {
         reject(false);
       } else {
         resolve(authClient);
       }
     });
   });
 }

 main();

Python


"""This code snippet lists all integrations for an agent.

Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#list_all_integrations_for_an_agent

This code is based on the https://github.com/google-business-communications/python-businessmessages
Python Business Messages client library.
"""

from oauth2client.service_account import ServiceAccountCredentials
from businesscommunications.businesscommunications_v1_client import BusinesscommunicationsV1
from businesscommunications.businesscommunications_v1_messages import (
    BusinesscommunicationsBrandsAgentsIntegrationsListRequest
)

# Edit the values below:
BRAND_ID = 'EDIT_HERE'
AGENT_ID = 'EDIT_HERE'
SCOPES = ['https://www.googleapis.com/auth/businesscommunications']
SERVICE_ACCOUNT_FILE = './service_account_key.json'

credentials = ServiceAccountCredentials.from_json_keyfile_name(
    SERVICE_ACCOUNT_FILE, scopes=SCOPES)

client = BusinesscommunicationsV1(credentials=credentials)

integrations_service = BusinesscommunicationsV1.BrandsAgentsIntegrationsService(client)

agent_name = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID

integration = integrations_service.List(
  BusinesscommunicationsBrandsAgentsIntegrationsListRequest(parent=agent_name)
)

print(integration)

לאפשרויות עיצוב וערך: Integration

התאמה של כוונת רכישה

אחרי שמפעילים את השילוב של Dialogflow לנציג של Business Messages, נציג יכול להשתמש בכוונות שהוגדרו בפרויקט Dialogflow כדי להבין לענות לשאלות של משתמשים בלי שתצטרכו לכתוב קוד. מידע נוסף על Intents, זמינים במסמכי התיעוד של Dialogflow ES ו-Dialogflow CX.

הגדרת ה-Intents ב-Dialogflow לכל אפשרות שיחה שמתכוונים תמיכה באמצעות אוטומציה. נציגי Business Messages מסתמכים על Dialogflow כדי להבין הודעות למשתמשים.

כשמבצעים קריאה ל-Dialogflow APIs, Business Messages מעבירה את מטען ייעודי של הודעות למשתמשים לכוונות שלכם ול-webhook שלכם למילוי ההזמנות. כשיש התאמה להודעה למשתמש מתוך כוונה, אפשר לגשת למטען הייעודי (Payload) הזה בפורמט Struct שדה business_messages_payload בתוך QueryParameters.

המטען הייעודי (Payload) מכיל את כל השדות מההודעה למשתמש, מלבד שדה DialogflowResponse.

בשביל Dialogflow CX, Business Messages מעבירה גם פרמטר סשן שנקרא channel עם הערך google_business_messages ל-Intent שלכם, ואתם יכולים להפנות אותו לנציג שלכם בפורמט הבא: $session.params.channel.

אפשר להשתמש בפרמטר הזה כדי להוסיף תנאים למילוי ההזמנות של Dialogflow כדי לתמוך בכמה ערוצים באותו סוכן של Dialogflow.

מידע נוסף על פרמטרים של שאילתות זמין בהפניות Dialogflow ES ו-Dialogflow CX.

דרישות מוקדמות

כשיוצרים מודלים של NLU ב-Dialogflow, אפשר להגדיר של כוונת המשתמשים. אפליקציית Business Messages תומכת בתשובת ברירת המחדל, למשל:

  • טקסט
  • מטען ייעודי (payload) בהתאמה אישית
  • העברה של נציג תמיכה אנושי (Dialogflow CX בלבד)

מטען ייעודי (payload) בהתאמה אישית צריך להתאים לתגובה תקינה להודעה בפורמט JSON של Business Messages לאובייקט. כשמגדירים תשובות מטען ייעודי (payload) בהתאמה אישית ל-Intent, Business Messages מתעלם מהשדות הבאים:

  • name
  • messageId
  • representative

ראו את התשובות לדוגמה הבאות.

טקסט עם הצעות

{
  "text": "Hello World!",
  "fallback": "Hello World!\n\nReply with \"Hello\" or \"Hi!\"",
  "suggestions": [
    {
      "reply": {
        "text": "Hello",
        "postbackData": "hello-formal"
      }
    },
    {
      "reply": {
        "text": "Hi!",
        "postbackData": "hello-informal"
      }
    }
  ]
}

צ'אט אינטראקטיבי

{
  "fallback": "Hello, world!\nSent with Business Messages\n\nReply with \"Suggestion #1\" or \"Suggestion #2\"",
  "richCard": {
    "standaloneCard": {
      "cardContent": {
        "title": "Hello, world!",
        "description": "Sent with Business Messages.",
        "media": {
          "height": "TALL",
          "contentInfo":{
            "altText": "Google logo",
            "fileUrl": "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png",
            "forceRefresh": "false"
          }
        },
        "suggestions": [
          {
            "reply": {
              "text": "Suggestion #1",
              "postbackData": "suggestion_1"
            }
          },
          {
            "reply": {
              "text": "Suggestion #2",
              "postbackData": "suggestion_2"
            }
          }
        ]
      }
    }
  }
}
{
  "fallback": "Card #1\nThe description for card #1\n\nCard #2\nThe description for card #2\n\nReply with \"Card #1\" or \"Card #2\"",
  "richCard": {
    "carouselCard": {
      "cardWidth": "MEDIUM",
      "cardContents": [
        {
          "title": "Card #1",
          "description": "The description for card #1",
          "suggestions": [
            {
              "reply": {
                "text": "Card #1",
                "postbackData": "card_1"
              }
            }
          ],
          "media": {
            "height": "MEDIUM",
            "contentInfo": {
              "fileUrl": "https://my.files/cute-dog.jpg",
              "forceRefresh": false
            }
          }
        },
        {
          "title": "Card #2",
          "description": "The description for card #2",
          "suggestions": [
            {
              "reply": {
                "text": "Card #2",
                "postbackData": "card_2"
              }
            }
          ],
          "media": {
            "height": "MEDIUM",
            "contentInfo": {
              "fileUrl": "https://my.files/elephant.jpg",
              "forceRefresh": false
            }
          }
        }
      ]
    }
  }
}

העברה של נציג תמיכה אנושי

{
  "metadata": {}
}

בוטים לשאלות נפוצות

אחרי שמפעילים את השילוב של Dialogflow ES לנציג של Business Messages, אתם יכולים ליצור בוט לשאלות נפוצות. כשמציינים שאלות ותשובות בתור מסמך ידע נתמך, Business Messages ו-Dialogflow יוצרים התשתית הנדרשת כדי להבין שאלות של משתמשים ולהשיב להן, שצריך לכתוב קוד.

כדי לראות איך בוט של שאלות נפוצות פועל, אפשר לשוחח בצ'אט עם שאלות נפוצות בנושא Business Messages בוט.

דרישות מוקדמות

לפני שיוצרים בוט שאלות נפוצות, השאלות והתשובות צריכות להיות זמינות כמו מסמך ידע (עד 50MB): קובץ HTML שזמין באופן ציבורי או קובץ CSV.

באופן כללי, מסמכי ידע

  • יכול לכלול Markdown מוגבל בתשובות, כפי שמצוין בעשירית text.
  • בגודל מקסימלי של 50MB.
  • אסור לחרוג מ-2,000 צמדים של שאלות/תשובות.
  • אין לתמוך בשאלות כפולות עם תשובות שונות.

בקובצי HTML:

  • קבצים מכתובות URL ציבוריות נסרקו על ידי הכלי לאינדקס של חיפוש Google, כדי שהן יופיעו באינדקס החיפוש. אפשר לבדוק את זה בעזרת 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 קובץ כמחרוזת בקידוד 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

מחיקה של מסמך ידע

אם אתם צריכים להסיר צמדים של שאלות/תשובות מהנציג של Business Messages: מוחקים את מסמך הידע שמכיל אותם באמצעות הפקודה הבאה.

מריצים את הפקודה הבאה כדי למחוק מסמך קיים אחד. החלפה BRAND_ID, AGENT_ID וגם INTEGRATION_ID עם הערכים הייחודיים מתוך name של המסמך. החלפה KNOWLEDGE_BASE_DISPLAY_NAME במחרוזת המתאימה.

cURL


# This code deletes a knowledge base document.
# Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#delete_a_knowledge_document

# Replace the __BRAND_ID__, __AGENT_ID__, __INTEGRATION_ID__ and __KNOWLEDGE_BASE_DISPLAY_NAME__
# To delete all knowledge bases, set dialogflowKnowledgeBases to an empty list. Otherwise, the list should contain all existing knowledgebases except the one you would like to remove.
# Make sure a service account key file exists at ./service_account_key.json

curl -X PATCH \
"https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__/integrations/__INTEGRATION_ID__?updateMask=dialogflowEsIntegration.dialogflowKnowledgeBases" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-communications" \
-H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \
-d '{
  "dialogflowEsIntegration": {
    "dialogflowKnowledgeBases": [
      {
        "displayName": "__KNOWLEDGE_BASE_DISPLAY_NAME__"
      }
    ]
  }
}'

לאפשרויות עיצוב וערך: DialogflowKnowledgebase

תגובות אוטומטיות

אם מפעילים תגובה אוטומטית במהלך השילוב עם Dialogflow, אפליקציית Messages מגיבה למשתמש באופן אוטומטי באמצעות Dialogflow. העסק שלך נציג ההודעות משיב בהתאם לרמת הסמך הגבוהה ביותר. עם שילוב של Dialogflow ES, אם יש התאמות גם לתשובה וגם לשאלה בהתאמה אישית עם כוונת רכישה, תקבלו מ-Business Messages את התשובה עם הערך הגבוה ביותר רמת הסמך.

Business Messages מסמנת את כל ההודעות במענה אוטומטי כהודעות שנשלחו מ-BOT לנציגים של העסק. אם הנציג תומך בנציגים אנושיים, התשובות האוטומטיות מושהות אחרי REPRESENTATIVE_JOINED ב-Business Messages אירועים וממשיכים את התשובות האוטומטיות אחרי REPRESENTATIVE_LEFT אירועים. ראו Handoff מבוט לנציג תמיכה אנושי.

תגובה אוטומטית עם תשובה לשאלות נפוצות

בשילוב עם Dialogflow ES, אם התשובה לשאלות הנפוצות היא רמת הסמך הגבוהה ביותר ברמה, Business Messages ממופה את התשובה להודעת טקסט. אם קיימת יש תשובה קשורה אבל שונה, בהודעה יוצג תשובה" הצעה חדשה. אם לא, ההודעה תכלול שאלה והצעות תשובות שואלות אם ההודעה תאמה לבקשה של המשתמש.

תגובה אוטומטית עם תגובת Intent

תגובות של Intent יכולות לכלול אחת או יותר מהתגובות הבאות.

אם לתשובה יש את ההתאמה הגבוהה ביותר ברמת הסמך, במקרים הבאים: חל.

  • אם התשובה כוללת לפחות ערך טקסט אחד, מערכת Business Messages תמפה את המידע הזה להודעת טקסט.
  • אם התשובה כוללת לפחות מטען ייעודי (payload) אחד בהתאמה אישית עם שם עסק תקין מבנה האובייקט של JSON, Business Messages יוצר הודעה באמצעות מספק JSON.
  • אם התשובה כוללת לפחות תגובה אחת להעברה של נציג תמיכה אנושי: תשובה אוטומטית עם בקשה מנציג תמיכה.

מכיוון ש-Dialogflow יכול לכלול כמה תשובות בהתאמה אחת ל-Intent, אפליקציית Business Messages שולחת כל העברה של נציג תמיכה מסוג הודעת טקסט, מטען ייעודי (payload) בהתאמה אישית או העברה של נציג תמיכה בשידור חי. כהודעה נפרדת. אם יש מספר הודעות בכוונת רכישה התאמה, אבל חלקם לא תקינים, התכונה Business Messages שולחת רק הודעות תקינות הודעות כתגובות אוטומטיות.

מענה אוטומטי עם בקשה לנציג תמיכה

Dialogflow CX תומך בהעברה של נציג תמיכה תשובה. הוא מסמן שצריך להעביר את השיחה לאדם פרטי והוא מאפשר לכם להעביר מטא-נתונים בהתאמה אישית לצורך ההעברה התהליך. אם בתגובה לבקשת הסכמה יש את ההתאמה הגבוהה ביותר ברמת הסמך, כולל העברה של נציג תמיכה אנושי, Business Messages שולחת אירוע מבוקש לנציג תמיכה אנושי ל-webhook. כדי לטפל באירוע הזה: מקשר בין בוט לנציג תמיכה אנושי.

תשובה אוטומטית עם הודעה חלופית

אם אפליקציית Dialogflow לא מקבלת התאמה ברמת סמך גבוהה, Business Messages שולחת תשובה חלופית. הטיפול בחלופות ב-Dialogflow ES שונה Dialogflow CX.

Dialogflow ES

לגבי בוטים של שאלות נפוצות, אם לא נמצאה התאמה לתשובה לשאלות נפוצות, Business Messages שולח הודעה חלופית שלא נמצאה לה תשובה.

עבור כוונות מוגדרות, אם אין התאמה לתגובת Intent, העסק אפליקציית Messages שולחת תגובה של Intent חלופי. אפשר להשתמש בטקסט חלופי שסופק על ידי Dialogflow, או להגדיר חלופה עם טקסט נוסף ומטענים ייעודיים (payloads) בהתאמה אישית.

דוגמה לתגובה חלופית מסוג Intent שה-webhook יכול לקבל:

{
  "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 חלופי בתור אירועים מובְנים. אם אין התאמה לתגובה ל-Intent, אפליקציית Business Messages שולחת הודעה חלופית מאירוע ברירת המחדל 'ללא התאמה' ב-Dialogflow. אפשר צריך להשתמש בטקסט החלופי שסופק על ידי Dialogflow, או להגדיר את החלופה עם טקסט נוסף, מטענים ייעודיים (payloads) בהתאמה אישית ואפשרויות להעברת נציגים פעילים.

דוגמה לתגובה חלופית של Intent התגובה לפעולה מאתר אחר (webhook) יכולה לקבל:

{
  "intentResponses": [
    {
      "intentName": "sys.no-match-default",
      "intentDisplayName": "Default Fallback Intent",
      "intentDetectionConfidence": "0.3",
      "fulfillmentMessages": [
        {
          "text": "I missed that, say that again?"
        }
      ]
    }
  ]
}

הקוד של Business Messages הוא intent_name ו-intent_display_name.

שדות ספציפיים ל-Dialogflow

אחרי הפעלת השילוב עם Dialogflow, המשתמש ישלח הודעה לנציג מקבלים כוללים את dialogflowResponse לאובייקט. התגובה לפעולה מאתר אחר (webhook) מקבלת מטענים ייעודיים עבור כל ההודעות למשתמשים, ללא קשר אם התכונה Business Messages השיבה באופן אוטומטי להודעה בדף בשם. כדי לבדוק אם יש תגובה אוטומטית, בודקים את הערך autoResponded ולהחליט אם להגיב למשתמש.

Dialogflow ES

...
"dialogflowResponse": {
  "queryText": "TEXT",
  "intentResponse": {
    "intentName": "INTENT_ID",
    "intentDisplayName": "INTENT_NAME",
    "intentDetectionConfidence": "CONFIDENCE_NUMERIC",
    "fulfillmentMessages": [{
      "text": "FULFILLMENT_TEXT",
      "jsonPayload": "JSON",
      "error": "ERROR_STATUS",
    }],
  "faqResponse": {
    "userQuestion": "USER_QUESTION",
    "answers": [{
      "faqQuestion": "FAQ_QUESTION",
      "faqAnswer": "FAQ_ANSWER",
      "matchConfidenceLevel": "CONFIDENCE_LEVEL",
      "matchConfidence": "CONFIDENCE_NUMERIC",
    }],
  },
  "autoResponded": "BOOLEAN",
  "autoRespondedMessages": [{
    "message": "MESSAGE_JSON",
    "responseSource": "SOURCE",
  }],
},
...
שדה תיאור
queryText הטקסט המקורי של השאילתה בשיחה. אם איות אוטומטי מופעל התיקון למודל Dialogflow, queryText מכיל את הקלט המתוקן של המשתמש.
intentName המזהה הייחודי של ה-Intent התואם.
intentDisplayName השם של ה-Intent התואם.
intentDetectionConfidence דירוג הסמך המספרי בהתאמה בין queryText ל-intentName.
text תשובה בהודעת טקסט.
jsonPayload תגובת מטען ייעודי (payload) בהתאמה אישית. המחרוזת הזו תואמת לערך המותאם אישית המטען הייעודי (payload) שהוגדר ב-Dialogflow. אם למטען הייעודי (Payload) אין קובץ JSON תקין של Business Messages של מבנה האובייקט, error מתאר את הבעיה.
error תיאור של שגיאה עם הודעה של מילוי Intent.
userQuestion השאלה שהמשתמש שאל, כפי שהיא נותחה על ידי Dialogflow.
faqQuestion שאלה מ-Dialogflow תואמת לשאלה של המשתמש.
faqAnswer התשובה מ-Dialogflow תואמים לשאלה של המשתמש.
matchConfidenceLevel רמת הסמך בהתאמה בין userQuestion וגם faqQuestion
matchConfidence דירוג הסמך המספרי בהתאמה בין userQuestion וגם faqQuestion
autoResponded אם ל-Business Messages הייתה תשובה אוטומטית המשתמש עם תשובה מ-Dialogflow.
message המטען הייעודי (payload) של התגובה האוטומטית.
responseSource המקור של התשובה האוטומטית. צפייה ResponseSource

Dialogflow CX

...
"dialogflowResponse": {
  "queryText": "TEXT",
  "intentResponse": {
    "intentName": "INTENT_ID",
    "intentDisplayName": "INTENT_NAME",
    "intentDetectionConfidence": "CONFIDENCE_NUMERIC",
    "fulfillmentMessages": [{
      "text": "FULFILLMENT_TEXT",
      "jsonPayload": "JSON",
      "error": "ERROR_STATUS",
      "liveAgentHandoff": {
        "metadata": {}
      }
    }],
  "autoResponded": "BOOLEAN",
  "autoRespondedMessages": [{
    "message": "MESSAGE_JSON",
    "responseSource": "SOURCE",
  }],
},
...
שדה תיאור
queryText הטקסט המקורי של השאילתה בשיחה. אם איות אוטומטי מופעל התיקון למודל Dialogflow, queryText מכיל את הקלט המתוקן של המשתמש.
intentName המזהה הייחודי של ה-Intent התואם.
intentDisplayName השם של ה-Intent התואם.
intentDetectionConfidence דירוג הסמך המספרי בהתאמה בין queryText ל-intentName.
text תשובה בהודעת טקסט.
jsonPayload תגובת מטען ייעודי (payload) בהתאמה אישית. המחרוזת הזו תואמת לערך המותאם אישית המטען הייעודי (payload) שהוגדר ב-Dialogflow. אם למטען הייעודי (Payload) אין קובץ JSON תקין של Business Messages של מבנה האובייקט, error מתאר את הבעיה.
error תיאור של שגיאה עם הודעה של מילוי Intent.
liveAgentHandoff מטא-נתונים בהתאמה אישית לגבי הליך העברת הנציג החי.
autoResponded אם ל-Business Messages הייתה תשובה אוטומטית המשתמש עם תשובה מ-Dialogflow.
message המטען הייעודי (payload) של התגובה האוטומטית.
responseSource המקור של התשובה האוטומטית. צפייה ResponseSource