Google Chat

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

限制

设置 Google Chat

如需为代理设置 Google Chat 集成,您需要具备:

启用 Google Chat API

在使用 Google API 之前,您需要先在 Google Cloud 项目中启用这些 API。您可以在单个 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. 添加一人或多人字段中,输入 Chat 应用的名称。
  4. 从结果中选择您的 Chat 应用。系统会打开一条私信。

富响应消息

使用 Fulfillment 中的自定义载荷支持富响应消息。如需了解消息格式,请参阅 Google Chat Message API

短信

以下自定义载荷会提供 Google Chat 短信

{
  "text": "Hello, world"
}

卡片消息

以下自定义载荷提供 Google 聊天卡片消息

{
  '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针对特定渠道的响应