Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I notify users on Slack that aren't in the channel?

What we are trying to do

I am working on automation which posts messages to a Slack channel using Incoming Webhooks on a custom Slack App. The messages mentions people.

What works

We can send a message just fine, it has formatted content, and usernames are correctly resolved using the link-names flag.

a successful message being posted and tagging people

What isn't working

The whole point of the notification is to inform a dynamic set of people about something they should care about. The set of people we tag varies hugely (think people who contributed to a pull request) and so not all possible recipients are in the channel these automated messages go to.

We assumed that given the usernames are being directly @-mentioned, they would be notified by Slack. However, two of the users we've tested with and @-mentioned confirm they never received a notification they had been tagged.

This is different to "human" behaviour, where if you @-mention someone in Slack, you get a little message reminding you that person isn't in this channel and offers to invite them or let them know.

example of mentioning a user who isn't in a channel

As far as we can tell, sending the message programmatically is doing the equivalent of "Do nothing" in the picture above. I want to do either of the other two options, preferably "Let them know".

How can I notify people they've been mentioned? I've looked at all the API documentation and nothing discusses notifying users who aren't in the channel that they are mentioned.

This can't be an uncommon issue.... right?

Notes:

  • We aren't directly calling chat.postMessage, it's just the only documentation on link_names I could find to link to. We are using Incoming Webhooks, which has minimal documentation on the parameters - it seems to be the same as chat.postMessage.
  • We would prefer not to move off Incoming Webhooks, but we can do a custom integration with the API if we have to.
like image 467
hanzworld Avatar asked Nov 07 '22 05:11

hanzworld


People also ask

Can you message someone outside your organization on Slack?

Slack Connect allows you to work with people outside your company in channels and direct messages (DMs). By moving conversations out of emails, you can work securely and collaboratively with partners, vendors, or customers. Read on for an overview of Slack Connect.

How do I notify everyone in a private Slack channel?

Use @channel to let everyone in a channel know about timely, relevant information. This will trigger a desktop or mobile notification for all members of the channel, whether their availability is set to active or away.

How do I notify everyone in a channel?

Type: @general to message everyone in the general channel. @team to notify everyone on that team. @channel to message everyone in that channel.


1 Answers

You need to invite the user to the channel first, using the Python client that's:

client.channels_invite(
    channel=channel_id,
    user=user_id
)
like image 104
Jake Dale Avatar answered Nov 15 '22 07:11

Jake Dale