I'm experimenting with Twilio's WhatsApp API with Python but the conditional flow doesn't work. When I enter the word 'office' after getting the response 'What would you like to print?', I don't get the expected response 'Opening...'. I'd require some help regarding this.
from twilio.rest import Client
from flask import Flask, request, redirect
from twilio.twiml.messaging_response import MessagingResponse
app = Flask(__name__)
@app.route("/", methods=['GET', 'POST'])
def wa_print():
"""Respond to incoming messages with a simple text message."""
question = request.values.get('Body')
print(question)
# Start our TwiML response
resp = MessagingResponse()
if (question == 'print'):
resp.message('What would you like to print?')
doc = request.values.get('Body')
if (doc == 'office'):
resp.message('Opening...')
return str(resp)
if __name__ == "__main__":
app.run()