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:

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.
Hey @dodgepong , I think you can accomplish what you'd want by setting as_user to true:

...from a line in the slack docs:

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!
Most helpful comment
Hey @dodgepong , I think you can accomplish what you'd want by setting as_user to true:
...from a line in the slack docs:
I'm unsure why that's not the default, but that did the trick for me!