Dialogflow で自動化を追加する

<ph type="x-smartling-placeholder">で確認できます。 <ph type="x-smartling-placeholder">で確認できます。 Dialogflow は、 ユーザー入力を処理し、既知のエンティティにマッピングする言語理解(NLU)ツール 適切な応答を返します。2 つのエディション 説明します。ビジネス メッセージ エージェントを Dialogflow ES と統合すると、 シンプルな自動化を簡単に作成してエージェントの開発を 促進できます方法 Dialogflow CX とのインテグレーションにより、 会話の複雑さを軽減します。

ビジネス メッセージ エージェントは、

ビジネス メッセージ エージェントを Dialogflow の他の機能と統合する ES または Dialogflow CX、 各プロダクトのドキュメントをご覧ください

Dialogflow と統合されているエージェントにユーザーがメッセージを送信すると、 ビジネス メッセージは Dialogflow にユーザー メッセージを渡し、Dialogflow の メッセージでエージェントへのレスポンスが dialogflowResponse オブジェクト。エージェントを構成して ユーザー操作なしで Dialogflow のレスポンスを自動送信 なります。自動返信をご覧ください。 をご覧ください。

Dialogflow の統合

Dialogflow ベースの自動化をビジネス メッセージで利用する前に、 Dialogflow インテグレーションを有効にする必要があります。

前提条件

利用を開始するには、以下が必要です。

  • ビジネス メッセージ エージェント
  • Global リージョンにあり、ルート言語が英語の Dialogflow エージェント (英語)

Dialogflow エージェントがない場合は作成します

Dialogflow ES

Dialogflow ES の統合を有効にするには、以下が必要です。 Dialogflow エージェントのプロジェクト ID。プロジェクト ID を確認するには、

  1. Dialogflow コンソールに移動します。
  2. ビジネス メッセージに接続する Dialogflow エージェントを選択します。 歯車アイコンをクリックして エージェント名の横が表示されます。
  3. [Google Project] の [Project ID] の値をメモします。

Dialogflow CX

Dialogflow CX の統合を有効にするには、以下が必要です。 Dialogflow エージェントのプロジェクト ID とエージェント ID。これらの ID を見つけるには

  1. Dialogflow CX コンソールに移動します。
  2. Dialogflow プロジェクトを選択します。
  3. エージェント セレクタで、オーバーフロー メニューをクリックします。 Dialogflow エージェントの横にあります。
  4. [名前をコピー] をクリックします。これにより、エージェントの名前が 次の形式にします。 projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID
  5. プロジェクト ID とエージェント ID の値をメモします。

統合を作成する

  1. パートナーの Dialogflow サービス アカウントのメールアドレスを dialogflowServiceAccountEmail。置換 PARTNER_ID は、パートナー ID に置き換えます。

    cURL

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

    Node.js

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

    Python

    
    """This code gets a partner.
    
    Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/partners/get
    
    This code is based on the https://github.com/google-business-communications/python-businessmessages
    Python Business Messages client library.
    """
    
    from oauth2client.service_account import ServiceAccountCredentials
    from businesscommunications.businesscommunications_v1_client import BusinesscommunicationsV1
    from businesscommunications.businesscommunications_v1_messages import (
        Agent,
        BusinesscommunicationsPartnersGetRequest,
    )
    
    # Edit the values below:
    PARTNER_ID = 'EDIT_HERE'
    SCOPES = ['https://www.googleapis.com/auth/businesscommunications']
    SERVICE_ACCOUNT_FILE = './service_account_key.json'
    
    credentials = ServiceAccountCredentials.from_json_keyfile_name(
        SERVICE_ACCOUNT_FILE, scopes=SCOPES)
    
    client = BusinesscommunicationsV1(credentials=credentials)
    
    partners_service = BusinesscommunicationsV1.PartnersService(client)
    
    partner_name = 'partners/' + PARTNER_ID
    
    partner = partners_service.Get(BusinesscommunicationsPartnersGetRequest(
            name=partner_name
        ))
    
    print(partner)
    
  2. サービス アカウントのメールアドレスをコピーします。このアカウントはビジネス メッセージを接続します Dialogflow エージェントもサポートしています

  3. Google Cloud コンソール Dialogflow プロジェクトを選択します。

  4. [IAM] に移動します。 権限

  5. [追加] をクリックし、[新しいメンバー] のサービス アカウントのメールアドレスを入力します。

  6. [ロールを選択] で、[Dialogflow コンソール エージェント編集者] を選択します。

  7. [別のロールを追加] をクリックし、[Dialogflow API クライアント] を選択します。

  8. [保存] をクリックします。

  9. Dialogflow プロジェクトをビジネス メッセージ エージェントと統合します。

    AUTO_RESPONSE_STATUS は、状況に応じて ENABLED または DISABLED に置き換えます。 メッセージに自動返信するかどうかを Dialogflow のレスポンスを返します。

    Dialogflow ES

    cURL

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

    Node.js

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

    Python

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

    Dialogflow CX

    cURL

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

    Node.js

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

    Python

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

    書式設定と値のオプションについては、以下をご覧ください。 Integration

ビジネス メッセージと Dialogflow の接続には 2 分ほどかかります。宛先 統合のステータスの確認、統合の OperationInfo

統合を更新する

エージェントの自動レスポンス設定を更新するには、次のコマンドを実行します。 AUTO_RESPONSE_STATUS を ENABLED に置き換えるか、 DISABLED(ビジネス メッセージを自動的に使用するかどうかによる) Dialogflow レスポンスでユーザーに応答します。

Dialogflow ES

cURL


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

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

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

Dialogflow CX

cURL


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

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

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

書式設定と値のオプションについては、以下をご覧ください。 Integration

Dialogflow のエディションを切り替える

1 つのビジネス メッセージ エージェントは、一度に 1 つの Dialogflow インテグレーションのみをサポートできます。 Dialogflow のエディションを切り替えるには、 現在の統合を確認してから、新しい統合を作成します。

統合を削除する

ビジネス メッセージ エージェントから Dialogflow を削除する必要がある場合は、 次のコマンドと統合します。

cURL


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

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

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

Node.js


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

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

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

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

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

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

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

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

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

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

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

 main();

Python


"""This code snippet deletes an integration.

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

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

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

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

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

client = BusinesscommunicationsV1(credentials=credentials)

integrations_service = BusinesscommunicationsV1.BrandsAgentsIntegrationsService(client)

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

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

print(integration)

書式設定と値のオプションについては、以下をご覧ください。 Integration

統合情報を取得する

統合に関する情報は、Business Communications (統合の name 値がある限り)。

単一の統合に関する情報を取得する

統合情報を取得するには、次のコマンドを実行します。

cURL


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

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

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

Node.js


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

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

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

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

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

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

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

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

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

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

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

 main();

Python


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

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

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

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

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

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

client = BusinesscommunicationsV1(credentials=credentials)

integrations_service = BusinesscommunicationsV1.BrandsAgentsIntegrationsService(client)

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

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

print(integration)

書式設定と値のオプションについては、以下をご覧ください。 Integration

エージェントのすべての統合を一覧表示する

統合の名前がわからない場合は、すべての情報を確認できます。 エージェントに関連付けられた統合(INTEGRATION_ID を省略) 値を取得します。

cURL


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

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

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

Node.js


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

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

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

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

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

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

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

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

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

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

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

 main();

Python


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

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

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

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

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

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

client = BusinesscommunicationsV1(credentials=credentials)

integrations_service = BusinesscommunicationsV1.BrandsAgentsIntegrationsService(client)

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

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

print(integration)

書式設定と値のオプションについては、以下をご覧ください。 Integration

インテント マッチング

ビジネス メッセージ エージェントの Dialogflow インテグレーションを有効にすると、 エージェントは、Dialogflow プロジェクトで構成されたインテントを使用して、 ユーザーの質問に対応できます。コードを記述する必要はありません。詳細情報 Dialogflow ES のドキュメントをご覧ください。 Dialogflow CX

使用するすべての会話オプションに対して Dialogflow インテントを構成します。 自動化によってサポートを提供しますビジネス メッセージ エージェントは Dialogflow を利用して 理解するのに役立ちます。

Dialogflow API を呼び出すと、ビジネス メッセージは ユーザー メッセージ ペイロード フルフィルメント Webhook を作成します。ユーザー メッセージが一致する場合 このペイロードには、次のように Struct 形式でアクセスできます。 QueryParameters 内の business_messages_payload フィールド。

ペイロードには、ユーザー メッセージのすべてのフィールド(DialogflowResponse を除く)が含まれます。

Dialogflow CX の場合、ビジネス メッセージは、値が google_business_messageschannel というセッション パラメータもインテントに渡します。このセッション パラメータは、$session.params.channel の形式でエージェントで参照できます。

このパラメータを使用すると、同じ Dialogflow エージェントで複数のチャネルをサポートするため、Dialogflow フルフィルメント条件を追加できます。

クエリ パラメータの詳細については、Dialogflow ESDialogflow CX のリファレンスをご覧ください。

前提条件

Dialogflow で NLU モデルを作成する際は、さまざまな構成で 指定することもできます。ビジネス メッセージはデフォルトの返信メッセージ、 これには次のものが含まれます

  • テキスト
  • カスタム ペイロード
  • ライブ対応のエージェントへのハンドオフ(Dialogflow CX のみ)

カスタム ペイロードは、有効なビジネス メッセージの JSON メッセージ レスポンスと一致する必要があります。 オブジェクトです。 インテントに対してカスタム ペイロード レスポンスを構成する場合、ビジネス メッセージ 次のフィールドは無視されます。

  • name
  • messageId
  • representative

次のサンプル レスポンスをご覧ください。

候補が表示されたテキスト

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

リッチカード

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

ライブ対応のエージェントへのハンドオフ

{
  "metadata": {}
}

FAQ bot

ビジネス メッセージ エージェントに対して Dialogflow ES の統合を有効にすると、次の処理が行われます。 FAQ bot を作成できます。質問と回答を Google Cloud の ビジネス メッセージと Dialogflow によって、 ユーザーの質問を理解して回答するための必要なインフラストラクチャを、 記述できます。

FAQ bot の動作を確認するには、ビジネス メッセージに関するよくある質問とチャットします bot です。

前提条件

FAQ bot を作成する前に、質問と回答を ナレッジ ドキュメント(最大 50 MB): 一般公開されている HTML ファイルまたは CSV ファイル。

一般的にナレッジドキュメントは

HTML ファイルの場合、

  • 公開 URL のファイルは、Google 検索インデクサによってクロールされている必要があります。 検索インデックスに存在するようにします。詳しくは、Google Search Console をご覧ください。 インデクサはコンテンツを最新の状態に維持しません。各 Pod の IP アドレスを ソース コンテンツが変更されたときにドキュメントを更新します。
  • Dialogflow はレスポンスの作成時にコンテンツから HTML タグを削除します。なぜなら、 可能な限り HTML タグを避け、書式なしテキストを使用することをおすすめします。
  • 質問と回答のペアが 1 つのファイルはサポートされていません。

CSV ファイルの場合

  • ファイルの 1 列目に質問、2 列目に回答を含める必要があります。 ヘッダーなし。
  • ファイルでは区切り文字としてカンマを使用する必要があります。

FAQ bot を作成する

FAQ bot を作成するには、まずナレッジベースを作成して、 追加し、質問と回答のペアを含む 1 つ以上のドキュメントを 説明します。

ナレッジベースを作成する

ナレッジベースを作成するには、次のコマンドを実行します。置換 BRAND_ID さん、AGENT_ID さん、INTEGRATION_ID さん ドキュメントの name の一意の値に置き換えます。置換 KNOWLEDGE_BASE_DISPLAY_NAME は、サービスを識別する文字列に置き換えます。 あります。

ナレッジベースを作成したら、ドキュメントを作成できます。 あります。

cURL


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

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

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

書式設定と値のオプションについては、以下をご覧ください。 DialogflowKnowledgebase

ナレッジ ドキュメントを作成する

ナレッジ ドキュメントを作成するには、次のコマンドを実行します。

ドキュメントを既存のドキュメントのリストに追加するか、存在しない場合は新しいリストを作成します まだ存在します。既存のドキュメントのリストには、ドキュメントの name を含める必要があります。 値が返されます。

公開 HTML ファイル

次の変数を置き換えます。

  • BRAND_ID さん、AGENT_ID さん、INTEGRATION_ID さん 統合の name から一意の値で
  • KNOWLEDGE_BASE_DISPLAY_NAMEDOCUMENT_DISPLAY_NAME と 任意の文字列を識別できる
  • 知識を持ったPUBLIC_URL ドキュメントの公開 URL

cURL


# This code creates a knowledge base document from an HTML document and adds it to the knowledge base.
# Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#create-document

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

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

ローカル CSV ファイル

次の変数を置き換えます。

  • BRAND_ID さん、AGENT_ID さん、INTEGRATION_ID さん 統合の name から一意の値で
  • KNOWLEDGE_BASE_DISPLAY_NAMEDOCUMENT_DISPLAY_NAME と 任意の文字列を識別できる
  • CSV_RAW_BYTES は、CSV に置き換えます。 エンコードした文字列として

cURL


# This code creates a knowledge base document from a CSV document and adds it to the knowledge base.
# Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/integrate/dialogflow?method=api#create-document

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

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

書式設定と値のオプションについては、以下をご覧ください。 DialogflowKnowledgebase

ナレッジベースにドキュメントを追加するには 2 分ほどかかります。確認するには、 ステータスを確認するには、統合の OperationInfo

ナレッジ ドキュメントを削除する

ビジネス メッセージ エージェントから質問と回答のペアを削除する必要がある場合は、 そのドキュメントを含むナレッジ ドキュメントを次のコマンドで削除します。

次のコマンドを実行して、既存のドキュメントを 1 つ削除します。置換 BRAND_ID さん、AGENT_ID さん、INTEGRATION_ID さん ドキュメントの name の一意の値に置き換えます。置換 KNOWLEDGE_BASE_DISPLAY_NAME は適切な文字列に置き換えます。

cURL


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

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

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

書式設定と値のオプションについては、以下をご覧ください。 DialogflowKnowledgebase

自動返信

Dialogflow の統合中に自動応答を有効にすると、Business メッセージは Dialogflow を介してユーザーに自動的に応答します。あなたのビジネス メッセージ エージェントは、最も高い信頼度の一致で応答します。 Dialogflow ES との統合(よくある質問の回答と ビジネス メッセージは、一致率が最も高いインテントを できます。

ビジネス メッセージでは、すべての自動返信メッセージが BOT から送信されたものとしてマークされます エージェントが人間のエージェントをサポートしている場合は、 REPRESENTATIVE_JOINEDを過ぎるとビジネス メッセージの自動返信は停止されます イベント REPRESENTATIVE_LEFT イベント後に自動応答を再開します。ハンドオフを参照 bot から人間のエージェントへ

よくある質問の回答で自動返信

Dialogflow ES との統合により、よくある質問の回答の信頼度が最も高い場合 ビジネス メッセージによって、その回答がテキスト メッセージにマッピングされます。もし 関連性があるが別の回答がある場合、メッセージには [別の回答を表示] と 応答」表示されます。含まれていない場合は、質問と提案がメッセージに メッセージがユーザーの要求を満たしているかどうかを尋ねる返信

インテント レスポンスによる自動応答

インテント レスポンスには、以下のレスポンスを 1 つ以上含めることができます。

インテント レスポンスの信頼度が最も高い場合、 適用されます。

  • 返信に 1 つ以上のテキスト値が含まれている場合、ビジネス メッセージによってこの値がマッピングされます。 値をテキスト メッセージに変換します。
  • レスポンスに、有効な Business API を含むカスタム ペイロードが 1 つ以上 Messages JSON オブジェクト構造です。ビジネス メッセージでは、 JSON オブジェクトを返すことができます
  • 回答に Live Agent の引き継ぎの応答が 1 つ以上ある場合は、以下をご覧ください。 ライブ対応のエージェント リクエストに自動応答します。

Dialogflow では 1 つのインテント マッチに複数のレスポンスが含まれることがあるため、 ビジネス メッセージは、テキスト、カスタム ペイロード、またはライブ対応のエージェントへの引き継ぎをそれぞれ送信 個別のメッセージとして表示できますインテントに複数のメッセージがある場合 一部のメールアドレスの形式が正しくない場合、ビジネス メッセージは有効な 自動返信として送信されます。

ライブ対応のエージェント リクエストに自動応答

Dialogflow CX はライブ エージェントのハンドオフをサポート レスポンスが返されます。会話を人間に引き継ぐ必要があるというシグナル カスタム メタデータを渡してハンドオフできます。 示されます。インテント レスポンスの信頼度が最も高い一致があり、かつ 人間のエージェントへの引き継ぎを含む場合、ビジネス メッセージでは ライブ対応のエージェントからリクエストされたイベント Webhook に追加します。このイベントを処理する方法については、以下をご覧ください。 bot から人間のエージェントへの引き継ぎ

代替メッセージで自動応答

Dialogflow が信頼度の高い一致を得られなかった場合、ビジネス メッセージは フォールバック レスポンスを作成します。フォールバックの処理は Dialogflow ES では異なり、 Dialogflow CX

Dialogflow ES

FAQ bot の場合、一致する質問の回答がない場合、ビジネス メッセージから 回答が見つからなかったというフォールバック メッセージが表示されます。

構成済みのインテントで、一致するインテントのレスポンスがない場合、Business メッセージは、フォールバック インテント レスポンスを送信します。 Dialogflow が提供するフォールバック テキストを使用するか、 追加のテキストとカスタム ペイロードでフォールバックできます。

これは、Webhook によって返されるフォールバック インテント レスポンスの例です。 は以下を受信できます。

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

Dialogflow によって intent_nameintent_display_name が事前入力されます。

Dialogflow CX

Dialogflow CX はフォールバック インテント レスポンスを次のように処理します。 組み込みのイベント。 一致するインテントの応答がない場合、ビジネス メッセージは Dialogflow の No-match デフォルト イベントからのフォールバック メッセージ。Google Chat では Dialogflow から提供されるフォールバック テキストを使用するか、フォールバックを構成します。 追加のテキスト、カスタム ペイロード、ライブ対応エージェントのハンドオフ オプションを利用できます。

この例は、バックエンド ユーザーの Webhook は以下を受信できます。

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

ビジネス メッセージで intent_nameintent_display_name をハードコードする。

Dialogflow 固有のフィールド

Dialogflow とのインテグレーションを有効にすると、ユーザーはエージェントにメッセージを送信します。 受信する 次を含める: dialogflowResponse 渡されます。Webhook は、指定したユーザー メッセージとは関係なく、すべてのユーザー メッセージのペイロードを受信します。 メッセージにビジネス メッセージが自動的に返信したかどうかを できます。自動応答があるかどうかを確認するには、 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 一致における信頼度評価(数値) queryTextintentName
text テキスト レスポンス。
jsonPayload カスタム ペイロード レスポンス。 この文字列はカスタム URL に一致する ペイロードが使用されます。 ペイロードに有効なビジネス メッセージ JSON がない場合 オブジェクト構造。error は問題を表します。
error インテント フルフィルメント メッセージを含むエラーの説明。
userQuestion Dialogflow で解析された、ユーザーが尋ねた質問。
faqQuestion ユーザーの質問と対応した Dialogflow からの質問。
faqAnswer Dialogflow からの回答がユーザーの質問と一致しました。
matchConfidenceLevel 両方の単語との一致の信頼度 userQuestionfaqQuestion
matchConfidence 次の範囲の一致の信頼度評価を表す数値 userQuestionfaqQuestion
autoResponded ビジネス メッセージに自動返信するかどうか Dialogflow から回答を返します。
message 自動レスポンスのペイロード。
responseSource 自動応答のソース。詳しくは、 ResponseSource

Dialogflow CX

...
"dialogflowResponse": {
  "queryText": "TEXT",
  "intentResponse": {
    "intentName": "INTENT_ID",
    "intentDisplayName": "INTENT_NAME",
    "intentDetectionConfidence": "CONFIDENCE_NUMERIC",
    "fulfillmentMessages": [{
      "text": "FULFILLMENT_TEXT",
      "jsonPayload": "JSON",
      "error": "ERROR_STATUS",
      "liveAgentHandoff": {
        "metadata": {}
      }
    }],
  "autoResponded": "BOOLEAN",
  "autoRespondedMessages": [{
    "message": "MESSAGE_JSON",
    "responseSource": "SOURCE",
  }],
},
...
フィールド 説明
queryText 元の会話型クエリテキスト。自動スペルの場合 Dialogflow モデル queryText で修正が有効になっています 修正されたユーザー入力が含まれています。
intentName 一致したインテントの一意の識別子。
intentDisplayName 一致したインテントの名前。
intentDetectionConfidence 一致における信頼度評価(数値) queryTextintentName
text テキスト レスポンス。
jsonPayload カスタム ペイロード レスポンス。 この文字列はカスタム URL に一致する ペイロードが使用されます。 ペイロードに有効なビジネス メッセージ JSON がない場合 オブジェクト構造。error は問題を表します。
error インテント フルフィルメント メッセージを含むエラーの説明。
liveAgentHandoff ライブ対応のエージェントのハンドオフ手順に関するカスタム メタデータ。
autoResponded ビジネス メッセージに自動返信するかどうか Dialogflow から回答を返します。
message 自動レスポンスのペイロード。
responseSource 自動応答のソース。詳しくは、 ResponseSource