Is it possible to set icon_emoji with the new incoming webhooks?

Viewed 2869

I've been going around in circles and I think icon_emoji is now part of legacy code, but I keep seeing examples of people using icon_emoji floating around.

I have a custom slack app set up, which uses the new blocks etc. I would love to use the icon_emoji but haven't had any luck figuring it out. I've tried using curl as well, and was also unsuccessful there too. The slack docs mention it doesn't work with bot users, but I haven't set one up?

I'm just an emoji girl living in an emoji world, would love to figure this out if possible!

Thanks :)

2 Answers

It's working for me using curl to send to https://hooks.slack.com/services/.... more information at https://api.slack.com/messaging/webhooks

example:

curl -X POST --data-urlencode "payload={\"channel\": \"#test\", \"username\": \"myBot\", \"text\": \"hello\", \"icon_emoji\": \":ghost:\"}" https://hooks.slack.com/services/...

Also the icon may only show up once due to message consolidation. See https://stackoverflow.com/a/42109435/2045153

I executed the exact curl request that @AlphaCactus shared and I'm still yet to see the custom fields--username and icon_emoji-- being set on Slack side. I'm still seeing the default values that are set in App configuration.

Reading the documentation https://api.slack.com/messaging/webhooks, I noticed the following information block:

You cannot override the default channel (chosen by the user who installed your app), username, or icon when you're using Incoming Webhooks to post messages. Instead, these values will always inherit from the associated Slack app configuration.

Therefore, I believe one needs to use chat.postMessage to set these custom fields.

Because I know by experience, that chat.PostMessage sets these custom fields.

Related