Skip to content

Instantly share code, notes, and snippets.

@phalt
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save phalt/fcb34611f675d16a63f1 to your computer and use it in GitHub Desktop.

Select an option

Save phalt/fcb34611f675d16a63f1 to your computer and use it in GitHub Desktop.
Twilio App Monitor Webhooks part 5
from flask import Flask, request
app = Flask(__name__)
from twilio.rest import TwilioRestClient
client = TwilioRestClient()
@app.route('/error_trigger', methods=['POST'])
def error_triggers():
error_code = request.values.get('ErrorCode', None)
description = request.values.get('Description', None)
if error_code:
msg = 'An error on Twilio occurred! ' + description
doc_url = ' https://twilio.com/docs/errors/' + error_code
msg += doc_url
client.messages.create(
to='YOUR_NUMBER',
from_='TWILIO_NUMBER',
body=msg
)
return msg
if __name__ == "__main__":
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment