Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use a slack command as a shortcut for multiple commands

Tags:

slack-api

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?

like image 424
Russell Stewart Avatar asked Mar 02 '16 20:03

Russell Stewart


1 Answers

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 :)

like image 165
Wilhelm Klopp Avatar answered Sep 24 '22 02:09

Wilhelm Klopp