הוספת אוטומציה באמצעות 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 עם שפת בסיס של אנגלית (en)

אם אין לכם סוכן של 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 במזהה השותף.

    כתובת אתר

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

  6. בשדה Select a role (בחירת תפקיד), בוחרים באפשרות Dialogflow Console Agent Editor (עורך הנציג של Dialogflow Console).

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

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

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

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

    Dialogflow ES

    כתובת אתר

    
    # 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

    כתובת אתר

    
    # 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

כתובת אתר


# 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

כתובת אתר


# 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, תצטרכו למחוק את השילוב עם הפקודה הבאה.

כתובת אתר


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

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

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

Node.js


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

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

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

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

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

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

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

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

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

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

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

 main();

Python


"""This code snippet deletes an integration.

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

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

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

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

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

client = BusinesscommunicationsV1(credentials=credentials)

integrations_service = BusinesscommunicationsV1.BrandsAgentsIntegrationsService(client)

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

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

print(integration)

לגבי אפשרויות עיצוב וערך, אפשר לעיין בIntegration.

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

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

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

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

כתובת אתר


# 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 כדי לקבל מידע על כל השילובים המשויכים לסוכן.

כתובת אתר


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

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

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

Node.js


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

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

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

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

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

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

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

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

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

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

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

 main();

Python


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

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

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

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

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

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

client = BusinesscommunicationsV1(credentials=credentials)

integrations_service = BusinesscommunicationsV1.BrandsAgentsIntegrationsService(client)

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

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

print(integration)

לגבי אפשרויות עיצוב וערך, אפשר לעיין בIntegration.

התאמת Intent

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

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

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

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

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

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

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

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

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

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

מטען ייעודי (payload) בהתאמה אישית חייב להתאים לאובייקט הודעת JSON חוקי ב-Business Messages. במהלך ההגדרה של תגובות ייעודיות למטענים, 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 מוגבל בתשובות, כפי שמצוין בטקסט עשיר.
  • גודל מקסימלי של 50MB.
  • אין לחרוג מ-2000 צמדי שאלות/תשובות.
  • אין תמיכה בשאלות כפולות עם תשובות שונות.

בקובצי HTML,

  • קבצים מכתובות URL ציבוריות צריכים לעבור סריקה על ידי אינדקס החיפוש של Google, כך שיהיו קיימים באינדקס החיפוש. ניתן לבדוק זאת באמצעות Google Search Console. לתשומת ליבכם, האינדקס לא מרענן את התוכן. עליכם לעדכן את המסמך באופן מפורש כאשר התוכן המקורי משתנה.
  • Dialogflow מסיר תגי HTML מהתוכן בעת יצירת תגובות. לכן מומלץ להימנע מתגי HTML ולהשתמש בטקסט פשוט כשהדבר אפשרי.
  • אין תמיכה בקבצים עם צמד אחד של שאלה/תשובה.

בקובצי CSV,

  • הקבצים צריכים לכלול שאלות בעמודה הראשונה ותשובות נוספות בעמודה השנייה, ללא כותרת.
  • קבצים חייבים להשתמש בפסיקים כמפרידים.

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

כדי ליצור בוט של שאלות נפוצות, צריך קודם ליצור מאגר ידע שבו יישמרו כל הנתונים של הבוט, ואז להוסיף מסמך אחד או יותר עם צמדי שאלות/תשובות למאגר הידע.

יצירת בסיס ידע

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

אחרי שיוצרים מאגר ידע, אפשר ליצור בו מסמכים.

כתובת אתר


# 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 הציבורית של המסמך

כתובת אתר


# 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

כתובת אתר


# 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 במחרוזת המתאימה.

כתובת אתר


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

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

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

לגבי אפשרויות עיצוב וערך, אפשר לעיין בDialogflowKnowledgebase.

תשובות אוטומטיות

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

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

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

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

תגובה אוטומטית בתגובת כוונה

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

אם תגובת הכוונה היא ברמת האמינות הגבוהה ביותר, הכללים הבאים יחולו.

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

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

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

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

מענה אוטומטי עם הודעת גיבוי

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

Dialogflow ES

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

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

זוהי דוגמה לתגובה חלופית עם webhook שניתן לקבל:

{
  "intentResponses": [
    {
      "intentName": "projects/df-integration/agent/intents/12345",
      "intentDisplayName": "Default Fallback Intent",
      "intentDetectionConfidence": "1.0",
      "fulfillmentMessages": [
        {
          "text": "One more time?"
        }
      ]
    }
  ]
}

Dialogflow מאכלס את השדות intent_name ו-intent_display_name מראש.

Dialogflow CX

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

זוהי דוגמה לתגובה חלופית עם 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 שלכם יקבל מטען ייעודי (payload) של כל ההודעות מהמשתמשים, בין אם ההודעה ב-Business Messages נשלחה אליכם באופן אוטומטי ובין אם לא. כדי לבדוק אם קיימת תגובה אוטומטית, צריך לבדוק את הערך בשדה autoResponded ולהחליט אם להגיב למשתמש.

Dialogflow ES

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

Dialogflow CX

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