heyoo
heyoo copied to clipboard
Looping old messages ( I am Building a chatbot for Whatsapp)
if i re deploy the bot on heruku, it's looping through the old messages and spamming. PLS HELP TO FIX IT!'
HEREUKU LOGS!
if request.method == 'POST':
body = request.getjson()
print(body)
if body.get("object") and body.get("entry") and body["entry"][0].get("changes") and
body["entry"][0]["changes"][0].get("value").get("messages"):
from = body["entry"][0]["changes"][0]["value"]["messages"][0]["from"]
msg_id = body["entry"][0]["changes"][0]["value"]["messages"][0]["id"]
datetime_str = body["entry"][0]["changes"][0]["value"]["messages"][0]["timestamp"]
msgbody = body["entry"][0]["changes"][0]["value"]["messages"][0].get("text", {}).get("body", "")
name = body["entry"][0]["changes"][0]["value"]["contacts"][0]["profile"]["name"]