Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I trigger a slash command in Slack every day at a certain time

I want to trigger a slash command in Slack every day at a certain time. Specifically, I want to clear my status every night at midnight.

From the documentation it seems like the only way to do this would be via an Incoming Webhook. However POSTing with the following JSON body just creates a message in Slack /status clear and does not actually run the command.

'{"text":"/status clear"}'

It also posts the message on behalf of the app associated with the webhook, not under my username.

Is there any way to invoke a slash command for my user from outside the official Slack app?

like image 481
MattL Avatar asked May 03 '17 14:05

MattL


1 Answers

Here is how to execute slash command for your user with an external script.

  1. Use the undocumented API method chat.command execute any slash command, e.g. /status

  2. Use an access token linked to your user account for the API call. One way to get that is to create a so-called "legacy token" with your user.

like image 92
Erik Kalkoken Avatar answered Sep 21 '22 16:09

Erik Kalkoken