DEV Community

Built By AI Lab
Built By AI Lab

Posted on Originally published at bbal-blog.kairo-app.workers.dev

Why my app never sends a WhatsApp message by itself

When a customer cancels, the app prepares a message and a link. The salon owner opens the link, WhatsApp shows the chat with the text already in it, and the owner presses Send. The app has no way to send anything on its own, and that was a design decision before it was a feature.

The rules sit on the server, where the browser cannot argue with them. Every time the owner presses the button, the server loads the offer, the customer and the slot again from the database and checks them. The customer must have agreed to receive messages, and the text and the channel of that agreement are stored. The customer must not have said STOP. The number must not be on the exclusion list. The offer must still be waiting and the slot still free. The phone number and the text come from the database. Whatever the form sends is ignored.

Time and volume have limits as well. Messages can be prepared between 9:00 and 21:00 in Rome. A daily cap applies, set to 20 by default.

Every message ends with a fixed line that carries the salon's name and tells the customer how to stop receiving messages. The owner can edit the text before sending. If the edit removes that line, the server puts it back.

A double click used to be a problem. Two quick requests could pass the "is it still waiting?" check before either one updated the offer, and the owner would have two links for one customer. Now the update itself is conditional, and only the request that really changed the status goes on. The second one is stopped.

A test in the project also fails if any file contains a network request to a messaging provider's API. Automatic sending is excluded from the code and not just switched off in a setting, so a wrong value in a settings page cannot start it.

An owner can move faster with a one-click bulk send. I decided the app would never offer one, because a message sent in the wrong minute to the wrong person cannot be taken back.


Disclosure: drafted with a local AI model, then reviewed and approved by me. Originally published at https://bbal-blog.kairo-app.workers.dev/why-my-app-never-sends-a-whatsapp-message-by-itself/

Top comments (0)