Forked from daniel-woods/sns_lambda_teams_webhook.py
Created
September 29, 2018 02:40
-
-
Save vvalorous/a84c0bf7f9bf732db5a84cda8fc110f6 to your computer and use it in GitHub Desktop.
Use a Webhook to send a message to a Microsoft Teams channel using Connectors/Incoming Webhook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# https://gist.github.com/daniel-woods | |
# Use a Webhook to send a message to a Microsoft Teams channel using Connectors/Incoming Webhook | |
import json | |
from urllib2 import urlopen, HTTPError, Request | |
def post_message(url, data): | |
req = Request(url, data) | |
f = urlopen(req) | |
f.close() | |
def lambda_handler(event, context): | |
# Webhook URL, get this from Connectors/Incoming Webhook. | |
url = "https://outlook.office.com/webhook/xxxx/IncomingWebhook/xxxx/xxxx" | |
msg = { | |
"text": event['Records'][0]['Sns']['Message'] | |
} | |
# Send the Message | |
post_message(url, json.dumps(msg)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment