Hubot-slack: Bot response does not show bot name or avatar when sending attachments

Created on 3 Sep 2016  路  2Comments  路  Source: slackapi/hubot-slack

  • [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x] I've read and agree to the Code of Conduct.
  • [x] I've searched for any related issues and avoided creating a duplicate issue.

    Description

When sending attachments via msg.send using hubot-slack v4.0.2, the bot does not appear to have the bot's avatar or name, but instead has the default bot avatar and the name "bot". When sending normal messages via msg.send, the bot has the correct avatar and name.

The bot's name can be changed by setting the username parameter on the sent message, but the avatar is still not displayed correctly.

Example code:

module.exports = (robot) ->
    robot.hear /^test attachments$/i, (msg) ->
        attachment = {
            fallback: 'a test attachment',
            title: 'This is a test attachment',
            text: 'This is attachment text.'
        }
        msg.send
            attachments: [attachment]

    robot.hear /^test messages$/i, (msg) ->
        msg.send 'This is a test message.'

Result:
Image of problem

Expected result:

I expected msg.send to not care if I have attachments or not, but instead be able to appear as coming from the bot that is sending the messages like normal.

Most helpful comment

Hey @dodgepong , I think you can accomplish what you'd want by setting as_user to true:

screen shot 2016-09-07 at 10 09 04 am

...from a line in the slack docs:

screen shot 2016-09-07 at 10 09 59 am

I'm unsure why that's not the default, but that did the trick for me!

All 2 comments

Hey @dodgepong , I think you can accomplish what you'd want by setting as_user to true:

screen shot 2016-09-07 at 10 09 04 am

...from a line in the slack docs:

screen shot 2016-09-07 at 10 09 59 am

I'm unsure why that's not the default, but that did the trick for me!

Ah, that did it! Thank you! I missed that part of the docs, and was confused because the old way of sending attachments worked fine. Good to know!

Was this page helpful?
0 / 5 - 0 ratings