【发布时间】:2021-04-27 18:40:12
【问题描述】:
我想在 whatsapp 上获取一个人的详细信息并将其存储,但它似乎没有按我的意愿工作。它不会在第二个数据到来之前等待用户输入第一个数据。
这是我的models.py:
class student_Account(models.Model):
name = models.CharField(max_length = 30)
place_of_stay = models.CharField(max_length = 30)
def __str__(self):
return self.name
这是我的views.py:
@csrf_exempt
def sms(request):
incoming_msg = request.POST.get('Body', '').lower()
resp = MessagingResponse()
msg = resp.message()
msg1 = resp.message()
if 'hi' in incoming_msg:
reply = ("Hello and welcome to kkk banking system WhatsApp bot!\n\n"
"What would you like to do\n"
"1. Create an accout?\n"
"2. Check your account balance\n")
msg.body(reply)
if incoming_msg == '1':
reply = ("Enter your name")
a = incoming_msg
student.name = a
reply = ("Enter your place of stay")
b = incoming_msg
student.place_of_stay = b
msg.body(reply)
student.save()
reply = ("Your details has been saved!!.")
msg.body(reply)
【问题讨论】:
-
我建议你使用渠道进行实时交流