watson-developer-cloud / botkit-middleware

A middleware to connect Watson Conversation Service to different chat channels using Botkit
https://www.npmjs.com/package/botkit-middleware-watson
Apache License 2.0
206 stars 254 forks source link

Text formatting for slack #79

Closed richielo closed 7 years ago

richielo commented 7 years ago

Is there a way to do formatting when I reply the message to slack? I just want to output a JSON array as a list. I tried things as simple as newline (\n, \n\n). But it doesn't seem to reflect on the slack side....

Thank you very much for your help.

mitchmason commented 7 years ago

https://get.slack.help/hc/en-us/articles/202288908-Format-your-messages check out the text formatting from slack above

richielo commented 7 years ago

Thank you for your response. But it doesn't seem to cover how to do that for bot tho..newline didn't work when I use \n...

mitchmason commented 7 years ago

They included a link specifically for bot messages on that page, direct link here: https://api.slack.com/docs/message-formatting but what you should also double check is to make sure Watson is not removing them, in which case you would want to escape them using / character. You should call the Conversation API directly and see what you get back. That is exactly what is sent to slack, that should at least isolate where the problem is occuring, Watson side or Slack side.

germanattanasio commented 7 years ago

Hey @richielo you need to escape your response to Slack. I think you already did because this is a very old issue. Feel free to open this if you were not able to fix it.

rodalton commented 5 years ago

To include a new line in a response from WA in Slack, you'll need to include the newline character in the text response as defined in the JSON editor i.e. in the WA Dialog, open the JSON editor for the particular node and include the \n as shown in the example below

{
  "output": {
    "generic": [
      {
        "values": [
          {
            "text": "Hi there, how can I help today? :sunglasses: \nAlso saying Hi on a new line, just because I can :thumbsup:"
          }
        ],
        "response_type": "text",
        "selection_policy": "sequential"
      }
    ]
  }
}