menduChat / twilio.py
lsacy
test
121a1b0
raw
history blame
592 Bytes
from flask import Flask, request, session
from flask import render_template, redirect, url_for
from twilio.twiml.messaging_response import MessagingResponse
from joy import ask
app = Flask(__name__)
#app.config[‘SECRET_KEY’] = ‘any-random-string’ what is this for?
@app.route('/joy', methods=['POST'])
def joy():
incoming_msg = request.values['Body']
chat_log = session.get('chat_log')
answer, session['chat_log'] = ask(incoming_msg, chat_log)
msg = MessagingResponse()
msg.message(answer)
return str(msg)
if __name__ == '__main__':
app.run(debug=True)