Skip to content

Instantly share code, notes, and snippets.

@daniel-woods
Last active September 29, 2018 02:40
Show Gist options
  • Select an option

  • Save daniel-woods/bf16265e04bb43cad93450af07e1303d to your computer and use it in GitHub Desktop.

Select an option

Save daniel-woods/bf16265e04bb43cad93450af07e1303d 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
#!/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