jsonintegrationslackibm-watsonwatson-assistant

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


I build a chatbot with Watson Assistant and integrate it with Slack. I want to write Native JSON supported by Slack through Watson Dialog using JSON Editor. The doc of Watson Assistant says:

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

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

So I tried sth like this:

{
  "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"
      }
    ]
  }
}

The content of the attachment field is copied from the Block Kit Builer(https://api.slack.com/tools/block-kit-builder). But this seems not work. Can anyone give me some suggestions? Thanks in advance.


Solution

  • Output.integrations is not a preferred way. Pls try

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

    By using user_defined you can mix with it more responses like text, image, etc.