Slack Incoming Web Hooks - Send message @channel

Viewed 13317

I am working with Slack API recently and my motive is to send a channel wide message at a certain time by calling a web hook provided by Slack Incoming Web hooks.

I created a web hook and got 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 cannot notify all in the team by just sending @channel in the message as like we do in normal slack channel chat. If i send @channel in the curl message, it shows as text message in chat, and not as @channel link.

I even tried sending slack channel id <#G5CERWGRG|hep_test>, as shown in the above curl request. But the message posted isn't notifying all in the group.

Note : I want to keep my channel notification preference as it is (Notify only on mentions)

Note

4 Answers

For anyone else struggling to get this working, if you are using blocks, it looks like you need to have the <!channel> in the block content, and not in the text content.

The text key shows up in the notification and doesn't allow formatting, while the blocks do.

You can use "link_names": True in your payload and use @name :

    slack_data = {
                'text': 'Hi @user, this is for you',
                "icon_emoji": self._icon,
                "username": sender,
                "link_names": True
                }
Related