Using Python & Slack for quick and free personal push notifications
If you’re like me, you often find yourself wanting to send a notification that some running task has completed, or that some process needs attention.
The way I’ve done this for years is to send myself an e-mail. But because I’m a terrible sys admin I find it a pain to get e-mail to reliably send from Python+Ubuntu+some SMTP server. I will never admit how long I’ve spent fighting this battle…
Enter: Slack teams, Python and push notifications.
Here’s how to do it:
Step 1: Set yourself up with a personal Slack team by registering a team of one at slack.com.
Step 2: Get your Slack token here: https://api.slack.com/docs/oauth-test-tokens
Step 3: Install the official Slack Python package:
pip install slackclient
Step 4: Write a little function to send yourself a message:
from slackclient import SlackClientdef slack_message(message, channel):
token = '[YOUR TOKEN]'
sc = SlackClient(token) sc.api_call('chat.postMessage', channel=channel,
text=message, username='My Sweet Bot',
That’s it that’s all! Free, quick and easy native push notifications for your next personal project.