dimanche 27 septembre 2020

IF statement acting weird in twilio texting project

I am trying to create a texting project where I can text a twilio number, and based off what the message is I can reply with a custom message. I am using a string of if statements to check the body of the text and reply with certain things

app = Flask(__name__)

@app.route("/sms", methods=['GET', 'POST'])

def sms_reply():
  reply_pointer = 0
  body = request.values.get('Body', None)
  resp = MessagingResponse()

  print(body)

  if(body == "Test1"): reply_pointer = 0
  elif(body == "Test2"): reply_pointer = 1
  elif(body == "Test3"): reply_pointer = 2
  elif(body == "Test4"): reply_pointer = 3


  print(reply_pointer)

I am texting these messages from my phone and if I send Test1 through Test3 I get normal results, but when I text Test4, reply_pointer gets set to 0 and it stays 0 if I text Test1, Test2, etc. I've been trying to fix this for so long and I have no idea whats going on.

Aucun commentaire:

Enregistrer un commentaire