JSON编辑模式
  • PDF

JSON编辑模式

  • PDF

以下介绍在CLOVA Chatbot中可进行操作的JSON输入形式。JSON编辑模式适合用于将组合回复和多个必填项的复杂回复类型复制到其他对话中的情况。
点击 [JSON编辑模式] 按钮时,即可复制JSON结构的数据。通过将复制的数据应用于其他对话,便可以轻松复制经复杂设置的回复类型。

默认回复

JSON Structure示例如下。

[
  {
    "component": {
      "type": "text",
      "data": {
        "description": "the answer of this query is test",
        "url": "http://www.example.com"
      }
    },
    "answerType": "TEXT"
  }
]
字段 类型 是否必需 描述
component object true support Text Component in the chatbot custom api specification v2
component.type string true text
component.data.description string true answer
component.data.url string false the hyperlink jump url
(http://www.example.com )
answerType string true TEXT, means default answer

多链接回复

JSON Structure示例如下。

[
  {
    "component": {
      "type": "template",
      "data": {
        "cover": {
          "type": "text",
          "data": {
            "description": "多链接的回复部分。"
          }
        },
        "contentTable": [
          [
            {
              "colSpan": 1,
              "rowSpan": 1,
              "data": {
                "type": "button",
                "title": "naver",
                "data": {
                  "type": "basic",
                  "action": {
                    "type": "link",
                    "data": {
                      "url": "https://www.naver.com/"
                    }
                  }
                }
              }
            }
          ],
          [
            {
              "colSpan": 1,
              "rowSpan": 1,
              "data": {
                "type": "button",
                "title": "google",
                "data": {
                  "type": "basic",
                  "action": {
                    "type": "link",
                    "data": {
                      "url": "https://www.google.com/"
                    }
                  }
                }
              }
            }
          ]
        ]
      }
    },
    "answerType": "MULTILINKS"
  }
]
字段 类型 是否必需 描述
answerType string true MULTILINKS, means multilink answer
component jsonObject true support Template Component in the chatbot custom api specification v2, and template type only support Text + Buttons

图片回复

JSON Structure示例如下。

[
  {
    "component": {
      "type": "carousel",
      "data": {
        "cards": [
          {
            "type": "image",
            "title": "第一个轮播图片的标题。",
            "data": {
              "imageUrl": "https://www.image.com/image.png",
              "description": "第一个轮播图片的说明。"
            }
          },
          {
            "type": "image",
            "title": "第二个轮播图片的标题。",
            "data": {
              "imageUrl": "https://www.image.com/image.png",
              "description": "第二个轮播图片的说明。"
            }
          }
        ]
      }
    },
    "answerType": "IMAGECARD"
  }
]

Field Introduce

字段 类型 是否必需 描述
answerType string true IMAGECARD, means image answer
component jsonObject true support Image Component, Template Component, Carousel Component in the chatbot custom api specification v2.
It depends on the number of Image Card and Button:
1. one image card, no button: Image Component;
2. one image card, with button: Template Component, and template type only support Image Component + Buttons;
3. multiple image card: Carousel Component, and carouse type support only images and template with image + buttons

Image Field Introduce

字段 类型 是否必需 描述
type string true image
title string true short bold text
data.imageUrl string true image url, must be https url
data.description string false details info of image

选项回复

JSON Structure示例如下。

[
  {
    "component": {
      "type": "text",
      "data": {
        "description": "#{客观式表单名称}"
      }
    },
    "answerType": "SINGLEFORM"
  }
]
字段 类型 是否必需 描述
answerType string true SINGLEFORM, means multiple choice answer
component object true support Text Component in the chatbot custom api specification v2
component.type string true Text
component.data.description string true String1 true form name,wrap with # and {}
#{formName}

组合回复

使用组合回复时,最多可添加5个对话框。
JSON Structure示例如下。

 [
  {
    "component": {
      "type": "text",
      "data": {
        "description": "回复示例。",
        "url": "http://www.example.com"
      }
    },
    "answerType": "TEXT"
  },
  {
    "component": {
      "type": "text",
      "data": {
        "description": "#{客观式表单名称}"
      }
    },
    "answerType": "SINGLEFORM"
  }
]

Field Introduce
In the array data( array[jsonObject] ),each json object represents a bubble, multiple bubbles correspond to multiple json objects.

Flex消息回复

若即时通讯工具为LINE,支持Flex消息回复。
JSON Structure示例如下。

[
  {
    "component": {
      "type": "flex",
      "title": "Flex回复。",
      "data": {
        "type": "bubble",
        "hero": {
          "type": "image",
          "url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/01_1_cafe.png",
          "size": "full",
          "aspectRatio": "20:13",
          "aspectMode": "cover"
        },
        "body": {
          "type": "box",
          "layout": "vertical",
          "contents": [
            {
              "type": "text",
              "text": "Brown Cafe",
              "weight": "bold",
              "size": "xl"
            }
          ]
        },
        "footer": {
          "type": "box",
          "layout": "vertical",
          "spacing": "sm",
          "contents": [
            {
              "type": "button",
              "style": "link",
              "height": "sm",
              "action": {
                "type": "uri",
                "label": "CALL",
                "uri": "https://linecorp.com"
              }
            },
            {
              "type": "spacer",
              "size": "sm"
            }
          ],
          "flex": 0
        }
      }
    },
    "answerType": "FLEXMESSAGE"
  }
]
字段 类型 是否必需 描述
answerType string true FLEXMESSAGE, means flex message answer
component object true support LINE Flex in the chatbot custom api specification v2

LINE表情包回复

若即时通讯工具为LINE,支持LINE表情包回复。
JSON Structure示例如下。

[
  {
    "component": {
      "type": "line_sticker",
      "data": {
        "packageId": "11537",
        "stickerId": "52002734"
      }
    },
    "answerType": "STICKER"
  }
]
字段 类型 是否必需 描述
answerType string true STICKER, means LINE sticker answer
component object true support Line Sticker in the chatbot custom api specification v2

本文是否有帮助