如何在 Watson Assistant json 响应中使用 output.integration.slack

how to use output.integration.slack in Watson Assistant json response

我使用 Watson Assistant 构建了一个聊天机器人并将其与 Slack 集成。我想使用 JSON 编辑器通过 Watson Dialog 编写 Slack 支持的原生 JSON。 Watson Assistant 的文档说:

output.integrations.slack: any JSON response you want to be included in the attachment field of a response intended for Slack.

(参见 https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-responses-json#dialog-responses-json-user-defined

所以我尝试了这样的事情:

{
  "output": {
    "integrations": {
      "slack": {
        "attachment": {
          "blocks": [
            {
              "text": {
                "text": "Pick a date for the deadline.",
                "type": "mrkdwn"
              },
              "type": "section",
              "accessory": {
                "type": "datepicker",
                "action_id": "datepicker-action",
                "placeholder": {
                  "text": "Select a date",
                  "type": "plain_text",
                  "emoji": true
                },
                "initial_date": "1990-04-28"
              }
            }
          ]
        }
      }
    },
    "generic": [
      {
        "response_type": "text",
        "values": [],
        "selection_policy": "sequential"
      }
    ]
  }
}

附件字段的内容是从 Block Kit Builder(https://api.slack.com/tools/block-kit-builder) 中复制的。 但这似乎行不通。谁能给我一些建议?提前致谢。

Output.integrations 不是首选方式。 请尝试

"output": {
  "generic": [
   {
    "user_defined": {
   //Put here your slack attachment
   },
   "response_type": "user_defined"
  }
]}

通过使用 user_defined,您可以混合使用更多响应,例如文本、图片等。