Search code examples
slackslack-api

Difference between Sash Command and Out going webhook


I know following about slack slash commands and out going webhooks

1) Slash Commands: - When user types slash command, it Will trigger external URL (URL of external web service), with all required data and message - Web service would process that as required, and would respond with HTTP Response.

2) Outgoing webhook: - When user sends message with triggering words(optional) in specified channel, it will trigger external URL (URL of external web service), with all required data and message - Web service would process that as required, and would respond with HTTP Response

Purpose of both these functionalities is same. Only difference I can see is - with slash command, there is no way to define triggering criteria. If this command is used, external URL is called irrespective of channel and words in the message. While with outgoing webhook, we can apply filters(matching criteria) to call external URL conditionally, whenever criteria matches.

Is there any other difference? When should we use slash command over outgoing webhook and vice versa?

I want to listen to a particular channel, and sends its data to google sheet when they type "OOO, away, late". I can create 3 slash commands or can create a outgoing webhook for these three triggering words for this channel. What is the best approach to accomplish this? I think I should go with out going webhook, considering its capability of matching criteria.


Solution

  • The main difference is how they are triggered.

    A slash command is only triggered when a user enters its specific command into a channel, e.g. /who to see members of a channel.

    The outgoing webhook automatically sends all message of a channel to a web service or all messages that include a specific trigger word.

    However, I would strongly recommend to use Slack events instead of outgoing webhooks for your use case, since the latter is marked as legacy integration. Also events are way more powerful, e.g. they also work in private channels.