Mattermost, Inc.

Slash command attachment not working

Hello,

I’m using slash commands to create a BOT, but I can’t seem to get the attachments working.
As response I have this json string:

{
   "response_type": "in_channel",
   "text": "Test",
   "attachments": [
        {
            "image_url": "http://url.to/my_image.png"
        }
    ]
}

But only the text “Test” is appearing in the channel, but everything inside the “attachments” is not.
While for the mattermost_bot this does work.

What could be wrong?

Did you come to any conclusions with this? I am noticing exactly the same thing.
What do you mean when you differentiate “BOT” from “mattermost_bot”? To what are you referring? (I’m new to Mattermost.)

My impression is that the Mattermost guys are following the Slack message syntax to the letter. So, I found the following page: https://api.slack.com/docs/formatting.
It contains plenty of examples and also a format builder.

I tested my message there and it worked out great.
Also, here I found the following complex example:

{
  "attachments": [
    {
      "fallback": "test",
      "color": "#FF8000",
      "pretext": "This is optional pretext that shows above the attachment.",
      "text": "This is the text of the attachment. It should appear just above an image of the Mattermost logo. The left border of the attachment should be colored orange, and below the image it should include additional fields that are formatted in columns. At the top of the attachment, there should be an author name followed by a bolded title. Both the author name and the title should be hyperlinks.",
      "author_name": "Mattermost",
      "author_icon": "http://www.mattermost.org/wp-content/uploads/2016/04/icon_WS.png",
      "author_link": "http://www.mattermost.org/",
      "title": "Example Attachment",
      "title_link": "http://docs.mattermost.com/developer/message-attachments.html",
      "fields": [
        {
          "short": false,
          "title":"Long Field",
          "value":"Testing with a very long piece of text that will take up the whole width of the table. And then some more text to make it extra long."
        },
        {
          "short":true,
          "title":"Column One",
          "value":"Testing"
        },
        {
          "short":true,
          "title":"Column Two",
          "value":"Testing"
        },
        {
        "short":false,
        "title":"Another Field",
        "value":"Testing"
        }
      ],
      "image_url": "http://www.mattermost.org/wp-content/uploads/2016/03/logoHorizontal_WS.png"
    }
  ]
}

This example renders perfectly on the above mentioned message builder (on the Slack web page). However, when I try to let my webhook return that very message, I get literally nothing at all from Mattermost.

Oh and I have enabled ( = allow) pretty much all security related features in the system console that could be blocking this from happening. I have also enabled logging and do not see a single error during these calls.

I have tested versions 3.0.2 and 3.0.3.
To me this seems like a bug - or is there some more feature I need to enable to get this working?

Hi martinr,

We don’t currently support Slack attachments when using Slash Commands. They’re only supported with incoming webhooks right now. We want to be compatible with Slack wherever possible though, so I’ve created a ticket to look into adding this.