slack / slackbot / slack incoming-webhooks

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
Posts: 11
Joined: Sun Jan 18, 2015 3:08 pm

slack / slackbot / slack incoming-webhooks

Post by jeffeb3 » Thu Sep 29, 2016 10:04 pm

I want my IoT things to post to a slack channel that I've created for the members of my family. We can all choose our own notification settings, etc. for different parts of the IoT system.

I just wanted to post information into the slack channel, I'm not interested in getting commands from the channel (although there is a really neat library for that here: viewtopic.php?t=2405)

This is what I came up with: ... 4643282533

Code: Select all

def slack_it(msg):
    ''' Send a message to a predefined slack channel.'''
    import urequests

    # Get an "incoming-webhook" URL from your slack account. @see

    headers = {'content-type': 'application/json'}
    data = '{"text":"%s"}' % msg
    resp =, data=data, headers=headers)
    return resp
There's a lot more you can do, and the api docs for slack have some neat examples. This gist should be good enough for you to figure out the more complicated stuff. All for about 300 Bytes

Post Reply