Hi @dag07121991. The webhook split and the narrow tools above are the right base. Before you put this on a live number, I would close one hole that structure still leaves open: the same appointment can be created twice, and nothing in the flow would tell you.
It happens in three ordinary places.
One is Meta. If Workflow A is slow to answer, the webhook is redelivered with the same message id. Deduping on the id covers that, but only if the dedupe write lands before the agent starts working. If you check the Data Table and then insert, two deliveries that arrive 200ms apart can both pass the check. Insert first and decide after: upsert on message_id, and let the unique constraint pick the one that continues.
Second is the tool call itself. Your create_booking request times out at 30 seconds. Altegio may already have written the record. The agent sees a failure, retries, and you now have two bookings for one customer. Retrying a POST because you did not get a response is the same as booking twice.
Third is two customers, same slot. Both ask for 14:00 with the same staff member, get_free_slots shows it open to both, both agents write. A re-check right before the write narrows that window but does not close it. What closes it is the database, not the model.
The version I would ship is a two-phase booking with a key the model cannot invent:
// Code node, before the HTTP Request that creates the record
const { client_key, staff_id, service_id, datetime } = $json;
const booking_key = [client_key, staff_id, service_id, datetime]
.map(v => String(v).trim())
.join('|');
return [{ json: { ...$json, booking_key } }];
// Data Table: unique index on booking_key where status in ('pending','confirmed')
Write the row as pending with that key before you call Altegio. If the insert conflicts, the booking already exists, so the agent reads the existing record and tells the customer what it finds instead of trying again. After Altegio returns an id, flip the row to confirmed. If the call fails, the row stays pending and a scheduled sweep retries once with the same key, which is safe precisely because the key is the same.
Then the part that bites about a week after launch: the WhatsApp Cloud API only allows free-form messages inside the 24-hour window that opens when the customer writes to you. The “you are booked for 10:00 tomorrow” reminder lands outside it, so it needs an approved template, or it silently fails. Instagram has its own window. Plan that leg with the booking, not after.
Last one, and it is cheap: keep the model out of the state transitions. Four states (browsing, slot_offered, details_collected, confirmed) and a Code node that rejects a move unless the fields it needs are present. The model fills slots; it does not get to decide when a booking is done.
meta webhook
-> respond 200 -> upsert message_id (unique) -> queue
-> agent tool: get_services / get_free_slots (read only)
-> agent tool: reserve -> insert pending row (unique booking_key)
-> POST book_record -> status=confirmed
-> sweep (every 15m): pending older than 5m -> retry once, same key
Disclosure: I work with Pond AI. We build, run and maintain custom agents like this one, map the architecture for free before anything is committed and you keep that map either way, and a custom build carries a 7-day refund.
Are your reminders going out as templates already, or are you expecting to reply inside the window?