利用 Dialogflow 的 Google Chat 集成,您可以基于 Dialogflow 技术轻松创建具有自然语言理解能力的 Google Chat 应用。
限制
- 此集成仅支持采用代理默认语言的文本输入。
设置 Google Chat
如需为代理设置 Google Chat 集成,您需要符合以下条件:
- Google Cloud 项目
创建 Google Chat 应用
- 前往您的 Google Cloud 项目
- 在 Google Cloud 控制台中,启用 Google Chat API
- 前往 Google Chat API 配置页面(依次选择菜单 > API 和服务 > 已启用的 API 和服务 > Google Chat API > 配置)
- 填写配置信息(名称、头像网址、说明等)(如适用)
- 请务必启用互动功能
设置 Dialogflow
- 点击左侧面板上的管理标签页。
- 点击左侧菜单中的集成 (Integrations)。
- 点击 Google Chat 图块上的连接按钮。
- 选择环境(如适用)。
- 点击开始。
- 复制 Webhook 网址。
在 Google Chat 中启用网络钩子
返回 Google Chat API 配置页面,然后将您的网络钩子网址粘贴到交互式功能 > 连接设置 > 应用网址下
测试
如要测试您配置的应用,请将其添加到 Google Chat 聊天室或向其发送私信。
富响应消息
可通过履行中的自定义载荷支持富响应消息。如需了解消息格式,请参阅 Google Chat 消息 API。
短信
以下自定义载荷提供 Google Chat 文本消息:
{ "text": "Hello, world" }
卡片消息
以下自定义载荷提供了 Google Chat 卡片消息:
{ 'cardsV2': [{ 'cardId': 'createCardMessage', 'card': { 'header': { 'title': 'A card message!', 'subtitle': 'Sent from Dialogflow', 'imageUrl': 'https://developers.google.com/chat/images/chat-product-icon.png', 'imageType': 'CIRCLE' }, 'sections': [ { 'widgets': [ { 'buttonList': { 'buttons': [ { 'text': 'Read the docs!', 'onClick': { 'openLink': { 'url': 'https://developers.google.com/workspace/chat' } } } ] } } ] } ] } }] }
针对特定频道的响应
配置完成后,当代理回复 Google Chat 消息时,系统会自动使用频道为 DF_CX_GOOGLE_CHAT
的频道专用响应。