Skip to content

Instantly share code, notes, and snippets.



Created Jul 17, 2017
What would you like to do?
Google App Engine ADT Pulse alert email to IFTT webhook adapter
import logging
import re
# Receives alert emails from ADT Pulse and expects them to have
# an extra text of the form 'action=YOUR_ACTION' in the body.
# Calls IFTT with your key and the given action to trigger a webhook.
from google.appengine.ext.webapp.mail_handlers import InboundMailHandler
from google.appengine.api import urlfetch
import webapp2
class LogSenderHandler(InboundMailHandler):
def receive(self, mail_message):"Received a message from: " + mail_message.sender)
ok_sender = re.compile('adtpulse\.com|YOUR_TEST_EMAIL', re.IGNORECASE)
if not"Skipping message: " + mail_message.sender)
action = re.compile('action=(\w+)')
plaintext_bodies = mail_message.bodies('text/plain')
for content_type, body in plaintext_bodies:
plaintext = body.decode()"Plain text body of length %d.", len(plaintext))
m =
if m:
action =;"Action %s.", action)
url = "" + action + "/with/key/YOUR_KEY""URL %s.", url)
result = urlfetch.fetch(
if result.status_code == 200:"IFTT is happy: %s", result.content)
else:"IFTT status: %s", result.status_code)"IFTT response: %s", result.content)
app = webapp2.WSGIApplication([LogSenderHandler.mapping()], debug=True)
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.