Gemini Enterprise for Customer Experience API . projects . locations . apps . sessions

Instance Methods

close()

Close httplib2 connections.

generateChatToken(name, body=None, x__xgafv=None)

Generates a session scoped token for chat widget to authenticate with Session APIs.

runSession(session, body=None, x__xgafv=None)

Initiates a single turn interaction with the CES agent within a session.

Method Details

close()
Close httplib2 connections.
generateChatToken(name, body=None, x__xgafv=None)
Generates a session scoped token for chat widget to authenticate with Session APIs.

Args:
  name: string, Required. The session name to generate the chat token for. Format: projects/{project}/locations/{location}/apps/{app}/sessions/{session} (required)
  body: object, The request body.
    The object takes the form of:

{ # Request message for WidgetService.GenerateChatToken.
  "deployment": "A String", # Required. The deployment of the app to use for the session. Format: projects/{project}/locations/{location}/apps/{app}/deployments/{deployment}
  "recaptchaToken": "A String", # Optional. The reCAPTCHA token generated by the client-side chat widget.
}

  x__xgafv: string, V1 error format.
    Allowed values
      1 - v1 error format
      2 - v2 error format

Returns:
  An object of the form:

    { # Response message for WidgetService.GenerateChatToken.
  "chatToken": "A String", # The session scoped token for chat widget to authenticate with Session APIs.
  "expireTime": "A String", # The time at which the chat token expires.
}
runSession(session, body=None, x__xgafv=None)
Initiates a single turn interaction with the CES agent within a session.

Args:
  session: string, Required. The unique identifier of the session. Format: `projects/{project}/locations/{location}/apps/{app}/sessions/{session}` (required)
  body: object, The request body.
    The object takes the form of:

{ # Request message for SessionService.RunSession.
  "config": { # The configuration for the session. # Required. The configuration for the session.
    "deployment": "A String", # Optional. The deployment of the app to use for the session. Format: `projects/{project}/locations/{location}/apps/{app}/deployments/{deployment}`
    "entryAgent": "A String", # Optional. The entry agent to handle the session. If not specified, the session will be handled by the root agent of the app. Format: `projects/{project}/locations/{location}/agents/{agent}`
    "historicalContexts": [ # Optional. The historical context of the session, including user inputs, agent responses, and other messages. Typically, CES agent would manage session automatically so client doesn't need to explicitly populate this field. However, client can optionally override the historical contexts to force the session start from certain state.
      { # A message within a conversation.
        "chunks": [ # Optional. Content of the message as a series of chunks.
          { # A chunk of content within a message.
            "agentTransfer": { # Represents an event indicating the transfer of a conversation to a different agent. # Optional. Agent transfer event.
              "displayName": "A String", # Output only. Display name of the agent.
              "targetAgent": "A String", # Required. The agent to which the conversation is being transferred. The agent will handle the conversation from this point forward. Format: `projects/{project}/locations/{location}/apps/{app}/agents/{agent}`
            },
            "defaultVariables": { # A struct represents default variables at the start of the conversation, keyed by variable names.
              "a_key": "", # Properties of the object.
            },
            "image": { # Represents an image input or output in the conversation. # Optional. Image data.
              "data": "A String", # Required. Raw bytes of the image.
              "mimeType": "A String", # Required. The IANA standard MIME type of the source data. Supported image types includes: * image/png * image/jpeg * image/webp
            },
            "payload": { # Optional. Custom payload data.
              "a_key": "", # Properties of the object.
            },
            "text": "A String", # Optional. Text data.
            "toolCall": { # Request for the client or the agent to execute the specified tool. # Optional. Tool execution request.
              "args": { # Optional. The input parameters and values for the tool in JSON object format.
                "a_key": "", # Properties of the object.
              },
              "displayName": "A String", # Output only. Display name of the tool.
              "id": "A String", # Optional. The unique identifier of the tool call. If populated, the client should return the execution result with the matching ID in ToolResponse.
              "tool": "A String", # Optional. The name of the tool to execute. Format: `projects/{project}/locations/{location}/apps/{app}/tools/{tool}`
              "toolsetTool": { # A tool that is created from a toolset. # Optional. The toolset tool to execute.
                "toolId": "A String", # Optional. The tool ID to filter the tools to retrieve the schema for.
                "toolset": "A String", # Required. The resource name of the Toolset from which this tool is derived. Format: `projects/{project}/locations/{location}/apps/{app}/toolsets/{toolset}`
              },
            },
            "toolResponse": { # The execution result of a specific tool from the client or the agent. # Optional. Tool execution response.
              "displayName": "A String", # Output only. Display name of the tool.
              "id": "A String", # Optional. The matching ID of the tool call the response is for.
              "response": { # Required. The tool execution result in JSON object format. Use "output" key to specify tool response and "error" key to specify error details (if any). If "output" and "error" keys are not specified, then whole "response" is treated as tool execution result.
                "a_key": "", # Properties of the object.
              },
              "tool": "A String", # Optional. The name of the tool to execute. Format: `projects/{project}/locations/{location}/apps/{app}/tools/{tool}`
              "toolsetTool": { # A tool that is created from a toolset. # Optional. The toolset tool that got executed.
                "toolId": "A String", # Optional. The tool ID to filter the tools to retrieve the schema for.
                "toolset": "A String", # Required. The resource name of the Toolset from which this tool is derived. Format: `projects/{project}/locations/{location}/apps/{app}/toolsets/{toolset}`
              },
            },
            "transcript": "A String", # Optional. Transcript associated with the audio.
            "updatedVariables": { # A struct represents variables that were updated in the conversation, keyed by variable names.
              "a_key": "", # Properties of the object.
            },
          },
        ],
        "eventTime": "A String", # Optional. Timestamp when the message was sent or received. Should not be used if the message is part of an example.
        "role": "A String", # Optional. The role within the conversation, e.g., user, agent.
      },
    ],
    "inputAudioConfig": { # InputAudioConfig configures how the CES agent should interpret the incoming audio data. # Optional. Configuration for processing the input audio.
      "audioEncoding": "A String", # Required. The encoding of the input audio data.
      "noiseSuppressionLevel": "A String", # Optional. Whether to enable noise suppression on the input audio. Available values are "low", "moderate", "high", "very_high".
      "sampleRateHertz": 42, # Required. The sample rate (in Hertz) of the input audio data.
    },
    "outputAudioConfig": { # OutputAudioConfig configures how the CES agent should synthesize outgoing audio responses. # Optional. Configuration for generating the output audio.
      "audioEncoding": "A String", # Required. The encoding of the output audio data.
      "sampleRateHertz": 42, # Required. The sample rate (in Hertz) of the output audio data.
    },
    "remoteDialogflowQueryParameters": { # [QueryParameters](https://cloud.google.com/dialogflow/cx/docs/reference/rpc/google.cloud.dialogflow.cx.v3#queryparameters) to send to the remote [Dialogflow](https://cloud.google.com/dialogflow/cx/docs/concept/console-conversational-agents) agent when the session control is transferred to the remote agent. # Optional. [QueryParameters](https://cloud.google.com/dialogflow/cx/docs/reference/rpc/google.cloud.dialogflow.cx.v3#queryparameters) to send to the remote [Dialogflow](https://cloud.google.com/dialogflow/cx/docs/concept/console-conversational-agents) agent when the session control is transferred to the remote agent.
      "endUserMetadata": { # Optional. The end user metadata to be sent in [QueryParameters](https://cloud.google.com/dialogflow/cx/docs/reference/rpc/google.cloud.dialogflow.cx.v3#queryparameters).
        "a_key": "", # Properties of the object.
      },
      "payload": { # Optional. The payload to be sent in [QueryParameters](https://cloud.google.com/dialogflow/cx/docs/reference/rpc/google.cloud.dialogflow.cx.v3#queryparameters).
        "a_key": "", # Properties of the object.
      },
      "webhookHeaders": { # Optional. The HTTP headers to be sent as webhook_headers in [QueryParameters](https://cloud.google.com/dialogflow/cx/docs/reference/rpc/google.cloud.dialogflow.cx.v3#queryparameters).
        "a_key": "A String",
      },
    },
    "timeZone": "A String", # Optional. The time zone of the user. If provided, the agent will use the time zone for date and time related variables. Otherwise, the agent will use the time zone specified in the App.time_zone_settings. The format is the IANA Time Zone Database time zone, e.g. "America/Los_Angeles".
  },
  "inputs": [ # Required. Inputs for the session.
    { # Input for the session.
      "audio": "A String", # Optional. Audio data from the end user.
      "blob": { # Represents a blob input or output in the conversation. # Optional. Blob data from the end user.
        "data": "A String", # Required. Raw bytes of the blob.
        "mimeType": "A String", # Required. The IANA standard MIME type of the source data.
      },
      "dtmf": "A String", # Optional. DTMF digits from the end user.
      "event": { # Event input. # Optional. Event input.
        "event": "A String", # Required. The name of the event.
      },
      "image": { # Represents an image input or output in the conversation. # Optional. Image data from the end user.
        "data": "A String", # Required. Raw bytes of the image.
        "mimeType": "A String", # Required. The IANA standard MIME type of the source data. Supported image types includes: * image/png * image/jpeg * image/webp
      },
      "text": "A String", # Optional. Text data from the end user.
      "toolResponses": { # Execution results for the requested tool calls from the client. # Optional. Execution results for the tool calls from the client.
        "toolResponses": [ # Optional. The list of tool execution results.
          { # The execution result of a specific tool from the client or the agent.
            "displayName": "A String", # Output only. Display name of the tool.
            "id": "A String", # Optional. The matching ID of the tool call the response is for.
            "response": { # Required. The tool execution result in JSON object format. Use "output" key to specify tool response and "error" key to specify error details (if any). If "output" and "error" keys are not specified, then whole "response" is treated as tool execution result.
              "a_key": "", # Properties of the object.
            },
            "tool": "A String", # Optional. The name of the tool to execute. Format: `projects/{project}/locations/{location}/apps/{app}/tools/{tool}`
            "toolsetTool": { # A tool that is created from a toolset. # Optional. The toolset tool that got executed.
              "toolId": "A String", # Optional. The tool ID to filter the tools to retrieve the schema for.
              "toolset": "A String", # Required. The resource name of the Toolset from which this tool is derived. Format: `projects/{project}/locations/{location}/apps/{app}/toolsets/{toolset}`
            },
          },
        ],
      },
      "variables": { # Optional. Contextual variables for the session, keyed by name. Only variables declared in the app will be used by the CES agent. Unrecognized variables will still be sent to the Dialogflow agent as additional session parameters.
        "a_key": "", # Properties of the object.
      },
      "willContinue": True or False, # Optional. A flag to indicate if the current message is a fragment of a larger input in the bidi streaming session. When `true`, the agent will defer processing until a subsequent message with `will_continue` set to `false` is received. Note: This flag has no effect on audio and DTMF inputs, which are always processed in real-time.
    },
  ],
}

  x__xgafv: string, V1 error format.
    Allowed values
      1 - v1 error format
      2 - v2 error format

Returns:
  An object of the form:

    { # Response message for SessionService.RunSession.
  "outputs": [ # Outputs for the session.
    { # Output for the session.
      "audio": "A String", # Output audio from the CES agent.
      "citations": { # Citations associated with the agent response. # Citations that provide the source information for the agent's generated text.
        "citedChunks": [ # List of cited pieces of information.
          { # Piece of cited information.
            "text": "A String", # Text used for citaiton.
            "title": "A String", # Title of the cited document.
            "uri": "A String", # URI used for citation.
          },
        ],
      },
      "diagnosticInfo": { # Contains execution details during the processing. # Optional. Diagnostic information contains execution details during the processing of the input. Only populated in the last SessionOutput (with `turn_completed=true`) for each turn.
        "messages": [ # List of the messages that happened during the processing.
          { # A message within a conversation.
            "chunks": [ # Optional. Content of the message as a series of chunks.
              { # A chunk of content within a message.
                "agentTransfer": { # Represents an event indicating the transfer of a conversation to a different agent. # Optional. Agent transfer event.
                  "displayName": "A String", # Output only. Display name of the agent.
                  "targetAgent": "A String", # Required. The agent to which the conversation is being transferred. The agent will handle the conversation from this point forward. Format: `projects/{project}/locations/{location}/apps/{app}/agents/{agent}`
                },
                "defaultVariables": { # A struct represents default variables at the start of the conversation, keyed by variable names.
                  "a_key": "", # Properties of the object.
                },
                "image": { # Represents an image input or output in the conversation. # Optional. Image data.
                  "data": "A String", # Required. Raw bytes of the image.
                  "mimeType": "A String", # Required. The IANA standard MIME type of the source data. Supported image types includes: * image/png * image/jpeg * image/webp
                },
                "payload": { # Optional. Custom payload data.
                  "a_key": "", # Properties of the object.
                },
                "text": "A String", # Optional. Text data.
                "toolCall": { # Request for the client or the agent to execute the specified tool. # Optional. Tool execution request.
                  "args": { # Optional. The input parameters and values for the tool in JSON object format.
                    "a_key": "", # Properties of the object.
                  },
                  "displayName": "A String", # Output only. Display name of the tool.
                  "id": "A String", # Optional. The unique identifier of the tool call. If populated, the client should return the execution result with the matching ID in ToolResponse.
                  "tool": "A String", # Optional. The name of the tool to execute. Format: `projects/{project}/locations/{location}/apps/{app}/tools/{tool}`
                  "toolsetTool": { # A tool that is created from a toolset. # Optional. The toolset tool to execute.
                    "toolId": "A String", # Optional. The tool ID to filter the tools to retrieve the schema for.
                    "toolset": "A String", # Required. The resource name of the Toolset from which this tool is derived. Format: `projects/{project}/locations/{location}/apps/{app}/toolsets/{toolset}`
                  },
                },
                "toolResponse": { # The execution result of a specific tool from the client or the agent. # Optional. Tool execution response.
                  "displayName": "A String", # Output only. Display name of the tool.
                  "id": "A String", # Optional. The matching ID of the tool call the response is for.
                  "response": { # Required. The tool execution result in JSON object format. Use "output" key to specify tool response and "error" key to specify error details (if any). If "output" and "error" keys are not specified, then whole "response" is treated as tool execution result.
                    "a_key": "", # Properties of the object.
                  },
                  "tool": "A String", # Optional. The name of the tool to execute. Format: `projects/{project}/locations/{location}/apps/{app}/tools/{tool}`
                  "toolsetTool": { # A tool that is created from a toolset. # Optional. The toolset tool that got executed.
                    "toolId": "A String", # Optional. The tool ID to filter the tools to retrieve the schema for.
                    "toolset": "A String", # Required. The resource name of the Toolset from which this tool is derived. Format: `projects/{project}/locations/{location}/apps/{app}/toolsets/{toolset}`
                  },
                },
                "transcript": "A String", # Optional. Transcript associated with the audio.
                "updatedVariables": { # A struct represents variables that were updated in the conversation, keyed by variable names.
                  "a_key": "", # Properties of the object.
                },
              },
            ],
            "eventTime": "A String", # Optional. Timestamp when the message was sent or received. Should not be used if the message is part of an example.
            "role": "A String", # Optional. The role within the conversation, e.g., user, agent.
          },
        ],
        "rootSpan": { # A span is a unit of work or a single operation during the request processing. # A trace of the entire request processing, represented as a root span. This span can contain nested child spans for specific operations.
          "attributes": { # Output only. Key-value attributes associated with the span.
            "a_key": "", # Properties of the object.
          },
          "childSpans": [ # Output only. The child spans that are nested under this span.
            # Object with schema name: Span
          ],
          "duration": "A String", # Output only. The duration of the span.
          "endTime": "A String", # Output only. The end time of the span.
          "name": "A String", # Output only. The name of the span.
          "startTime": "A String", # Output only. The start time of the span.
        },
      },
      "endSession": { # Indicates the session has terminated, due to either successful completion (e.g. user says "Good bye!" ) or an agent escalation. The agent will not process any further inputs after session is terminated and the client should half-close and disconnect after receiving all remaining responses from the agent. # Indicates the session has ended.
        "metadata": { # Optional. Provides additional information about the end session signal, such as the reason for ending the session.
          "a_key": "", # Properties of the object.
        },
      },
      "googleSearchSuggestions": { # Search suggestions from Google Search Tool. # The suggestions returned from Google Search as a result of invoking the GoogleSearchTool.
        "htmls": [ # Compliant HTML and CSS styling for search suggestions. The provided HTML and CSS automatically adapts to your device settings, displaying in either light or dark mode indicated by `@media(prefers-color-scheme)`.
          "A String",
        ],
        "webSearchQueries": [ # List of queries used to perform the google search along with the search result URIs forming the search suggestions.
          { # Represents a single web search query and its associated search uri.
            "query": "A String", # The search query text.
            "uri": "A String", # The URI to the Google Search results page for the query.
          },
        ],
      },
      "payload": { # Custom payload with structured output from the CES agent.
        "a_key": "", # Properties of the object.
      },
      "text": "A String", # Output text from the CES agent.
      "toolCalls": { # Request for the client to execute the tools and return the execution results before continuing the session. # Request for the client to execute the tools.
        "toolCalls": [ # Optional. The list of tool calls to execute.
          { # Request for the client or the agent to execute the specified tool.
            "args": { # Optional. The input parameters and values for the tool in JSON object format.
              "a_key": "", # Properties of the object.
            },
            "displayName": "A String", # Output only. Display name of the tool.
            "id": "A String", # Optional. The unique identifier of the tool call. If populated, the client should return the execution result with the matching ID in ToolResponse.
            "tool": "A String", # Optional. The name of the tool to execute. Format: `projects/{project}/locations/{location}/apps/{app}/tools/{tool}`
            "toolsetTool": { # A tool that is created from a toolset. # Optional. The toolset tool to execute.
              "toolId": "A String", # Optional. The tool ID to filter the tools to retrieve the schema for.
              "toolset": "A String", # Required. The resource name of the Toolset from which this tool is derived. Format: `projects/{project}/locations/{location}/apps/{app}/toolsets/{toolset}`
            },
          },
        ],
      },
      "turnCompleted": True or False, # If true, the CES agent has detected the end of the current conversation turn and will provide no further output for this turn.
      "turnIndex": 42, # Indicates the sequential order of conversation turn to which this output belongs to, starting from 1.
    },
  ],
}