Method: properties.chat

提供一个聊天界面,用于通过 API 与 Google Analytics 数据互动。

此产品使用了 AI 技术,可能会显示不准确的信息。您的对话活动可能会用于改进产品,您在使用产品时须遵守 Google 的《条款》《AI 使用政策》《隐私权政策》详细了解 properties.chat AI 隐私权

HTTP 请求

POST https://analyticsdata.googleapis.com/v1alpha/{property=properties/*}:chat

网址采用 gRPC 转码语法。

路径参数

参数
property

string

必需。要聊的房源。格式:properties/{property}

请求正文

请求正文中包含结构如下的数据:

JSON 表示法
{
  "userQuery": string,
  "returnPropertyQuota": boolean,
  "sessionId": string
}
字段
userQuery

string

必需。用户查询。

returnPropertyQuota

boolean

可选。如果为 true,则响应将包含相应 Google Analytics 媒体资源的配额当前状态。配额将在 PropertyChatQuota 中返回。

sessionId

string

可选。提供此会话 ID 可继续现有对话并保持上下文。如果此字段为空或未设置,系统会创建新的聊天会话。无效的会话 ID 会导致错误。

响应正文

properties.chat 方法的响应消息。

如果成功,响应正文将包含结构如下的数据:

JSON 表示法
{
  "sessionId": string,
  "blocks": [
    {
      object (ResponseBlock)
    }
  ],
  "propertyQuota": {
    object (PropertyChatQuota)
  }
}
字段
sessionId

string

相应对话会话的唯一标识符。在后续请求中提供此 ID,以保持对话上下文。

blocks[]

object (ResponseBlock)

构成聊天响应的响应块。这可能包括文本、表格和列表。

propertyQuota

object (PropertyChatQuota)

相应 Google Analytics 媒体资源的配额状态(包括相应请求)。

授权范围

需要以下 OAuth 范围:

  • https://www.googleapis.com/auth/analytics.chatbot.read

ResponseBlock

聊天回答中的一个结构化数据块。

JSON 表示法
{

  // The following is a list of mutually exclusive fields. At most one of the
  // fields will be set in a response:
  "text": string,
  "table": {
    object (DataTable)
  }
  // End of mutually exclusive fields.
}
字段
一个结构化数据块。以下是互斥字段的列表。在响应中,最多只能设置一个字段:
text

string

一段文字。

table

object (DataTable)

一个表格数据块。

互斥字段的结束位置。

DataTable

数据表。

JSON 表示法
{
  "headers": [
    {
      object (DataTableHeader)
    }
  ],
  "rows": [
    {
      object (DataTableRow)
    }
  ]
}
字段
headers[]

object (DataTableHeader)

描述维度列。标题的数量和顺序与行中显示的维度一致。

rows[]

object (DataTableRow)

报告中维度值组合和指标值的行。

DataTableHeader

描述 DataTable 中的列标题。

JSON 表示法
{
  "header": string,
  "dataType": string
}
字段
header

string

标头名称。

dataType

string

数据类型。

DataTableRow

DataTable 中的一行。

JSON 表示法
{
  "columns": [
    {
      object (DataTableCell)
    }
  ]
}
字段
columns[]

object (DataTableCell)

相应行中的单元格值。

DataTableCell

数据表中的单元格。

JSON 表示法
{
  "value": string
}
字段
value

string

相应单元格的值。

PropertyChatQuota

聊天机器人特定字段的媒体资源配额。

JSON 表示法
{
  "tokensPerDay": {
    object (QuotaStatus)
  },
  "tokensPerHour": {
    object (QuotaStatus)
  }
}
字段
tokensPerDay

object (QuotaStatus)

每天消耗的 properties.chat token。

tokensPerHour

object (QuotaStatus)

每小时消耗的聊天 token。