LINE

通过 Dialogflow 的 LINE 集成,您可以将 Dialogflow 代理用作 LINE 聊天机器人。

限制

此集成仅支持默认代理语言

运作方式

集成的工作原理如下:

  • 您创建一个 LINE 渠道
  • 您将 Dialogflow 代理与该渠道关联,使它们能够相互通信。
  • Dialogflow 集成使用 LINE Messaging API 向最终用户发送消息。
  • Dialogflow 集成充当 LINE 网络钩子接收来自最终用户的消息。

设置

如需设置集成,请执行以下操作:

  1. 按照步骤创建 LINE 渠道:开始使用 Messaging API
  2. 从 Dialogflow 控制台获取 LINE 网络钩子网址:
    1. 转到 Dialogflow ES 控制台
    2. 点击左侧边栏菜单中的集成
    3. 点击 LINE
    4. 复制网络钩子网址值。您需要此值来配置 LINE 网络钩子。
  3. 配置 LINE 网络钩子:
    1. 按照步骤为渠道配置 LINE 网络钩子:LINE 接收消息(网络钩子)
    2. 使用上面复制的网络钩子网址提供 LINE 网络钩子配置。
    3. 复制 Channel IDChannel secretChannel access token 值。您需要这些值来配置 Dialogflow 集成。
  4. 配置 Dialogflow 集成:
    1. 转到 Dialogflow ES 控制台
    2. 点击左侧边栏菜单中的集成
    3. 点击 LINE
    4. Channel IDChannel secretChannel access token 粘贴到相应字段中。
    5. 选择环境(如适用)。
    6. 点击开始 (START)。

测试

如要测试您的代理,请点按 LINE 应用主屏幕上的横向三点图标。然后点击二维码图标并扫描聊天机器人设置页面上的二维码。此操作会将您的聊天机器人添加到对话列表中。

富响应消息

系统支持下列富响应消息

图片响应

Dialogflow 图片响应类型以 LINE 图片消息类型的形式发送至 LINE。

支持以下格式和尺寸:

  • jpeg
  • 大小不超过 1 MB
  • 尺寸不超过 240 x 240

卡片响应

Dialogflow 卡片响应类型以 LINE 模板消息类型的形式发送到 LINE。

快速回复响应

Dialogflow 快速回复响应类型以 LINE 模板消息类型的形式发送到 LINE。

自定义载荷响应

您可以使用自定义载荷响应发送大多数 LINE 消息类型

例如,以下自定义载荷会提供 LINE 模板消息:

{
  "type": "template",
  "altText": "this is a buttons template",
  "template": {
    "type": "buttons",
    "thumbnailImageUrl": "https://example.com/bot/images/image.jpg",
    "title": "Menu",
    "text": "Please select",
    "actions": [
      {
        "type": "postback",
        "label": "Buy",
        "data": "action=buy&itemid=123"
      },
      {
        "type": "postback",
        "label": "Add to cart",
        "data": "action=add&itemid=123"
      },
      {
        "type": "uri",
        "label": "View detail",
        "uri": "http://example.com/page/123"
      }
    ]
  }
}