Zedkay22 Zedkay22 - 23 days ago 10
MySQL Question

Messenger bot - timed responses

I've built a basic facebook messenger bot with PHP. How do I enable timed push notifications?

For example, here's an appointment booking scenario:


  1. User schedules a meeting for 2pm on Friday

  2. Bot remembers the timed information and at 1:45pm on Friday, the bot sends a message reminding the user of the appointment.



I understand that there's gotta be a database involved, but I'm wondering if someone could point me in the right direction to what functions to use or if there are any docs for this time related pushes with php.

*Note: I'm not looking for free code, but rather a point in the right direction for how to achieve the above.

Answer

This is a broad question and has little to do with bots themselves. Think of bot as only a communication protocol between your server and user. As you've mentioned, store user ids/meeting times in a database.

Then have a cron running, calling a link on yuour server which check the appropriate whether should a user be sent a notification now. Then send him a message and mark this action in a database, so it is not handled twice.