Changelog
Changelog
Here you can find updates and improvements to Niwa Ai.
0.13.1062: Customer relationships and automatic booking reminders
This release adds customer records and relationship workflows to Niwa AI. Booking reminders run through connected WhatsApp and email channels without asking customers to confirm attendance. When a customer cancels, Niwa can offer the available appointment to a suitable customer with a future reservation, keeping that reservation until the move is accepted.
Niwa’s Customer relationships page holds each customer’s internal profile, birthday, preferred language, additional fields, dated journal, appointments, messages and earlier-time offers. Staff can append notes and send WhatsApp or email messages. Website and matched private-channel conversations are recorded against the customer. Internal notes are excluded from the customer booking tool.
Automatic booking workflows
With booking enabled, reminders and same-day vacancy offers are enabled by default. Existing contact permission is used; a withdrawn permission or paused customer suppresses proactive delivery. No new consent or attendance-confirmation step is added.
- Reminders: one per appointment start and connected channel, normally 24 hours before. Both email and WhatsApp run when available. A short-notice booking uses two hours before, or halfway from creation to the appointment if booked less than four hours ahead. Reservations retain their existing confirmed status.
- Cancellations: the authenticated customer explicitly requests cancellation through their website session or matched private channel. The tool checks ownership, current start and lifecycle status. It wakes the durable vacancy scanner.
- Vacancy offers: today’s cancelled slot is offered to one confirmed future customer with the same service and practitioner, within the configured time-of-day tolerance. Defaults: next 30 days, 90-minute tolerance, 60-minute notice and a 20-minute offer. Each customer gets at most one such offer per day. Expiration or refusal allows another candidate to be considered.
- Acceptance: only an explicit acceptance moves the existing reservation. A MySQL member lock, transaction, offer row lock, appointment row locks and fresh availability check prevent losing the original appointment when a slot was taken. The move, history entry and Calendar-dispatch outbox commit together. Existing Google Calendar integration updates the booking’s event.
- Check-ins and birthday messages: configurable by the owner, initially off. Check-ins require a recorded completed service and no later active/completed booking. The configured interval also separates successive check-in jobs. Birthday messages need a known MM-DD and use only an explicitly configured gift. Niwa generates wording from recorded facts and the customer’s language, without language-keyword routing.
Tools and identity
Trusted admin chat, Telegram and MCP share crm_workflows_get, crm_workflows_configure, crm_contacts_list, crm_contact_get, crm_contact_update, crm_journal_add, crm_message_send and crm_identity_link. Workflow configuration uses the same operation as the settings form. Journal writes and outbound messages require stable request IDs.
The storefront and private customer-channel agents receive only customer_relationship: list owned bookings/offers, cancel, accept/decline an offer, wake replacement search, record the customer’s own statement, set preferences or link a signed customer token. They cannot browse another customer’s record or choose an outreach recipient. Mutations require a quote from the current customer message; the model interprets intent semantically.
WhatsApp ownership uses the verified inbound full phone number and requires a unique saved match. Group chats, unresolved LIDs and ambiguous numbers do not gain access. Facebook/Instagram identities need a verified owner link or the customer’s signed link. Public comments cannot access booking records. A signed link appears in the owner’s customer record and generated reminders, opening a verified browser session; keep it private to that customer.
Delivery and recovery
The feature reuses the existing Meta durable queue in the crm lane, the native WhatsApp outbox, configured SMTP/FluentSMTP and the WhatsApp Cloud relay. It registers niwa_relationship_tick every minute and a cancellation wake event; both participate in Niwa’s managed background runner. A stopped worker recovers through the next scanner and an expiring queue lease, not only a finally block. Queue ownership expires after 600 seconds. A tick starts at most three jobs and stops starting new work after 45 seconds; one provider/model call may run longer.
Prepared messages and transport selection persist before sending. Gateway IDs and Cloud request IDs remain stable on retries. SMTP has no provider idempotency key, so a killed or failed send is marked uncertain for inspection instead of blindly repeated. Queued/accepted receipts are not delivery confirmation. Workflow settings and each customer record expose pending, failed, skipped and uncertain states. Completed CRM queue records are retained for deduplication and removed with contact deletion.
Cloud WhatsApp outside its customer-service window requires an approved template. Niwa prepares localized numbered templates and submits them through the configured relay; actual Meta approval remains external and is checked by the transport before sending. Existing approved bindings can be supplied. The relay must include numbered-template support and the relationship-workflow flag; deploying only the client cannot update an older central relay. Manual free-form CRM messages still need the reply window; sending a specific approved template uses the dedicated WhatsApp Cloud tool. A template receipt records its name, language and parameters rather than presenting an unsent free-form draft as the sent message.
Verification
tests/relationship-integration.php runs through WP-CLI with temporary MySQL tables, real appointment/store/tool code and isolated AI/email/WhatsApp/Calendar boundaries. It checks ownership, cancellation, candidate selection, acceptance rollback, durable delivery, repeated requests, worker death, templates, pauses and relationship schedules without contacting real customers. tests/meta-whatsapp-cloud.php covers the Cloud provider boundary with HTTP fixtures. Browser checks use the isolated local WordPress fixture for profile/journal/settings persistence, access control and desktop/mobile layout. These checks do not claim delivery to an actual customer or live provider approval.
v4.3.44
- Stability improvements
- Better WooCommerce product understanding
Last updated: October 9, 2026