Search code examples
slack-apislack

Can I use @ in a Slack slash command?


I am creating a custom slash command that hooks up to a RESTful API. I am looking to send a user id of the current users choosing, so I'd love to be able to use the @ shortcut to bring up the list of teammates. This API call is expecting a user id and a message. Is something like this possible:

/SLASHCOMMAND @USER, MESSAGE


Solution

  • You can certainly type @whatever into a a slash command, but the text will just be sent as-is to your HTTP endpoint.

    In the example above, you would receive "@USER, MESSAGE" as the text of the slash command. (If you want an ID, you'll then have to do your own parsing to find at-mentions and use the Slack Web API to figure out the ID corresponding to that username.)