Created
April 24, 2019 01:03
-
-
Save jaxatax/a390d36eca16767207b5c92bb1863160 to your computer and use it in GitHub Desktop.
Getting the value of the message with Twilio and PythonAnywhere.
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, request, redirect | |
from twilio.twiml.messaging_response import MessagingResponse | |
app = Flask(__name__) | |
@app.route("/sms", methods=['GET', 'POST']) | |
def incoming_sms(): | |
"""Send a dynamic reply to an incoming text message""" | |
# Get the message the user sent our Twilio number | |
body = request.values.get('Body', None) | |
# Start our TwiML response | |
resp = MessagingResponse() | |
# Determine the right reply for this message | |
if body == 'hello': | |
resp.message("Hi!") | |
elif body == 'bye': | |
resp.message("Goodbye") | |
return str(resp) | |
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