Reputation: 1960
My company has recently switched to Slack, and I'm really enjoying it so far. I'm learning about Slack Custom commands, and I would like to try writing a few.
One of the first ideas I had was to create a shortcut for going away -- either for lunch, or for a short break. When I go to lunch, I set my status as "Away" with the /away
command, and snooze notifications with /dnd 1 hour
. It would be nice if I could create a custom Slack command, called /lunch
that does both of these things, and another one called /back
that switches back to Online and not Snoozed.
All of the documentation for Custom Commands is oriented towards interfacing with an external API, but is there a way to write a custom command that triggers actions within Slack itself? Would this require using the Slack API?
Upvotes: 7
Views: 2655
Reputation: 5460
Yes, you would have to use the Slack API. But that's fine, because it's really fun to use :)
You can programmatically set your away
preference with this method:
https://api.slack.com/methods/users.setPresence
And you can set your do not disturb
duration with this one:
https://api.slack.com/methods/dnd.setSnooze
The guide for getting started with a custom integration is here.
Hope this helps :)
Upvotes: 3