Interactions with the API

For each conversational turn, an interaction takes place. During an interaction, an end-user sends input to the agent app and the agent app sends a response. You can use the Vertex AI Agents API to interact with the agent app at runtime.

Before you begin

You should do the following before reading this guide:

  1. Create a new agent app or continue using the agent app you created in Create an agent app.

Collect IDs

The samples below require several IDs as input. To find your project ID, region ID, and app ID:

  1. Go to the Agent Builder console:

    Agent Builder console

  2. Your project ID is shown at the top of the console.

  3. The Location column shows region IDs.

  4. Select an app.

  5. The browser URL path segment after agents/ contains the agent app ID.

You also need a session ID. A session represents a conversation between an agent app and an end-user. You create a unique session ID at the beginning of a conversation and use it for each turn of the conversation. For the purpose of trying the API, you can use any string ID that is at most 36 bytes, like test-session-123.

Call detect intent

The following samples call the Sessions.detectIntent method.

Select a protocol and version for the Session reference:

Protocol V3 V3beta1
REST Session resource Session resource
RPC Session interface Session interface
C++ SessionsClient Not available
C# SessionsClient Not available
Go SessionsClient Not available
Java SessionsClient SessionsClient
Node.js SessionsClient SessionsClient
PHP Not available Not available
Python SessionsClient SessionsClient
Ruby Not available Not available


Before using any of the request data, make the following replacements:

  • PROJECT_ID: your Google Cloud project ID
  • AGENT_ID: your playbook agent ID, which corresponds to the Dialogflow agent ID
  • REGION_ID: your region ID
  • SUBDOMAIN_REGION: if your region ID is us, the subdomain region is usa, otherwise the subdomain region is the same as the region ID
  • SESSION_ID: your session ID
  • END_USER_INPUT: the end-user input, for example: I want to buy a shirt

HTTP method and URL:


Request JSON body:

  "queryInput": {
    "text": {
      "text": "END_USER_INPUT"
    "languageCode": "en"
  "queryParams": {
    "timeZone": "America/Los_Angeles"

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

  "responseId": "a6cd27b0-5eaa-4f93-aa6e-11faf97dbb63",
  "queryResult": {
    "text": "I want to buy a shirt",
    "languageCode": "en",
    "responseMessages": [
        "text": {
          "text": [
            "Great! I can help you with that. We have a wide variety of shirts to choose from. What size and color would you like?"
    "intentDetectionConfidence": 1,
    "diagnosticInfo": {
      "Session Id": "123",
      "Response Id": "a6cd27b0-5eaa-4f93-aa6e-11faf97dbb63"
    "match": {
      "confidence": 1
    "advancedSettings": {
      "loggingSettings": {}
  "responseType": "FINAL"