Search code examples
c#slackslack-api

Slack message integration with c#


Is it possible in SLACK to be integrated to a C# Web API and send a direct message to a every user? I know webhook is needed for it to send a direct message. The problem will be webhooks are different for every user.


Solution

  • This does not work well with the standard incoming webhook, since you will need to create a webhook for each user (as you stated).

    Alternatively you can use the legacy version of the incoming webhook, which allows you to override the channel and which you can install from the app store. However, this is not recommended since its legacy: Sending message to different channel via slack webhook fails

    However, the recommended approach is use the Web API method for sending messages to multiple channels / users: chat.postmessage.

    Note that there is no method for bulk sending direct messages to multiple or even all users. The standard approach to reach all users is to send a message in the announcement channel or by adding <!everyone> to your message: Correct approach to DM many users using Web API

    That message would be public though. If you really want to send a direct message to every user you can do so by iterating through the list of all users and send each of them a direct message via API methods: Slack Send Direct Message to ALL on SLACK