Last active
November 3, 2015 22:56
-
-
Save atbaker/74a54a2331cca23a0d9a to your computer and use it in GitHub Desktop.
A Flask application that supports Twilio webhooks
This file contains 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 | |
from twilio import twiml | |
app = Flask(__name__) | |
@app.route('/voice', methods=['POST']) | |
def incoming_call(): | |
"""Twilio Voice URL - receives incoming calls from Twilio""" | |
# Create a new TwiML response | |
resp = twiml.Response() | |
# <Say> a message to the caller | |
resp.say("Thanks for calling! I got your call because of Twilio's webhook. Goodbye!") | |
# Return the TwiML | |
return str(resp) | |
@app.route('/message', methods=['POST']) | |
def incoming_message(): | |
"""Twilio Messaging URL - receives incoming messages from Twilio""" | |
# Create a new TwiML response | |
resp = twiml.Response() | |
# <Say> a message to the caller | |
resp.message("Thanks for your text! Webhooks are neat :)") | |
# Return the TwiML | |
return str(resp) | |
if __name__ == '__main__': | |
app.run() |
This file contains 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
Flask==0.10.1 | |
twilio==4.9.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment