How can I program my bot to send a message on a sp...
# 🤝help
l
Hello everyone, I'm currently in the process of developing a bot for WhatsApp and I've run into a specific challenge. At the beginning of the conversation, the user will provide my bot with a certain date. I would like for my bot to then send them a specific message on that exact date.I wonder if anyone has any insight into how to structure this system, or if anyone has set up something similar before and would be willing to share their experience. Thanks !
Hello, does anyone have any ideas or potential leads to explore ?
f
Yes, this could be possible using states and recurring events on the bot. There isn't a specific tutorial for using these yet but we have some details about these in the REST API docs: https://docs.botpress.cloud/docs/api-documentation/#bot
l
Thanks ! Would it be possible to do it with the feature "trigger" ?
f
Yes, but you'd need to keep track of schedule messages outside of the bot with your own API/service. Also, triggers is currently on Beta and there are still a few more feature that we need to add to them before they're official.
Easiest way would probably be storing "scheduled" messages in the bot's state using the State APIs, and setup a recurring event in the bot that iterates over the scheduled messages in the states to see which ones need to be sent, and then updates the state to remove the ones already sent.
However, this will only work if your use case only requires a small amount of scheduled messages at a given time, as there are some quotas in place as to how may state items can a bot have. If you need an unlimited amount of scheduled messages, you could store them in a serverless Redis database such as Upstash (https://upstash.com/) and then retrieve/update them from the recurring bot event.
154 Views