Let coworkers know you're busy with Slack
Slack is an awesome messaging app for teams. If you're using it at work, wouldn't it be great to integrate it with Focus so you could let your co-workers know when you were available?
With a little work, we can do just that!
Read on to learn how. The following steps can get a little advanced, so if you need help contact firstname.lastname@example.org.
We'll be using node-slack-cli an open-source project that lets us control Slack from the command line.
/Applications/Utilities/Terminal.app and type:
npm install node-slack-cli -g
This installs the package onto your computer.
Next visit https://api.slack.com/web#auth and under "Authentication" click Create Token next to the team you want to create the token for.
Copy the token for use below.
Tell Slack when you start Focusing
Now you can add the following lines in Preferences > Scripting > Focus
export PATH=$PATH:/usr/local/bin export SLACK_TOKEN="YOUR_TOKEN_GOES_HERE" /usr/local/bin/slack -c general -m "I've started a Focus session" -u YOUR_USERNAME_GOES_HERE
Replace YOUR_TOKEN_GOES_HERE with the token from Slack and YOUR_USERNAME_GOES_HERE with your username.
You can customize the message I've started a Focus session to say whatever you want and change the channel by changing general to whichever channel you want.
These lines, in order, say:
- Let Focus know where the node program lives by adding it's directory to our path
- Setup the Slack token
- Send the command to Slack
That's it. Now you should see something like the following in your Slack channel when you Focus:
Tell Slack when you stop Focusing
To notify a Slack room when you stop Focusing, add the following lines in Preferences > Scripting > Unfocus
export PATH=$PATH:/usr/local/bin export SLACK_TOKEN="YOUR_TOKEN_GOES_HERE" /usr/local/bin/slack -c general -m "I've stopped a Focus session" -u YOUR_USERNAME_GOES_HERE
Replace the same tokens from above, and customize the message and channel if needed.
That's it! Now your coworkers know if it's a good time to bug you or if they should wait until you're done working.
« Back to blog archive