Google Chat

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

限制

设置 Google Chat

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

启用 Google Chat API

在使用 Google API 之前,您需要在 Google Cloud 项目中启用它们。您可以在单个 Google Cloud 项目中启用一个或多个 API。

  1. 在 Google Cloud 控制台中,启用 Google Chat API 和 Dialogflow API

  2. 确认您在正确的 Cloud 项目中启用 API,然后点击下一步

  3. 确认您启用了正确的 API,然后点击启用

通过 Dialogflow CX 进行设置

  1. 转到 Dialogflow CX 控制台
  2. 选择您的 Google Cloud 项目。
  3. 选择您的代理。
  4. 选择管理标签页。
  5. 点击左侧边栏菜单中的集成
  6. Google Chat 中点击连接
  7. 填写以下必填信息:
    • 名称:当用户与此应用创建的内容互动或使用该应用创建的内容(例如在消息、搜索中以及用“@”提及你时)显示的名称。例如 Dialogflow CX App
    • 头像网址:向与应用互动的用户显示的头像图片。请指定托管一张方形(宽高比为 1:1)PNG 图片的 HTTPS 网址。建议的最小尺寸:256 x 256 像素。例如 https://developers.google.com/workspace/chat/images/quickstart-app-avatar.png
    • 说明:应用的说明,例如 A helpful bot that responds to real human conversation
  8. 根据情况选择环境
  9. 输入电子邮件地址,以将此 Chat 应用提供给特定用户和群组(如适用)。
  10. 点击启动

测试

如要测试您配置的应用,请在 Google Chat 聊天室中提及该应用,或向其发送私信。例如,

  1. 打开 Google Chat
  2. 点击发起新聊天
  3. 添加 1 位或更多人字段中,输入 Chat 应用的名称。
  4. 从结果中选择您的 Chat 应用。系统会打开一条私信。

富响应消息

使用 Fulfillment 中的自定义载荷支持富响应消息。如需了解消息格式,请参阅 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频道专用响应