Slack Incoming Web Hooks - Send a message to @channel

I recently work with the Slack API and my motive is to send a channel message at a specific time by triggering a webhook provided by the Slack Incoming Web hosts.

I created a webhook and got the code from Slack as below

curl -X POST -H 'Content-type: application/json' --data '{"text":"Hey, Its time for meeting!! <#G5CERWGRG|hep_test>", "link_names" : 1}' HOOK_URL

      

But I can't notify everyone on the team just by sending @channel in a message the same way we do in regular slack-channel chat. If I post @channel in a curl post, it shows up as a text message in the chat, not as a @channel link.

I even tried sending the slack channel id <# G5CERWGRG | hep_test> as shown in the above curl request. But the message sent doesn't notify everyone in the group.

Note. I want to keep the channel notification preference as is (notify for mentions only)

Note

+3


source to share


1 answer


The correct syntax for sending @channel messages is <!channel>

.

So the correct curl command for your example should look like this:

curl -X POST -H 'Content-type: application/json' --data '{"text":"Hey, Its time for meeting!! <!channel>", "link_names" : 1}' HOOK_URL

      



See also here for reference in the official documentation. You can also try this in the post builder .

Note that in order to overwrite the default channel for your web hop, you also need to add an additional property channel

with the channel name. However, this will only work for websites created using custom integrations, not for web moves created by Slack apps.

See here for an example on how to overwrite the channel name.

+6


source







All Articles