PirateApp
PirateApp

Reputation: 6230

What is the right way to keep the information between my bot and Facebook consistent?

From what I read in the Facebook Messenger documentation, there are a couple of callbacks that are triggered. The onReceivedAuthentication() as per documentation is called when a person taps on the "Send to Messenger" plugin. I want to save the person's firstName, lastName, picture and gender in my database. What if the person directly searches for our page and starts chatting with it? In that case, the above callback won't be triggered right? What if the user changes their name or picture on Facebook? How do I keep my database consistent with Facebook's data for each user?

Currently, I am updating the person's details in my database everytime the user greets my bot. I don't think that is a good strategy. Any suggestions are appreciated.

Upvotes: 1

Views: 351

Answers (1)

srk_pathan
srk_pathan

Reputation: 396

Just decide particular time limit like 1 hour or 24 hours or 1 week or as per your choice and when you store user's data from facebook by its graph API response,store one more field for that particular time of storing it either by timestamp or date and after that whenever you get message from user just compare that messages' timestamp with that field and if that difference is greater than that decided time limit then update users' data.

you can compare user's current message time as you are getting it in form of timestamp with every message

Hope this help you.

Upvotes: 1

Related Questions