Skip to content

Instantly share code, notes, and snippets.

@jaxatax
Forked from topherPedersen/chatbot.py
Created April 24, 2019 00:37
Show Gist options
  • Save jaxatax/580f2d11107cdfafe79428acfc04f86f to your computer and use it in GitHub Desktop.
Save jaxatax/580f2d11107cdfafe79428acfc04f86f to your computer and use it in GitHub Desktop.
Twilio Chatbook with Python & Flask
from flask import Flask
from twilio.twiml.messaging_response import MessagingResponse
import random
app = Flask(__name__)
@app.route("/", methods=['GET', 'POST'])
def sms_reply():
"""Respond to incoming calls with a simple text message."""
# Start our TwiML response
resp = MessagingResponse()
# random message
random_message = []
random_message.append('Who is this?')
random_message.append('What was your best-case scenario for sending this message?')
random_message.append('Tell me more about that.')
random_message.append('brb')
random_message.append('wat?')
random_message.append('lol')
random_message.append('idk?')
random_message.append('no')
random_message.append('yes!')
random_message.append('I understand.')
random_message.append('fo sho')
random_message.append('I gotta go...')
random_message.append('So what you\'re saying is, I need to step up my emoji game? I agree.')
random_number = random.randint(0, 12)
# Add a message
# resp.message("The Robots are coming! Head for the hills!")
resp.message(random_message[random_number])
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