What this is

Karen runs Oshun's front office

Patients message on WhatsApp, Instagram, the website, or call the clinic. Karen replies, books appointments, sends pre-care and post-care follow-ups, chases payments, and posts to social media — automatically, 24/7.

Who this page is for

Matthew, Dr. Rockhead, or staff

If you want to see the moving parts, change Karen's behavior, add a procedure, or understand why something happened — this is the map. No coding required to read it; editing some things does need Matthew.

How to read this page

Two sections, top to bottom

System Layers (below) = the parts of the machine. The 10 Journeys = what happens for a patient or a campaign, step by step. Click any tab to expand.

The Big Picture

How a message moves through Oshun's system, left to right.

Patient or Lead WhatsApp Instagram Website widget Phone call Email Karen AI reads history + memory, decides, takes action Book on Cal.com Send pre/post care Chase payment Post to social Alert staff Memory & Database every word saved

A patient message lands on any channel → Karen reads context and decides → she takes an action → everything is saved to memory. You can intervene at any point via Telegram.

Want to change something?

Most common adjustments and who owns them.

1

Change what Karen says

Tone, phrasing, pricing answers, booking hours, procedure descriptions.

How: tell Karen in Telegram — "Karen, update your pricing for Botox to $X." She stores it in memory immediately. No deploy needed.

Owner: Matthew or Dr. Rockhead via Telegram

2

Change a care plan or procedure flow

Add a new pre-care guide, adjust the 24h/1-week/4-week check-in timing, change the review request wording.

How: edit the care-plan JSON for that procedure (Matthew handles). Ask Karen in Telegram to show the current plan first.

Owner: Matthew (code) · approved by Dr. Rockhead

3

Add a new service or channel

New procedure type, new phone line, new Instagram account, new email list.

How: channel/integration changes are a config + deploy job. See the matching layer below — each panel shows the file that controls it.

Owner: Matthew

4

Pause, stop, or escalate something

Stop a campaign mid-send, pause Karen for one patient, escalate a complaint to Dr. Rockhead.

How: ask Karen in Telegram. Examples: "Karen, pause the broadcast." / "Karen, hand off the Jane Smith conversation to Dr. Rockhead."

Owner: anyone with Telegram access

The System, Layer by Layer

Each layer is a part of the machine. Click a tab to see what it does and which file controls it.

Channels

Messages arrive via WhatsApp Business API, routed through Chatwoot to Karen AI.

Oshun's primary patient channel. Phone: 18766766297. ~14s response time.

Chatwoot component →

Instagram DMs routed through Chatwoot to Karen AI.

Connected via Chatwoot Cloud account 156369. Karen replies in ~14 seconds.

Chatwoot component →

Operator control channel for Matthew and Dr. Rockhead — not patients.

Content approval, alerts, procedure marking, billing control, system commands.

Telegram component →

Inbound calls to (876) 676-6297 hit Twilio SIP trunk → ElevenLabs voice agent.

Patients talk to Karen — real-time voice AI. Books appointments, answers questions, escalates.

Voice / Twilio component →

Bulk campaigns via Listmonk. 5K email list + 43K phone contacts.

SMTP: karen@oshunja.com. 6 HTML templates. Campaign 1 sent, 2 & 3 in draft.

Listmonk component →

Website chat widget powered by Chatwoot.

Embedded on oshunja.com. Conversations thread with WhatsApp/IG — same contact, same history.

Chatwoot component →
Routing

Omnichannel inbox — WhatsApp, Instagram, website widget all funnel here.

Cloud account 156369. Manages conversation threading, contact merging, webhook dispatch to Karen AI. Also serves as CRM.

src/webhooks/chatwoot.jsregisterChatwootRoutes()
Full details →

Bot wiring — slash commands, inline buttons, media handling.

Handles operator messages, dispatches to AI or direct action handlers. 7 domain handler files in telegram_actions/.

src/telegram.jsstartTelegramBot()
Full details →

SIP trunk routing inbound calls to ElevenLabs voice agent.

Twilio handles phone infrastructure. ElevenLabs provides real-time TTS/STT. Karen's brain processes the conversation.

src/webhooks/voice.js → voice routes
Full details →

Self-hosted email marketing — campaigns, subscriber lists, delivery analytics.

SMTP via oshunja.com or Gmail fallback. Handles unsubscribes automatically. Data sovereignty — no third-party routing.

src/consolidator_briefings.js
Full details →
Brain

The central intelligence — orchestrates all conversations across every channel.

OpenRouter for chat, Gemini for cheaper tasks. Forward-Thinking Protocol: acknowledge → connect to goals → actionable next step. Action tag system dispatches real actions.

src/ai.jschat() (line 125)
Full details →

pgvector semantic search + knowledge storage. Karen remembers everything.

Hybrid search: vector similarity + full-text + tags + exact match, combined via RRF fusion. Per-turn consolidation extracts facts automatically.

src/memory.jshybridSearch() (line 125)
Full details →

Gathers everything Karen needs to respond — history, contact profile, relevant knowledge.

Queries: recent conversations, contact preferences, memory knowledge, tenant persona, core memory sections.

src/context-builder.jsbuildContext() (line 20)
Full details →

Assembles the system prompt with persona, available actions, and protocol instructions.

selectActionsForContext() filters which actions Karen can take based on channel and tenant tier. Bakes in Forward-Thinking Protocol.

src/prompt-builder.jsbuildDefaultPrompt() (line 217)
Full details →
Actions

Cal.com appointment booking with webhook-driven lifecycle.

Patients book at cosmetic.oshunja.com/booking. Webhooks trigger care plans — pre-care, reminders, post-care all start from a booking.

src/actions/calendar.js
Full details →

Automated pre-care and post-care sequences for every procedure.

6 pre-care guides approved (Laser, Botox, Fillers, Weight Loss, Lipo, PRP). Check-ins at 24h, 1 week, 4 weeks. Escalation on patient concerns.

src/actions/care/plans.jsstartCarePlan()
Full details →

Daily AI content generation → Telegram approval → multi-platform posting.

7 AM EST daily pipeline. Brand-aware generation. Blotato publishes to IG, FB, YT. Engagement scoring feeds next cycle.

src/consolidator_content.jsrunDailyContentPipeline()
Full details →

PayPal integration with 6-hop payment state machine.

awaiting → grace → staff_prompted → patient_prompted → at_risk → reconciliation → complete. 10% commission tracking. Escalation: day 3/7/14/30.

src/webhooks/billing.jsregisterBillingRoutes()
Full details →

Blotato API — multi-platform publishing to Instagram, Facebook, YouTube.

Handles caption formatting per platform, image upload, scheduling. Distribution layer for content engine output.

src/actions/blotato/publish.js
Full details →

ElevenLabs real-time voice AI — patients call and talk to Karen.

Same AI brain as chat but voice-optimized prompt. Books appointments, escalates complex questions to staff via Telegram.

src/webhooks/voice.jshandleElevenLabsTool()
Full details →

Automated lead nurture and re-engagement sequences.

5-touch warm lead sequence over 14 days. No-show recovery. Lapsed patient outreach. Auto-cancels if lead books. Preference learning adapts messaging.

src/nurture.jsenrollContact()
Full details →
Storage

Primary data store — 90+ tables. Contacts, conversations, care plans, billing, analytics.

Container: iv_postgres, db: irievybz_core, user: irievybz. pgvector extension for semantic memory search. 33 migration files.

Full details →

Job queue for all scheduled work — care plan steps, nurture sequences, watchdog checks, content pipeline.

Container: iv_redis. BullMQ handles delayed jobs, retries, and prioritization.

Full details →

Sensitive medical data stored separately — DPA 2020 compliant.

Path: /opt/irievybz/data/oshun-phi/photos. Hetzner VPS, ready for AWS migration. Intake forms, consent records, clinical photos.

Full details →

A Patient's Journey, Start to Finish

The timeline every lead follows if they become a patient. Each dot is an automated step — nobody on staff has to remember.

First message Day 0 Karen replies in ~14 seconds Booking Day 0–3 Cal.com link + confirmation Pre-care 3 days before Guide + intake + reminders Procedure Visit day Staff marks complete in Telegram Post-care Day 1 → Day 42 7–12 check-ins + escalate if issues Review ~Week 4 Google Review request sent Long-term Monthly Drip + re-engage

If the patient no-shows or goes quiet, they loop back into the nurture sequence (Journey 5). If they ever report a concern during post-care, Karen escalates to Dr. Rockhead on Telegram.

The 10 Journeys

Follow the data through the system, step by step. Open any to see the plumbing.

ChatwootKaren AIContactsMemory
1 Lead sends WhatsApp/IG message → arrives at Chatwoot
2 Webhook fires → Karen AI receives message
3 Karen loads context — history, tenant persona, memory, pricing
4 Karen crafts response (Forward-Thinking Protocol)
5 Response sent back through Chatwoot to WhatsApp/IG
6 Memory stores the interaction, builds patient profile
7 Lead enters nurture sequence (if new)
Read full journey →
Karen AICal.comContactsCare Plans
1 Lead expresses interest in a procedure
2 Karen shares Cal.com booking link with procedure info
3 Patient books via Cal.com → webhook fires
4 Karen sends booking confirmation on original channel
5 Contact record updated with appointment details
6 Hands off to pre-appointment flow
Read full journey →
Care PlansKaren AICal.com
1 Booking triggers the care plan (procedure-specific)
2 3-day reminder + pre-care guide dispatched
3 Intake forms sent (female/male health assessment)
4 24-hour reminder
5 1-hour reminder
6 Patient arrives (or no-show → Journey 5)
Read full journey →
Care PlansTelegramKaren AI
1 Staff marks procedure complete via Telegram/backend
2 Post-care plan activates for that procedure type (7–12 messages over ~45 days)
3 Most procedures (Botox, Fillers, Laser, PRP, General): Day 1, 3, 7, 14, 28, 42
4 Liposuction: Day 1, 3, 7, 14, 21, 30, 42
5 Weight Loss / Semaglutide: Day 1, 2, 3, 4, 5, 6, 7 (daily first week), then 14, 21, 30, 42
6 Day 45: Google Review request closes the plan
7 Escalation to Dr. Rockhead on Telegram if patient reports issues at any check-in
Read full journey →
Karen AINurtureContacts
1 Trigger: no-show, quiet lead, or lapsed patient
2 Enrolled in appropriate nurture sequence
3 5-touch personalized messages over 14 days
4 Preference learning adapts messaging
5 Conversion → Journey 2, or long-term monthly drip
Read full journey →
Content EngineBlotatoTelegram
1 Daily pipeline triggers at 7 AM EST
2 AI generates brand-aware social content
3 Preview sent to Telegram for approval
4 Approved → Blotato publishes to IG/FB/YT
5 Rejected → regenerate or skip
6 Engagement tracked, scoring feeds next cycle
Read full journey →
ListmonkKaren AI
1 Campaign created in Listmonk with HTML template
2 Audience segmented (5K emails / 43K phones)
3 Campaign sent in batches via SMTP
4 Delivery and engagement tracked
5 Replies routed to Karen via Chatwoot
6 Unsubscribes handled automatically
Read full journey →
TwilioKaren AICal.com
1 Patient calls (876) 676-6297 → Twilio SIP trunk
2 ElevenLabs voice agent picks up
3 Karen processes conversation in real time
4 Action: book appointment, share info, or escalate
5 Call transcript synced to memory
Read full journey →
Payment SystemKaren AITelegram
1 Payment due after procedure completion
2 6-hop state machine: awaiting → grace → prompted → at_risk → reconciliation → complete
3 Payment received → commission calculated (10%)
4 If unpaid: Day 3 warning → Day 7 suspend → Day 14 final → Day 30 cancel
Read full journey →
WatchdogTelegram
1 Hourly: infrastructure checks (DB, Redis, SMTP, disk)
2 Hourly: tenant system checks (Chatwoot, OAuth, queues)
3 Auto-remediation for known issues (BullMQ, Listmonk, tokens)
4 Urgent alerts → Telegram immediately
5 Daily summary report at 8 AM EST
6 Weekly feedback analysis (Monday 9 AM EST)
7 Voice bridge monitoring + transcript sync
Read full journey →