Google Chat

利用 Dialogflow 的 Google Chat 集成,您可以基于 Dialogflow 技术轻松创建具有自然语言理解能力的 Google Chat 应用。

限制

设置 Google Chat

如需为代理设置 Google Chat 集成,您需要符合以下条件:

  • Google Cloud 项目

创建 Google Chat 应用

  1. 前往您的 Google Cloud 项目
  2. 在 Google Cloud 控制台中,启用 Google Chat API
  3. 前往 Google Chat API 配置页面(依次选择菜单 > API 和服务 > 已启用的 API 和服务 > Google Chat API > 配置
  4. 填写配置信息(名称、头像网址、说明等)(如适用)
    • 请务必启用互动功能

设置 Dialogflow

  1. 点击左侧面板上的管理标签页。
  2. 点击左侧菜单中的集成 (Integrations)。
  3. 点击 Google Chat 图块上的连接按钮。
  4. 选择环境(如适用)。
  5. 点击开始
  6. 复制 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频道专用响应