Dodawanie automatyzacji przy użyciu Dialogflow

. . Dialogflow jest narzędzie do tłumaczenia języka (NLU), które przetwarza dane wejściowe użytkownika i odwzorowuje je na znane Twoje zamiary i odpowiednie odpowiedzi. Są 2 wersje. Dialogflow. Dzięki integracji agenta Business Messages z Dialogflow ES możesz łatwo utworzyć prostą automatyzację, aby przyspieszyć rozwój agenta. Według dzięki integracji z Dialogflow CX, możesz tworzyć zaawansowaną automatyzację, do bardziej skomplikowanych rozmów.

Agenty Business Messages obsługują bezpośrednią integrację z

Integracja agenta Business Messages z innymi funkcjami Dialogflow ES lub Dialogflow CX znajdziesz w dokumentacji poszczególnych usług.

Gdy użytkownik wysyła wiadomość do agenta z integracją Dialogflow, Business Messages przekazuje wiadomość użytkownika do Dialogflow i wysyła wiadomości Dialogflow odpowiedź na agenta w wiadomości dialogflowResponse. Agenty można skonfigurować tak, automatycznie wysyłać odpowiedź Dialogflow do użytkownika bez konieczności wykonywania żadnych działań Zobacz Automatyczne odpowiedzi .

Integracja Dialogflow

Zanim zaczniesz korzystać z automatyzacji opartej na Dialogflow w Business Messages, musisz włączyć integrację Dialogflow.

Wymagania wstępne

Aby rozpocząć, musisz mieć

  • aplikacja Business Messages agent
  • agent Dialogflow w regionie Global (Cały świat) z językiem głównym w języku angielskim, (ang.)

Jeśli nie masz agenta Dialogflow, utwórz go.

Dialogflow ES

Aby włączyć integrację Dialogflow ES, musisz mieć Identyfikator projektu agenta Dialogflow. Aby znaleźć identyfikator projektu:

  1. Otwórz konsolę Dialogflow.
  2. Wybierz agenta Dialogflow, którego chcesz połączyć z Business Messages, kliknij ikonę koła zębatego obok nazwy agenta.
  3. W sekcji Google Project (Projekt Google) zwróć uwagę na wartość Identyfikator projektu.

Dialogflow CX

Aby włączyć integrację Dialogflow CX, musisz mieć identyfikator projektu i agenta Dialogflow; Aby je znaleźć,

  1. Otwórz konsolę Dialogflow CX.
  2. Wybierz projekt Dialogflow.
  3. W selektorze agentów kliknij rozszerzone menu obok agenta Dialogflow.
  4. Kliknij Skopiuj nazwę. Imię i nazwisko agenta zostaną skopiowane do pola w tym formacie: projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID
  5. Zapisz wartości identyfikatora projektu i identyfikatora agenta.

Tworzenie integracji

  1. Uzyskaj adres e-mail konta usługi Dialogflow partnera od dialogflowServiceAccountEmail Zastąp PARTNER_ID swoim identyfikatorem partnera.

    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. Skopiuj adres e-mail konta usługi. To konto łączy Business Messages i agenty Dialogflow.

  3. W Google Cloud konsola, wybierz swój projekt Dialogflow.

  4. Otwórz Uprawnienia. .

  5. Kliknij Dodaj i wpisz adres e-mail konta usługi w polu Nowi użytkownicy.

  6. W polu Wybierz rolę wybierz Edytujący agenty konsoli Dialogflow.

  7. Kliknij Dodaj kolejną rolę i wybierz Klient Dialogflow API.

  8. Kliknij Zapisz.

  9. Zintegruj projekt Dialogflow z agentem Business Messages.

    Zastąp AUTO_RESPONSE_STATUS wartością ENABLED lub DISABLED w zależności określania, czy funkcja Business Messages ma automatycznie odpowiadać z odpowiedziami 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)
    

    Informacje o opcjach formatowania i wartości znajdziesz w Integration

Połączenie Business Messages i Dialogflow trwa około 2 minut. Do sprawdzić stan integracji, pobrać OperationInfo

Zaktualizuj integrację

Aby zaktualizować ustawienie automatycznej odpowiedzi agenta, uruchom poniższe polecenie. Zastąp AUTO_RESPONSE_STATUS ustawieniem ENABLED lub WYŁĄCZONA w zależności od tego, czy chcesz, aby funkcja Business Messages była automatycznie uruchamiana odpowiadać użytkownikom za pomocą odpowiedzi 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
}'

Informacje o opcjach formatowania i wartości znajdziesz w Integration

Przełączanie się między wersjami Dialogflow

Agent Business Messages może obsługiwać tylko jedną integrację Dialogflow naraz. Aby przełączyć się z jednej wersji Dialogflow na inną, musisz usunąć przed utworzeniem nowej.

Usuwanie integracji

Jeśli chcesz usunąć Dialogflow z agenta Business Messages, usuń do integracji z tym poleceniem.

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)

Informacje o opcjach formatowania i wartości znajdziesz w Integration

Uzyskaj informacje o integracji

Informacje o integracji można uzyskać na stronie Business Communications API, o ile masz wartość name integracji.

Uzyskaj informacje na temat pojedynczej integracji

Aby uzyskać informacje o integracji, uruchom następujące polecenie.

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)

Informacje o opcjach formatowania i wartości znajdziesz w Integration

Wyświetlanie listy wszystkich integracji dla agenta

Jeśli nie znasz nazwy integracji, możesz uzyskać informacje na temat wszystkich integracje powiązane z agentem przez pominięcie INTEGRATION_ID z adresu URL żądania 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)

Informacje o opcjach formatowania i wartości znajdziesz w Integration

Dopasowywanie intencji

Po włączeniu integracji Dialogflow dla agenta Business Messages może użyć skonfigurowanych intencji w projekcie Dialogflow, aby przeanalizować odpowiadanie na pytania użytkowników bez konieczności pisania kodu. Aby dowiedzieć się więcej o: zapoznaj się z dokumentacją Dialogflow ES. i Dialogflow CX.

Skonfiguruj intencje Dialogflow dla każdej opcji konwersacji, którą chcesz do ich obsługiwania dzięki automatyzacji. Agenty Business Messages używają Dialogflow rozumieją przekaz użytkowników.

Wywołując interfejsy Dialogflow API, Business Messages przekazuje ładunek wiadomości użytkownika do intencji i webhooka realizacji. Gdy wiadomość do użytkownika zostanie dopasowana z intencją, możesz uzyskać dostęp do tego ładunku w formacie Struct w sekcji business_messages_payload w polu QueryParameters.

Ładunek zawiera wszystkie pola z wiadomości użytkownika oprócz pola DialogflowResponse.

W przypadku Dialogflow CX Business Messages przekazuje też parametr sesji o nazwie channel z wartością google_business_messages do intencji i możesz się do niego odwołać w agencie za pomocą tego formatu: $session.params.channel.

Za pomocą tego parametru możesz dodawać warunki do realizacji Dialogflow w celu obsługi wielu kanałów w tym samym agencie Dialogflow.

Więcej informacji o parametrach zapytania znajdziesz w materiałach dotyczących Dialogflow ES i Dialogflow CX.

Wymagania wstępne

Podczas tworzenia modeli NLU w Dialogflow możesz skonfigurować typów odpowiedzi na potrzeby intencji. Business Messages obsługuje odpowiedź domyślną, które mogą obejmować:

  • Tekst
  • Ładunek niestandardowy
  • Przekazywanie na żywo agenta (tylko w Dialogflow CX)

Ładunek niestandardowy musi pasować do prawidłowej odpowiedzi na wiadomość Business Messages w formacie JSON . Gdy konfigurujesz odpowiedzi ładunku niestandardowego dla intencji, Business Messages ignoruje następujące pola:

  • name
  • messageId
  • representative

Poniżej znajdziesz przykładowe odpowiedzi.

Tekst z sugestiami

{
  "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"
      }
    }
  ]
}

Karta informacyjna

{
  "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
            }
          }
        }
      ]
    }
  }
}

Przekazywanie na żywo pracownikowi obsługi klienta

{
  "metadata": {}
}

Boty typu FAQ

Po włączeniu integracji Dialogflow ES dla agenta Business Messages: może utworzyć bota FAQ. Gdy podasz pytania i odpowiedzi jako za pomocą obsługiwanego dokumentu wiedzy, Business Messages i Dialogflow, niezbędną infrastrukturę do rozumienia pytań użytkowników i odpowiadania na nie bez co nie wymaga pisania kodu.

Aby zobaczyć, jak działa bot z najczęstszymi pytaniami, porozmawiaj na czacie z najczęstszymi pytaniami dotyczącymi funkcji Business Messages Bot.

Wymagania wstępne

Zanim utworzysz bota z najczęstszymi pytaniami, musisz mieć dostępne pytania i odpowiedzi dokument wiedzy (maks. 50 MB): dostępny publicznie plik HTML lub CSV.

Ogólnie rzecz biorąc,

  • Może zawierać w odpowiedzi ograniczony tekst Markdown, zgodnie z opisem w sekcji Reklamy z elementami rozszerzonymi tekst.
  • Maksymalny rozmiar to 50 MB.
  • Nie może przekraczać 2000 par pytań i odpowiedzi.
  • Nie pozwalaj na duplikowanie pytań z różnymi odpowiedziami.

W przypadku plików HTML

  • Pliki z publicznych adresów URL muszą zostać zindeksowane przez indeks wyszukiwarki Google dzięki czemu będą one uwzględnione w indeksie wyszukiwania. Możesz to sprawdzić w Google Search Console. Pamiętaj, że narzędzie indeksujące nie dba o aktualność treści. Musisz wyraźnie aktualizowanie dokumentu po zmianie jego treści źródłowej.
  • Podczas tworzenia odpowiedzi Dialogflow usuwa tagi HTML z treści. Ponieważ w tym celu najlepiej unikać tagów HTML i w miarę możliwości używać zwykłego tekstu.
  • Pliki z jedną parą pytania i odpowiedzi nie są obsługiwane.

W przypadku plików CSV

  • Pliki muszą zawierać pytania w pierwszej kolumnie i odpowiedzi w drugiej bez nagłówka.
  • Pliki muszą zawierać przecinki jako separatory.

Utwórz bota z najczęstszymi pytaniami

Aby utworzyć bota najczęściej zadawanych pytań, trzeba najpierw utworzyć bazę wiedzy, w której będą przechowywane bota, a następnie dodaj co najmniej 1 dokument z parami pytań/odpowiedzi bazy wiedzy.

Tworzenie bazy wiedzy

Aby utworzyć bazę wiedzy, uruchom następujące polecenie. Zastąp BRAND_ID, AGENT_ID i INTEGRATION_ID unikalnymi wartościami z name dokumentu. Zastąp KNOWLEDGE_BASE_DISPLAY_NAME z ciągiem identyfikującym Twój wyboru.

Po utworzeniu bazy wiedzy możesz tworzyć dokumenty w dokumencie.

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__"
      }
    ]
  }
}'

Informacje o opcjach formatowania i wartości znajdziesz w DialogflowKnowledgebase

Utwórz dokument wiedzy

Aby utworzyć dokument wiedzy, uruchom następujące polecenie.

Dodaj dokument do listy istniejących dokumentów lub utwórz nową listę, jeśli nie masz żadnej już istnieje. Lista istniejących dokumentów powinna zawierać name dokumentu w żądaniu.

Publiczny plik HTML

Zastąp te zmienne:

  • BRAND_ID, AGENT_ID i INTEGRATION_ID unikalnymi wartościami z name integracji
  • KNOWLEDGE_BASE_DISPLAY_NAME i DOCUMENT_DISPLAY_NAME z identyfikacji wybranych ciągów znaków.
  • PUBLIC_URL z wiedzą publiczny adres URL dokumentu

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__"
          }
        ]
      }
    ]
  }
}'

Lokalny plik CSV

Zastąp te zmienne:

  • BRAND_ID, AGENT_ID i INTEGRATION_ID unikalnymi wartościami z name integracji
  • KNOWLEDGE_BASE_DISPLAY_NAME i DOCUMENT_DISPLAY_NAME z identyfikacji wybranych ciągów znaków.
  • CSV_RAW_BYTES za pomocą pliku CSV jako ciąg zakodowany w formacie 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__"
          }
        ]
      }
    ]
  }
}'

Informacje o opcjach formatowania i wartości znajdziesz w DialogflowKnowledgebase

Dodanie dokumentu do bazy wiedzy trwa około 2 minut. Aby sprawdzić stanu dokumentu, pobierz OperationInfo

Usuwanie dokumentu wiedzy

Jeśli chcesz usunąć pary pytań i odpowiedzi z agenta Business Messages, usuń dokument wiedzy, który go zawiera, za pomocą tego polecenia.

Aby usunąć jeden istniejący dokument, uruchom następujące polecenie. Zastąp BRAND_ID, AGENT_ID i INTEGRATION_ID unikalnymi wartościami z name dokumentu. Zastąp KNOWLEDGE_BASE_DISPLAY_NAME odpowiednim ciągiem.

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__"
      }
    ]
  }
}'

Informacje o opcjach formatowania i wartości znajdziesz w DialogflowKnowledgebase

Automatyczne odpowiedzi

Jeśli podczas integracji Dialogflow włączysz automatyczną odpowiedź, Wiadomości automatycznie odpowiadają użytkownikowi przy użyciu Dialogflow. Twoja firma Agent Wiadomości odpowiada zgodnie z najwyższym poziomem ufności. Dzięki integrację Dialogflow ES, jeśli odpowiedzi zawierają odpowiedzi na najczęstsze pytania oraz niestandardowi odbiorcy o podobnych zamiarach, Business Messages odpowiada dopasowaniem o największym poziom ufności.

Business Messages oznacza wszystkie wiadomości, na które odpowiedziano automatycznie, jako pochodzące z domeny BOT przedstawicielom. Jeśli Twój agent obsługuje agenty działające na żywo, Business Messages zawiesi automatyczne odpowiedzi po REPRESENTATIVE_JOINED wydarzenia i wznawia automatyczne odpowiedzi po REPRESENTATIVE_LEFT zdarzeniach. Zobacz Handoff z bota na agenta.

Automatyczne wysyłanie odpowiedzi na najczęstsze pytania

Dzięki integracji z Dialogflow ES, jeśli odpowiedź na najczęstsze pytania jest najpewniejsza Business Messages przypisze odpowiedź na SMS-a. Jeśli występuje jest powiązana, ale jest inna, ale wyświetla się komunikat „Wyświetl inną odpowiedź”. odpowiedź” sugestii. W przeciwnym razie wiadomość będzie zawierać pytanie i sugerowane odpowiedzi odpowiada na pytanie, czy wiadomość spełniła żądanie użytkownika.

Automatyczna odpowiedź z zamiarem użytkownika

Odpowiedzi dotyczące zamiarów mogą zawierać jedną lub więcej z poniższych odpowiedzi.

Jeśli odpowiedź dotycząca intencji ma najwyższy poziom ufności, następujące warunki: ma zastosowanie.

  • Jeśli odpowiedź zawiera co najmniej 1 wartość tekstową, Business Messages mapuje ją do wiadomości tekstowej.
  • Jeśli odpowiedź zawiera co najmniej jeden ładunek niestandardowy z prawidłową wartością Business Struktura obiektu JSON Wiadomości, Business Messages tworzy wiadomość za pomocą podany obiekt JSON.
  • Jeśli odpowiedź zawiera co najmniej 1 odpowiedź na czacie na żywo z obsługi klienta, zapoznaj się z artykułem Automatyczna odpowiedź na prośbę pracownika obsługi klienta

Dialogflow może zawierać wiele odpowiedzi w ramach 1 dopasowania intencji, Business Messages wysyła każdą wiadomość tekstową, ładunek niestandardowy lub przekazanie na żywo agenta. jako oddzielną wiadomość. Jeśli intencja zawiera wiele wiadomości pasują, ale niektóre z nich mają nieprawidłowy format. Business Messages wysyła tylko prawidłowe jako automatyczne odpowiedzi.

Automatyczna odpowiedź na zaproszenie na żywo od pracownika obsługi klienta

Dialogflow CX obsługuje przekazywanie agenta na żywo. . Jest to sygnał, że rozmowę należy przekazać człowiekowi. i pozwala przekazać niestandardowe metadane . Jeśli odpowiedź dotycząca intencji ma najwyższy poziom ufności i to obejmuje przekazanie na żywo od pracownika obsługi klienta, Business Messages wysyła wydarzenie dla pracownika obsługi klienta transmisji na żywo do webhooka. Aby obsługiwać to zdarzenie, zobacz Przekazywanie z bota do pracownika obsługi klienta.

Automatyczna odpowiedź z komunikatem zastępczym

Jeśli Dialogflow nie uzyska wysokiej ufności, Business Messages wysyła w odpowiedzi kreacji zastępczej. Kreacje zastępcze są obsługiwane inaczej w Dialogflow ES i Dialogflow CX,

Dialogflow ES

Jeśli nie uda się znaleźć odpowiedzi na najczęstsze pytania botów, Business Messages wysyła że nie może znaleźć odpowiedzi.

Jeśli w przypadku skonfigurowanych intencji nie ma dopasowania do odpowiedzi dotyczącej intencji, wartość Business Wiadomości wysyłają odpowiedź intencji zastępczej. Możesz użyć tekstu zastępczego dostarczonego przez Dialogflow lub skonfigurować z dodatkowym tekstem i ładunkami niestandardowymi.

Oto przykładowa odpowiedź intencji zastępczej, którą Twój webhook może otrzymywać:

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

Dialogflow wstępnie wypełnia pola intent_name i intent_display_name.

Dialogflow CX

Dialogflow CX obsługuje odpowiedzi intencji zastępczej jako wbudowanych zdarzeń. Jeśli nie uda się dopasować odpowiedzi do intencji, Business Messages wyśle z domyślnego zdarzenia braku dopasowania w Dialogflow. Dostępne opcje użyj tekstu zastępczego dostarczonego przez Dialogflow lub skonfiguruj kreację zastępczą z dodatkowym tekstem, ładunkami niestandardowymi i opcjami przekazywania na żywo agenta.

Oto przykład odpowiedzi intencji zastępczej, webhook może otrzymywać:

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

Business Messages koduje na stałe intent_name i intent_display_name.

Pola dotyczące Dialogflow

Po włączeniu integracji Dialogflow użytkownik będzie wysyłać wiadomości do agenta otrzymuje zastosuj dialogflowResponse. obiektu. Webhook otrzymuje ładunki dla wszystkich wiadomości użytkownika niezależnie od tego, czy Business Messages automatycznie odpowiedział na wiadomość na Twoim w imieniu Google. Aby sprawdzić automatyczną odpowiedź, sprawdź wartość autoResponded i zdecyduj, czy chcesz odpowiedzieć użytkownikowi.

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",
  }],
},
...
Pole Opis
queryText Oryginalny tekst zapytania konwersacyjnego. Jeśli automatyczna pisownia poprawka jest włączona w modelu Dialogflow, queryText zawiera poprawione dane wejściowe użytkownika.
intentName Unikalny identyfikator dopasowanej intencji.
intentDisplayName Nazwa dopasowanej intencji.
intentDetectionConfidence Liczbowa ocena ufności dopasowania od queryText do intentName.
text Odpowiedź tekstowa.
jsonPayload Odpowiedź z ładunkiem niestandardowym. Ten ciąg jest zgodny z ciągiem niestandardowym ładunek zdefiniowanego w Dialogflow. Jeśli ładunek nie ma prawidłowego pliku JSON Business Messages struktury obiektu, error opisuje problem.
error Opis błędu z komunikatem o zrealizowaniu intencji.
userQuestion Pytanie zadane przez użytkownika przetworzone przez Dialogflow.
faqQuestion Pytanie z Dialogflow zostało dopasowane do pytania użytkownika.
faqAnswer Odpowiedź z Dialogflow pasuje do pytania użytkownika.
matchConfidenceLevel Poziom pewności dopasowania między userQuestion i faqQuestion.
matchConfidence Liczbowa ocena ufności w zakresie dopasowania między userQuestion i faqQuestion.
autoResponded czy Business Messages automatycznie odpowiedział(a) na użytkownik z odpowiedzią z Dialogflow.
message Ładunek automatycznej odpowiedzi.
responseSource Źródło automatycznej odpowiedzi. Zobacz 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",
  }],
},
...
Pole Opis
queryText Oryginalny tekst zapytania konwersacyjnego. Jeśli automatyczna pisownia poprawka jest włączona w modelu Dialogflow, queryText zawiera poprawione dane wejściowe użytkownika.
intentName Unikalny identyfikator dopasowanej intencji.
intentDisplayName Nazwa dopasowanej intencji.
intentDetectionConfidence Liczbowa ocena ufności dopasowania od queryText do intentName.
text Odpowiedź tekstowa.
jsonPayload Odpowiedź z ładunkiem niestandardowym. Ten ciąg jest zgodny z ciągiem niestandardowym ładunek zdefiniowanego w Dialogflow. Jeśli ładunek nie ma prawidłowego pliku JSON Business Messages struktury obiektu, error opisuje problem.
error Opis błędu z komunikatem o zrealizowaniu intencji.
liveAgentHandoff Niestandardowe metadane procedury przekazania klienta na żywo.
autoResponded czy Business Messages automatycznie odpowiedział(a) na użytkownik z odpowiedzią z Dialogflow.
message Ładunek automatycznej odpowiedzi.
responseSource Źródło automatycznej odpowiedzi. Zobacz ResponseSource