Best answer

How to show color bar on Slack messages created by Zap

  • 28 June 2021
  • 4 replies
  • 12417 views

I can create a zap to post a message to Slack, but can’t see how to get the coloured bar at the left edge of the slack message (good, warning, danger). Does anyone know if this is possible in Zaps?

icon

Best answer by SamB 18 March 2022, 15:23

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

4 replies

Userlevel 7
Badge +14

Hi @trevski 

Can you post a screenshot to clarify the colored bar you mean in Slack?

You may have to create a custom Slack App: https://api.slack.com/start

NOTE: This is doable via Zaps, but involves the Slack API, which can be used with the Webhooks app: https://zapier.com/apps/webhook/integrations#triggers-and-actions

Screenshot. Slack lets you highlight as standard with red, yellow or green.

Userlevel 7
Badge +14

@trevski 

Yes, that is being done using the Slack API, which offers more advanced formatting options: https://api.slack.com/

Userlevel 7
Badge +11

Hey folks! I just wanted to follow up to further build on Troy’s suggestion here for anyone that might not be very familiar with setting up Slack Apps/webhooks.
 

I wrote up a guide a little while back that has a section which explains how to set up a Slack App which is a good starting point to reference:


One difference from that guide will be the OAuth scope that’s needed when setting up your Slack App. You’ll need to make sure your Slack app has the chat:write OAuth Scope in order to be able to post a message:

68a2c54ad0acd65b331c982e750708c7.png

Another difference is that you’d want to use the Custom Response action event instead of the GET action event that’s mentioned in the guide. This is because you’ll using the chat.postMessage endpoint instead: Slack > Composing your message

Since colour bars can only be added to secondary attachments you’ll need to follow the format outlined by Slack here: Adding secondary attachments

You’ll need to specify the Channel ID which you can find within Slack by clicking on the channel name to bring up the Channel Details. In the pop up window that appears the Channel ID will be listed at the bottom.

Next, you’d take the OAuth token (See guide on How to count reactions in Slack for details on how to generate that) and Channel ID. Then add them into the webhook request, along with the text for the message and set a colour, like so:

6bd02139e728daba0b74e6d833b9aac4.png
This would then post a message to the channel with a green coloured bar like this: 
d18f9f06d3d49431ea736cc6136fd65c.png