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

不羁的心 提交于 2020-01-13 20:35:05

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/43762414/how-can-i-trigger-a-slash-command-in-slack-every-day-at-a-certain-time

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!