OpenAPI と統合コネクタのツール

エージェント アシスト機能は、外部 API やデータソースとともに使用できます。 Google Cloud は、エージェント アシストの統合を容易にする OpenAPI ツールと Integration Connectors ツールを提供します。

OpenAPI ツール

OpenAPI ツールを使用すると、Agent Assist 機能と外部 API を接続できます。この接続により、エージェント アシスト機能は複数のソースから情報を読み取って書き込むことができます。OpenAPI ツールを作成するには、接続する外部 API を記述する OpenAPI スキーマを指定する必要があります。

Integration Connectors ツール

Integration Connectors を使用して、さまざまなデータソースに接続します。 Google Cloud コネクタツールを使用すると、Agent Assist 機能で Integration Connectors を使用してこれらのデータソースの読み取りと書き込みを行うことができます。

始める前に

OpenAPI ツールと Integration Connectors ツールを作成する環境を設定するには、プロジェクト ID とリージョンを入力し、次のコードを実行します。

CLOUDSDK_CORE_PROJECT=YOUR_PROJECT_ID
REGION=YOUR_REGION
API_VERSION=v2beta1
API_ENDPOINT=https://${REGION}-dialogflow.googleapis.com/${API_VERSION}

function gcurl () {
        curl -H "Authorization: Bearer "$(gcloud auth print-access-token) -H "X-Goog-User-Project: ${CLOUDSDK_CORE_PROJECT}" -H "Content-Type: application/json; charset=utf-8" "$@"
}

OpenAPI ツールを作成する

OpenAPI ツールを使用するには、まずツールの作成をリクエストして、ツールリソース名を保存する必要があります。

ステップ 1: ツールの作成をリクエストする

OpenAPI ツールを作成するリクエストを行う手順は次のとおりです。

  1. コードを次のようにカスタマイズします。
    1. 1 つのプロジェクト内で、すべてのツール間で一意の tool_key 値を使用します。
    2. open_api_spec.text_schema フィールドに独自の OpenAPI スキーマを入力します。
  2. 次のカスタマイズされたコードを実行します。

    $ cat > create-tool-request.json << EOF
    {
      "tool_key": "UNIQUE_KEY",
      "description": "TOOL_DESCRIPTION",
      "display_name": "TOOL_DISPLAY_NAME",
      "open_api_spec": {
        "text_schema": "Your-Schema"
      }
    }
    EOF

    $ gcurl -X POST ${API_ENDPOINT}/projects/${CLOUDSDK_CORE_PROJECT}/locations/${REGION}/tools -d @create-tool-request.json | tee create-tool-response.json

成功すると、API は次の例に示すように、リソース名を含む新しく作成されたツールを返します。

{
  "name": "projects/Your-Project-ID/locations/Your-Region/tools/Tool-ID",
  "toolKey": "UNIQUE_KEY",
  "description": "TOOL_DESCRIPTION",
  "createTime": "2025-06-02T18:11:38.999174724Z",
  "updateTime": "2025-06-02T18:11:38.999174724Z",
  "displayName": "TOOL_DISPLAY_NAME",
  "openApiSpec": {
    "textSchema": "Your-Schema"
  }
}

ステップ 2: ツールリソース名を保存する

後で使用するために、ツールリソース名を環境変数に保存します。ツールリソースの環境変数のテンプレートの例を次に示します。

TOOL_RESOURCE=$(cat create-tool-response.json | jq .name | tr -d '"')

OpenAPI ツールを使用した AI コーチ

AI コーチ機能で OpenAPI ツールを使用すると、 Google Cloudの外部から追加情報にアクセスできます。この外部情報は、コンタクト センター エージェントを支援する候補の生成に使用できます。

ステップ 1: ジェネレータを作成する

次の例では、ツールリソース環境変数を使用してジェネレータを作成します。

$ cat > create-generator-request.json << _EOF_
{"agent_coaching_context":{"instructions":[{"agent_action":"help customer by using the tool to find information from library of congress","condition":"The customer asks about library of congress","description":"agent coaching test","display_name":"Search for information"}],"overarching_guidance":"Help customer with questions"},"description":"prober-generate-suggestions-with-agent-coaching-generator","inference_parameter":{"max_output_tokens":256,"temperature":0},"tools":["${TOOL_RESOURCE}"],"trigger_event":"CUSTOMER_MESSAGE"}
_EOF_

$ gcurl -X POST ${API_ENDPOINT}/projects/${CLOUDSDK_CORE_PROJECT}/locations/${REGION}/generators -d @create-generator-request.json | tee create-generator-response.json

_EOF_

$ gcurl -X POST ${API_ENDPOINT}/projects/${CLOUDSDK_CORE_PROJECT}/locations/${REGION}/generators -d @create-generator-request.json | tee create-generator-response.json

AI コーチ ジェネレータの次の例のようなレスポンスが返されます。

{
  "name": "projects/Your-Project-ID/locations/Your-Region/generators/Generator-ID",
  "description": "example-generator",
  "inferenceParameter": {
    "maxOutputTokens": 256,
    "temperature": 0
  },
  "triggerEvent": "CUSTOMER_MESSAGE",
  "createTime": "2025-06-02T18:30:51.021461728Z",
  "updateTime": "2025-06-02T18:30:51.021461728Z",
  "agentCoachingContext": {
    "instructions": [
      {
        "displayName": "Search for information",
        "condition": "The customer asks about library of congress",
        "agentAction": "help customer by using the tool to find information from library of congress"
      }
    ],
    "version": "1.5",
    "overarchingGuidance": "Help customer with questions"
  },
  "tools": [
    "projects/Your-Project-ID/locations/Your-Region/tools/Tool-ID"
  ]
}

ジェネレータ リソース名を保存する

次の例のように、後で使用するために環境変数として保存します。

GENERATOR_RESOURCE=$(cat create-generator-response.json | jq .name | tr -d '"')

ステップ 2: 会話プロファイルを作成する

次のコードを実行して、会話プロファイルを作成します。

$ cat > create-conversation-profile-request.json << _EOF_
{"displayName":"prober-generate-suggestions-with-agent-coaching-generator","humanAgentAssistantConfig":{"humanAgentSuggestionConfig":{"generators":["${GENERATOR_RESOURCE}"]}}}
_EOF_

$ gcurl -X POST ${API_ENDPOINT}/projects/${CLOUDSDK_CORE_PROJECT}/locations/${REGION}/conversationProfiles -d @create-conversation-profile-request.json | tee create-conversation-profile-response.json

次のようなレスポンスが返されます。

{
  "name": "projects/Your-Project-ID/locations/Your-Region/conversationProfiles/Conversation-Profile-ID",
  "displayName": "prober-generate-suggestions-with-agent-coaching-generator",
  "humanAgentAssistantConfig": {
    "humanAgentSuggestionConfig": {
      "generators": [
        "projects/Your-Project-ID/locations/Your-Region/generators/Generator-ID"
      ]
    }
  },
  "languageCode": "en-US",
  "createTime": "2025-06-02T18:40:39.940318Z",
  "updateTime": "2025-06-02T18:40:39.940318Z",
  "projectNumber": "${project_number}"
}

会話プロファイルのリソース名を保存する

この名前を次の例のように環境変数として保存します。

CONVERSATION_PROFILE_RESOURCE=$(cat create-conversation-profile-response.json | jq .name | tr -d '"')

ステップ 3: 会話を作成する

次のコードを実行して、会話を作成します。

$ cat > create-conversation-request.json << _EOF_
{"conversationProfile":"${CONVERSATION_PROFILE_RESOURCE}"}
_EOF_

$ gcurl -X POST ${API_ENDPOINT}/projects/${CLOUDSDK_CORE_PROJECT}/locations/${REGION}/conversations -d @create-conversation-request.json | tee create-conversation-response.json

次のようなレスポンスが返されます。

{
  "name": "projects/Your-Project-ID/locations/Your-Region/conversations/Conversation-ID",
  "lifecycleState": "IN_PROGRESS",
  "conversationProfile": "projects/Your-Project-ID/locations/Your-Region/conversationProfiles/Conversation-Profile-ID",
  "startTime": "2025-06-02T18:43:40.818123Z",
  "conversationStage": "HUMAN_ASSIST_STAGE",
  "source": "ONE_PLATFORM_API",
  "initialConversationProfile": {
    "name": "projects/Your-Project-ID/locations/Your-Region/conversationProfiles/Conversation-Profile-ID",
    "displayName": "prober-generate-suggestions-with-agent-coaching-generator",
    "humanAgentAssistantConfig": {
      "humanAgentSuggestionConfig": {
        "generators": [
          "projects/Your-Project-ID/locations/Your-Region/generators/Generator-ID"
        ]
      }
    },
    "languageCode": "en-US"
  },
  "projectNumber": "${project_number}",
  "initialGeneratorContexts": {
    "projects/Your-Project-ID/locations/Your-Region/generators/Generator-ID": {
      "generatorType": "AGENT_COACHING",
      "generatorVersion": "1.5"
    }
  }
}

会話リソース名を保存する

この名前を環境変数として保存し、後で使用できるようにします。変数は次の形式にする必要があります。

CONVERSATION_RESOURCE=$(cat create-conversation-response.json | jq .name | tr -d '"') 

ステップ 4: エンドユーザーを作成する

次のコードを実行して、エンドユーザーを作成します。

$ cat > create-end-user-request.json << _EOF_
{"role":"END_USER"}
_EOF_

$ gcurl -X POST ${API_ENDPOINT}/${CONVERSATION_RESOURCE}/participants -d @create-end-user-request.json | tee create-end-user-response.json

次のようなレスポンスが返されます。

{
  "name": "projects/Your-Project-ID/locations/Your-Region/conversations/Conversation-ID/participants/End-User-Participant-ID",
  "role": "END_USER"
}

エンドユーザーのリソース名を保存する

エンドユーザーのリソース名を次のように環境変数として保存します。

END_USER_RESOURCE=$(cat create-end-user-response.json | jq .name | tr -d '"')

ステップ 5: 人間のエージェントを作成する

次のコードを実行して、人間のエージェントを作成します。

$ cat > create-human-agent-request.json << _EOF_
{"role":"HUMAN_AGENT"}
_EOF_

$ gcurl -X POST ${API_ENDPOINT}/${CONVERSATION_RESOURCE}/participants -d @create-human-agent-request.json | tee create-human-agent-response.json

次のようなレスポンスが返されます。

{
  "name": "projects/Your-Project-ID/locations/Your-Region/conversations/Conversation-IDHuman-Agent-Participant-ID",
  "role": "HUMAN_AGENT"
}

ヒューマン エージェントのリソース名を保存する

次のように、ヒューマン エージェントのリソース名を環境変数として保存します。

HUMAN_AGENT_RESOURCE=$(cat create-human-agent-response.json | jq .name | tr -d '"')

ステップ 6: AI コーチにテキストを送信する

次のコードを実行して、AnalyzeContent メソッドで AI コーチにテキストを送信します。

cat > analyze-content-1-request.json << _EOF_
{"text_input":{"languageCode":"en-US","text":"Can you search library of congress for the latest trends"}}
_EOF_

gcurl -X POST "${API_ENDPOINT}/${END_USER_RESOURCE}:analyzeContent" -d @analyze-content-1-request.json | tee analyze-content-1-response.json

ステップ 7: ツール呼び出しを検証する

次のコードを実行して、ツール呼び出しを確認します。

cat analyze-content-1-response.json| jq ".humanAgentSuggestionResults[0].generateSuggestionsResponse.generatorSuggestionAnswers[0].generatorSuggestion.toolCallInfo"

次のようなレスポンスが返されます。

[
  {
    "toolCall": {
      "tool": "projects/Your-Project-ID/locations/Your-Region/tools/Tool-ID",
      "action": "search",
      "inputParameters": {
        "q": "latest trends",
        "fo": "json",
        "tool_description": "A generic search endpoint that might be available across various LoC APIs. The structure of the results will vary.\n",
        "at": "trending_content"
      },
      "createTime": "2025-06-02T18:56:53.882479179Z"
    },
    "toolCallResult": {
      "tool": "projects/Your-Project-ID/locations/Your-Region/tools/MjM0NTU3NDk2MTM5NTAwNzQ4OQ",
      "action": "search",
      "content": ""}]}",
      "createTime": "2025-06-02T18:56:54.289367086Z"
    }
  }
]

ステップ 8:(省略可)リソースを削除する

前の手順で作成したリソースを削除するには、次のコードを実行します。

会話プロファイル

gcurl -X DELETE ${API_ENDPOINT}/${CONVERSATION_PROFILE_RESOURCE}

ジェネレータ

gcurl -X DELETE ${API_ENDPOINT}/${GENERATOR_RESOURCE}

OpenAPI ツール

gcurl -X DELETE ${API_ENDPOINT}/${TOOL_RESOURCE}

Integration Connectors ツールを作成する

Integration Connectors は、 Google Cloud コンソールを使用して設定できます。次の手順に沿って、BigQuery コネクタに基づいて Agent Assist Integration Connectors ツールを作成します。

ステップ 1: BigQuery コネクタツールを作成する

Integration Connectors ツールを作成する前に、Google Cloud コンソールに移動して、BigQuery Integration Connectors を作成します。

ステップ 2: Integration Connectors ツールの作成をリクエストする

次のコードを実行して、ツールの作成をリクエストします。connector_spec.name フィールドには、BigQuery コネクタのリソース名を使用します。

cat > create-connector-tool-request.json << _EOF_
{
  "tool_key": "order_tool",
  "description": "order bigquery connector tool",
  "display_name": "order bigquery connector tool",
  "connector_spec": {
    "name": "projects/Your-Project-ID/locations/Your-Region/connections/Your-Connector-ID",
    "actions": [
                             {
                               "entityOperation": {
                                 "entityId": "Orders",
                                 "operation": "LIST"
                               }
                             }, {
                               "entityOperation": {
                                 "entityId": "Orders",
                                 "operation": "GET"
                               }
                             }
                           ]
  }
}
_EOF_


gcurl -X POST ${API_ENDPOINT}/projects/${CLOUDSDK_CORE_PROJECT}/locations/${REGION}/tools -d @create-connector-tool-request.json | tee create-connector-tool-response.json

次のようなレスポンスが返されます。

{
  "name": "projects/Your-Project-ID/locations/Your-Region/tools/Tool-ID",
  "toolKey": "order_tool",
  "description": "order bigquery connector tool",
  "createTime": "2025-06-03T19:29:55.896178942Z",
  "updateTime": "2025-06-03T19:29:55.896178942Z",
  "connectorSpec": {
    "name": "projects/Your-Project-ID/locations/Your-Region/connections/order-bigquery-connector",
    "actions": [
      {
        "entityOperation": {
          "entityId": "Orders",
          "operation": "LIST"
        }
      },
      {
        "entityOperation": {
          "entityId": "Orders",
          "operation": "GET"
        }
      }
    ]
  },
  "displayName": "order bigquery connector tool"
}

次のステップ

Agent Assist がサポートする Integration Connectors ツールの完全なリストについては、Dialogflow Connector ツールのリストをご覧ください。