Skip to content

Instantly share code, notes, and snippets.

@jeffeb3
Created September 29, 2016 21:48
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffeb3/d6f7b72e3b7da8d10f18254643282533 to your computer and use it in GitHub Desktop.
Save jeffeb3/d6f7b72e3b7da8d10f18254643282533 to your computer and use it in GitHub Desktop.
Post to slack from a MicroPython (esp 8266, version 1.8.4)
def slack_it(msg):
''' Send a message to a predefined slack channel.'''
import urequests
# Get an "incoming-webhook" URL from your slack account. @see https://api.slack.com/incoming-webhooks
URL='https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX'
headers = {'content-type': 'application/json'}
data = '{"text":"%s"}' % msg
resp = urequests.post(URL, data=data, headers=headers)
return resp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment