I implemented MessageBird WhatsApp Integration. but my problem is how to build a logic where I can calculate the remaining sms limit and reset it after 24hrs.
total limit is 1000 per day in 24 hrs
if I send 500 sms at 2 pm and the remaining 500 at 5 pm, so next day at 2 pm I will get 500 limits and the remaining 500 at 5pm.
can someone help me to build this logic so that the API can send the accurate remaing limit for sending sms for that time period.
It's really hard to answer to your question without further details about your project's architecture.
Assuming you have means to persist and query your data, you could simply store an entity for each message sent by a user along with a
created_at
timestamp, eg.:Then you could easily query this data and verify the 1000 message limit against the total count of records found for the given
user_id
andcreated_at >= now() - 24h