Marketing
Segments, WhatsApp campaigns, automated journeys and the retention engine, offers and discount codes, and Meta Conversions API tracking.
7 min read
Overview
The marketing module lets brands reach clients on WhatsApp: one-off campaigns to a segment, automated journeys triggered by client behaviour, a daily retention engine for lapsed clients, and offers that apply at checkout. Campaigns and journeys are WhatsApp only today.
Consent: journeys and campaigns skip any client who has refused marketing or transactional messages on that channel (or on "all"). There is no opt-in requirement: a client with no consent row is allowed. If the consent lookup itself fails, everyone is treated as opted out rather than risk spamming. A WhatsApp STOP reply records an opt-out.
Segments
A segment is a saved audience of a brand's clients. The type decides how it is resolved at send time (web/src/lib/marketing/segments.ts):
| Type | Rule |
|---|---|
| VIP | Minimum visits in a day window and/or minimum spend |
| Lapsed | No visit in N days |
| Birthday | Birthday falling in the configured window |
| By service | Has had one of the chosen services |
| RFM | RFM score at or above a minimum |
| Manual | A hand-picked list of clients |
Each type has one rule set; there is no AND/OR builder across types. Segment counts are shown in the dashboard. When creating a campaign, "All active clients with phone" is also available as an audience.
Campaigns
A campaign is a one-time WhatsApp message to a segment.
Flow
- Name the campaign.
- Write the message (a template with
{{client_name}}and{{brand_name}}), optionally with AI-personalised copy per client. - Pick the audience (a segment or all clients with a phone).
- Save, then press Send on the campaigns list.
On send the campaign is claimed atomically (so a double click or second tab cannot send twice), the audience is resolved with the opt-out filter applied, and each client is messaged in turn. Each attempt is recorded in campaign_sends (sent or failed, with the provider message id or error), and the campaign ends with sent and failed counts. A run that dies midway can be re-sent: clients already reached are skipped.
Known gaps:
- No scheduling.
scheduled_atcan be stored, but the form does not set it and no job sends scheduled campaigns. - Free-form text. Campaigns send plain WhatsApp text, which Meta delivers only inside the 24 hour window; a cold audience is not reachable this way. Approved templates are what journeys use.
- No open, click, redemption or revenue reporting exists for campaigns, only sent and failed counts.
Sending requires the marketing.campaigns action permission (default: org owner, brand manager, location manager).
Offers and Discount Codes
Offers (offers table, in Marketing -> Offers and Daily offers) are codes applied at checkout, not tied to a campaign:
- Types: percentage, fixed amount, free service, gift card, referral.
- Limits: minimum spend, total uses, uses per client, valid from and to.
- Scope: weekdays, specific dates, month-end days, and specific services or categories (a scoped offer discounts only matching bill lines). Days are evaluated in IST.
- Auto-apply offers are applied without a code.
- Codes are stored upper-cased; redemptions increment
uses_count.
The AI receptionist can quote and apply offers too. Creating and pausing offers uses the marketing.coupons permission.
Message Templates
Template creation, approval and the variable list are described in Communications. Journeys store a Meta template name per journey (wa_template_name) and the sample copy shown in the dashboard.
Journeys
A journey is one automated message per trigger, per brand. It is not a multi-step workflow: there are no wait steps, conditions or branches. Each brand has at most one journey per trigger, switched on or off in Marketing -> Journeys, with an editable copy and delay.
Triggers
| Trigger | Default delay | Enrolled by |
|---|---|---|
welcome |
0 h | Any online booking (the code comment says first-time clients, but nothing checks that; only the 24 hour duplicate guard applies) |
post_visit |
2 h | An invoice is paid, or a visit is completed |
review_request |
24 h | Same event, carrying the store's Google review link |
win_back |
0 h | Retention engine (below) |
rebook_nudge |
0 h | Retention engine (below) |
birthday |
0 h | Daily job /api/cron/birthdays, on the client's birthday (IST) |
no_show |
1 h | An appointment is marked no-show |
Default journeys are created for a brand the first time the Journeys page loads; existing rows are never overwritten. Default Meta template names are salon_welcome, salon_post_visit, salon_review_request, salon_win_back, salon_rebook_nudge, salon_birthday and salon_no_show.
Enrolment and sending
- A client is enrolled once per journey in any 24 hours.
/api/cron/process-journeysruns every 15 minutes and sends enrolments whose time has come, 50 at a time. A row is leased before sending so overlapping runs cannot double-send.- Each send is cancelled, with the reason stored on the enrolment, when the client opted out, has no phone, WhatsApp is off or unconfigured for the brand, no template name is set, or a review request has no Google review link.
rebook_nudge,win_backandno_showmessages are also cancelled if the client booked or paid after being enrolled.- Sent journeys use the brand's approved Meta template (a template send), with the client name, brand name and a third value for
post_visit(service name) orreview_request(review link).
Review link
Set the brand's Google review link on the Journeys page, and optionally a link per store (Marketing -> Journeys). A store link wins over the brand link. Links must be https. See Reputation.
Retention Engine
/api/cron/retention-nudges runs daily (04:30 UTC) and enrols lapsed clients into the rebook_nudge and win_back journeys when those journeys are on. For each active client with a phone and a last visit (from paid invoices and completed appointments):
| Days since last visit | Action |
|---|---|
| Under 30 | Nothing |
| 30 to 59 | One rebook_nudge per visit cycle |
| 60, 90, 120 | win_back steps 1, 2, 3 (up to three per cycle) |
| Over 365 | Nothing |
A client with an upcoming or recent (within 30 days) booking is skipped, steps are at least 28 days apart, and a cancelled or failed nudge also holds off a retry for 28 days. Managers can enrol one client by hand from the retention screens, with the same 28 day spacing enforced.
Other automated outreach that does not use journeys:
| Job | What it does |
|---|---|
/api/cron/abandoned-bookings (every 15 min) |
Messages online-booking sessions abandoned for 30+ minutes |
/api/cron/reminders/service-recall (daily) |
Rebook nudge when a service's recall_after_days has passed with no visit since |
/api/cron/ai-nps-surveys (every 15 min) |
Post-visit feedback request (see Reputation) |
/api/cron/ai-whitespace-analyzer (weekdays 10:30 IST) |
Flash promo to clients lapsed over 45 days |
/api/cron/ai-pre-arrival-nudge, ai-chat-recovery |
AI add-on offer before a visit, and follow-up of cold AI chats |
Attribution
Booking links carry utm_source, stored on the appointment. The Reputation -> Attribution & ROI report groups bookings and completed-service revenue by source and pairs them with ad spend entered by hand. There is no last-click attribution from campaign or journey messages to bookings.
Meta Conversions API
Server-side conversion tracking for Meta ads, configured in Settings -> Marketing -> Meta Ads (CAPI) with a Pixel / Dataset ID and access token. Kagami sends Lead (new client from online booking, front desk or a first WhatsApp message), Schedule (appointment booked) and Purchase (POS invoice, with its value) with hashed match keys, retries once, and logs every attempt (90 days) on the settings page, which also has a test-event button. Details are in Integrations.
Key Data Entities
- segments - type and filter rules
- campaigns and campaign_sends - a send and its per-client results
- offers - discount code, limits and scope
- journeys - one per brand and trigger: template, delay, on/off
- journey_enrollments - one client's pending or finished message, with status and error
- client_consents - per-channel opt-in or refusal
- meta_capi_events - log of conversion events sent to Meta
Permissions
| Action | org_owner | brand_manager | location_manager | front_desk |
|---|---|---|---|---|
Create and send campaigns (marketing.campaigns) |
Yes | Yes | Yes (default) | No |
Create message templates (marketing.message_templates) |
Yes | Yes | Yes (default) | No |
Create and pause offers (marketing.coupons) |
Yes | Yes | Yes (default) | No |
| Set review links, Meta CAPI | Yes | Yes | Yes | No |
The three action permissions can be changed per role in Settings -> Roles & permissions. Segment and journey permissions were not re-verified.