Last active
August 29, 2015 14:07
-
-
Save phalt/fcb34611f675d16a63f1 to your computer and use it in GitHub Desktop.
Twilio App Monitor Webhooks part 5
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
| 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