Skip to content

Instantly share code, notes, and snippets.

@RobSpectre
Created May 4, 2015 20:49
Show Gist options
  • Save RobSpectre/01801cf0810250bcd60e to your computer and use it in GitHub Desktop.
Save RobSpectre/01801cf0810250bcd60e to your computer and use it in GitHub Desktop.
Flask app for returning sentiment of text messages with Twilio
from flask import Flask
from flask import request
from twilio import twiml
from textblob import TextBlob
app = Flask(__name__)
@app.route('/sms', methods=['POST'])
def sms():
body = request.form['Body']
blob = TextBlob(body)
response = twiml.Response()
response.message(str(blob.sentiment))
return str(response)
if __name__ == "__main__":
app.debug = True
app.run()
textblob==0.9.0
twilio==4.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment