Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# minimal example of linking RiveScript to Twilio (untested)
from flask import Flask, request, redirect
from rivescript import RiveScript
import twilio.twiml
app = Flask(__name__)
bot = RiveScript()
bot.load_directory("brain")
bot.sort_replies()
@app.route("/", methods=['GET', 'POST'])
def reply():
"""Get a reply for the twilio user."""
from_number = request.values.get('From', None)
message = request.values.get('Body', None)
if message:
reply = bot.reply(from_number, message)
resp = twilio.twiml.Response()
resp.message(reply)
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
You can’t perform that action at this time.