Skip to content

Instantly share code, notes, and snippets.

@LewisLebentz LewisLebentz/
Last active Jan 29, 2017

What would you like to do?
#!/usr/bin/env python
import json
from urllib2 import Request, urlopen
def post(event, context):
V2TOKEN = 'enter_token_here'
ROOMID = enter_room_id_here
# API V2, send message to room:
url = '' % ROOMID
message = "Write your message here"
headers = {
"content-type": "application/json",
"authorization": "Bearer %s" % V2TOKEN}
datastr = json.dumps({
'message': message,
'color': 'purple',
'message_format': 'html',
'notify': False,
'from': 'Lambda'})
request = Request(url, headers=headers, data=datastr)
uo = urlopen(request)
rawresponse = ''.join(uo)
assert uo.code == 204
return "Success"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.