WhatsApp Messaging & Templates
All WhatsApp goes through wa-hub (triotoonz), plain-text send. The Vedamrita getaseed sender is NOT used by this app.
Sender config
- Shared credentials:
/root/.config/wa-hub.env(WA_HUB_TOKEN,WA_HUB_URL) — edit once, all apps read it. The backend loads it after its local.env. - Per-app brand:
WHATSAPP_BRANDin the backend.env.
Template store (central)
Every message's wording lives in the wa_templates DB table — one row per message type.
This is the single place to change what customers receive. Use {{var}} placeholders.
| key | when it sends | variables |
|---|---|---|
otp |
login OTP to the shopkeeper | greeting, brand, code |
reminder |
manual balance reminder (and auto-reminder job) | name, shop, amount |
udhaar_added |
customer's khata gets a credit (udhaar) entry | name, shop, amount, note, balance |
payment_received |
customer's khata gets a payment entry | name, shop, amount, balance |
welcome |
a customer with a phone is added | name, shop |
- View via API:
GET /api/templates(auth). - Edit (single-owner): update the row directly, e.g.
UPDATE wa_templates SET text='...' WHERE key='reminder';(picked up within ~60s; no restart needed). - Seeds run once (
ON CONFLICT DO NOTHING) sonpm run migratenever clobbers your edits.
Features
- OTP — login, via
otptemplate. - Entry notifications — when an entry is recorded for a customer who has a phone, they get a
WhatsApp (
udhaar_added/payment_received) with the amount and new balance. Fire-and-forget: a WhatsApp failure never blocks or fails the ledger write. Toggle withNOTIFY_ON_ENTRY=false. - Manual reminder —
POST /api/customers/:id/remindsends theremindertemplate with the current balance; logged inreminders. - Auto reminders (opt-in, OFF by default) —
backend/scripts/auto_reminders.jsreminds every customer with a phone + outstanding balance not reminded in the last N days. Enable withAUTO_REMINDERS_ENABLED=true(+AUTO_REMINDER_MIN_DAYS, default 7). Run manually to test:node scripts/auto_reminders.js --force. A disabled systemd timerudhaar-reminders.timeris installed;systemctl enable --now udhaar-reminders.timerto schedule it daily.
Safety notes
- Auto-reminders are OFF by default so real customers are never auto-pinged without an explicit opt-in.
- All sends are rate-paced and failures are swallowed + logged, never user-facing crashes.