Open elbination opened 4 years ago
Hi! Ran into the same problem. The problem lies in Heroku. The free version starts two "dynos" with two different sets of memory, that's why you get different results for the same user.
Our workaround was to add a pickle (or you can use any type of persistent memory) that tracks if a dyno messaged the user already.
if os.path.exists('df.pickle'):
with open('df.pickle', 'rb') as x:
df = pickle.load(x)
with open('message.pickle', 'wb') as x:
pickle.dump(message_dict, x, protocol=pickle.HIGHEST_PROTOCOL)
with open('message.pickle', 'rb') as x:
previous_message = pickle.load(x)
check_message = previous_message
Also if I'm not mistaken we found a way to only run one dyno, I think this was the line of code that did that:
app.run(threaded=True)
Hope this helps!
The problem is exactly the same here: https://stackoverflow.com/questions/41601267/facebook-messenger-python-two-different-results-same-user
And I can confirm this comment: "facebook's api posts back the message with the recipientID of the facebook page's ID. I know kinda weird. My guess is that you (user1) populates that list, but somewhere in between (user2 being the facebook page) also contributes to the length of the list.. idk, just a guess. what do you think? try printing out recipient IDs."
I am using Flask and Heroku for webhook server. What should I do?