Google 助理链接

您可以生成一个网址,该网址直接链接到您的 Action 的特定 intent。 用户在网络浏览器或移动浏览器中点击 Google 助理链接(以前称为“操作链接”)将被定向到 孩子设备上的 Google 助理,用户可在其中直接与你的 Action 互动。

Google 助理链接与目录网页链接不同,后者会将用户转到 Google 助理目录中的 Action 页面。

在以下情况下,Google 助理链接会很有用:

  • 将用户链接到方法指南网站上的语音指导说明。
  • 从帮助页面将用户链接到客户服务页面。
  • 将用户链接到更新 intent,以便他们可以选择加入 您日后的更新。

你可以在 Actions 控制台中的项目中生成 Google 助理链接。 所有部署渠道(Alpha 版、Beta 版、 和生产环境)。例如,如果您在 Alpha 版中启用了 Google 助理链接 发布 Action,那么 Alpha 版测试人员可以使用该链接。

如需为 Action 生成网址,请按以下步骤操作:

  1. Actions 控制台中,前往部署 >Google 助理链接
  2. 对于 Intent,选择您要为其生成链接的 intent。
  3. 启用 Would you like to enable linked for intent_name? 选项。
  4. (可选)在广告系列参数部分中,输入您希望 另外,还要在链接中以网址参数的形式捕获数据。
  5. (可选)输入链接标题。使用此标题描述 Action 的用途。对于 例如,如果您的操作将用户引导到交易流程中去购物 音乐会门票,链接标题可以是“购买音乐会门票”。

输入信息后,您可以查看和复制生成的网址或 为 Google 助理链接生成的代码段随时随地使用 Google 助理链接 来将用户引导至这个特定的 Action

你可以测试任何 intent(主 intent 或自定义 intent,包含或不包含 intent)的 Google 助理链接 参数)。

如要在设备上测试 Google 助理链接,请按以下步骤操作:

  1. 在 Actions 控制台中生成 Google 助理链接
  2. 通过电子邮件、聊天消息或其他形式将 Google 助理链接作为网址发送给自己 格式。
  3. 在内置 Google 助理的设备上,使用同一账号登录 Google 助理 创建 Actions 项目所用的资源。
  4. 在同一设备上,点击你发送给自己的 Google 助理链接。

确认 Google 助理关联按预期运行后,您需要重新部署 您的 Action,为用户提供该链接。

Google 助理链接可以选择在网址中包含 intent 和参数。使用 广告系列参数部分,添加广告系列参数。

如果 Google 助理链接不含其他参数,Google 助理就会链接到 您的 Action 的 MAIN intent (actions.intent.MAIN),其中包含以下代码 行为:

  • 如果您未在 Google 助理链接中明确启用 MAIN intent, Google 助理会匹配不含任何参数的主要 intent,类似于 “与 app_name”对话的行为。
  • 如果您明确启用了 MAIN intent,Google 助理就会传递参数 添加到你的操作中。

下面是一个使用 MAIN intent 的 Google 助理链接网址示例,其中不包含 其他参数:

https://assistant.google.com/services/invoke/uid/000000d139bbc4d4

Google 助理链接网址的一般语法如下:

https://assistant.google.com/services/invoke[/$action_id][?intent=$intent&param.$param=$value][&$utm_param=$utm_value]

下表介绍了您可以设置的网址参数:

网址参数 说明
$action_id 操作的数字标识符。
$intent 内置 intent 或用户 intent 的全名。
$param Action 软件包中指定的 intent 参数的全名。
$value $param 中声明的类型(在 操作包。
$utm_param 一个或多个 UTM 参数类型的列表。有效值包括: utm_sourceutm_mediumutm_campaignutm_termutm_content
$utm_value UTM 参数的字符串值。

如果 Google 助理链接包含内置 intent(该 intent 以 actions.intent.),Google 助理会尝试提取所有内置 intent 参数,并将这些参数传递给 Action。任何会造成 Google 助理无法理解,因为内置 intent 参数已被移除。

对于对话型 Action,Google 助理会将这些参数发送到你的执行方式 包含在 AppRequest 消息中。

以下示例展示了如何指定 Google 助理链接网址 包含具有单个 intent 参数的内置 intent:

https://assistant.google.com/services/invoke/uid/0000008ddd7eabec?intent=actions.intent.PLAY_GAME&param.name=%22ExampleGame%22

对于用户 intent,Google 助理只会提取 作为 intent 的一部分定义的,并舍弃任何其他参数。

以下示例展示了如何指定 Google 助理链接网址 包含用户 intent:

https://assistant.google.com/services/invoke/uid/0000001f575305a0?intent=NEWS_UPDATE_DEEP_LINK&param.topic=sports

对于上述示例网址,Google 助理会在 AppRequest 中添加一个 JSON 对象作为 如下:

argument {
  name: 'topic',
  raw_text: 'sports',
  text_value: 'sports',
}

UTM 参数是 Google 助理发送给你的字符串 用户点击 Google 助理链接后执行的操作。您可以使用 这些字符串以供分析之用。

Google 助理向你的 Action 发送的 UTM 参数包括:

  • utm_source
  • utm_medium
  • utm_campaign
  • utm_term
  • utm_content

以下示例展示了如何指定 Google 助理链接网址 包含 UTM 参数:

https://assistant.google.com/services/invoke/uid/000000d139bbc4d4?utm_source=Google&utm_medium=email&utm_campaign=holiday+sale

对于上面的示例网址,Google 助理会在 AppRequest 条消息:

argument {
  name: 'utm_source',
  raw_text: 'Google',
  text_value: 'Google',
}
argument {
  name: 'utm_medium',
  raw_text: 'email',
  text_value: 'email',
}
argument {
  name: 'utm_campaign',
  raw_text: 'holiday sale',
  text_value: 'holiday sale',
}

借助于丰富的 Google 助理链接,你可以利用 使用 Assist.js用户可以试用你的 Action,以及 (通过账号关联)。

当用户访问您的网站时,会看到“试用 Google 助理” 按钮,触发 Rich Assistant 关联流程。

为你的 Action 启用账号关联后,用户就可以在内置 Google 助理的任何设备上访问你的 Action。此外,用户还可以将他们使用您的服务的账号与其 Google 账号相关联,从而获得更加个性化的体验。

与账号关联时,富媒体助理链接会使用您的授权网址,该网址在 Actions 控制台的项目中设置。如需了解详情,请参阅账号关联文档

前提条件

如需使用 Rich Assistant 链接,您需要满足以下条件:

本地开发

如需在网站上添加丰富的 Google 助理链接,请完成以下步骤:

  1. 在您的页面上添加以下 JavaScript 库,并将 <PROJECT_ID> 替换为您的 Actions 项目 ID:

    <script async
    src="https://actions.google.com/api/assist.js?projectId={PROJECT_ID}&dev=true">
    </script>
    
  2. 将以下 HTML 标记添加到您网页的某处。这会加载内嵌的“通过 Google 助理试试”按钮:

    <google-assistant-link-group>
      <!-- One or more <google-assistant-link> tags -->
      <google-assistant-link href="{ASSISTANT_LINK_1}">
      </google-assistant-link>
      <google-assistant-link href="{ASSISTANT_LINK_2}">
      </google-assistant-link>
    </google-assistant-link-group>
    

主动触发

如果您希望在用户首次访问您的网页时自动启动富媒体 Google 助理关联流程,请使用 <google-assistant-proactive-link> 代码。应用此代码后,在用户首次访问时,链接会激活,无需用户选择内嵌按钮。

  1. id 添加到 Google 助理关联组代码中:

    <google-assistant-link-group id="my-group">
      <!-- One or more <google-assistant-link> tags -->
      <google-assistant-link href="{ASSISTANT_LINK_1}">
      </google-assistant-link>
      <google-assistant-link href="{ASSISTANT_LINK_2}">
      </google-assistant-link>
    </google-assistant-link-group>
    
  2. 在您的网页上放置 <google-assistant-proactive-action-link> 标记,并将其 groupId 属性设置为 id

    <google-assistant-link-group id="my-group">
      <!-- One or more <google-assistant-link> tags -->
      <google-assistant-link href="{ASSISTANT_LINK_1}">
      </google-assistant-link>
      <google-assistant-link href="{ASSISTANT_LINK_2}">
      </google-assistant-link>
    </google-assistant-link-group>
    
    <google-assistant-proactive-link
    groupId="my-group">
    </google-assistant-proactive-link>
    

部署

富助理链接仅适用于您拥有的且已通过 Google 验证的网域。在本地进行开发时,可以通过执行以下操作来绕过此要求:有权访问 Actions 项目,登录您的 Google 账号,并在脚本代码中设置 dev=true 查询参数。

  <script async
    src="https://actions.google.com/api/assist.js?projectId={PROJECT_ID}&dev=true">
  </script>

如需使用 Google 助理丰富的链接部署 Action,请执行以下操作:

  1. 在 Actions 控制台中的 Deploy >品牌验证 >关联网站
  2. 从脚本中移除 dev=true 查询参数:

    <script async
    src="https://actions.google.com/api/assist.js?projectId={PROJECT_ID}">
    </script>
    

限制和最佳做法

以下限制和最佳做法适用,因此你的 Google 助理链接网址 可在目录之外或 Google 其他 服务:

  • 继续支持你所有的 Google 助理链接。如果您分发 之后出现的 Google 助理链接损坏,则您的 Actions 项目可能会被标记为 健康状况不佳并被删除
  • 发布链接表示支持来自不受信任的来源的触发。不限 关联的 Action,因此在执行任何关联操作之前,你必须先明确确认用户 例如,关闭智能家居的 Action 设备应提示用户 “确定要停用$applianceName吗?”

    在这种情况下,实际操作是指影响用户 服务、数据、设备、网络、计算机或 API。例如,发送 电子邮件、执行交易、更改智能家居的状态 创建订阅或更新某项内容