Using Python & Slack for quick and free personal push notifications

Matt Harvey
Aug 8, 2016 · 1 min read

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',
icon_emoji=':robot_face:')

That’s it that’s all! Free, quick and easy native push notifications for your next personal project.

Matt Harvey

Written by

Founder of Coastline Automation, using AI to make every car crash-proof.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade