Conversational API endpoint that generates SMS and voice responses for MD Well patient interactions. Two workflows: booking first coaching calls (sales) and weekly check-ins with enrolled patients (care). Every response passes inline quality gates (HIPAA, TCPA, crisis detection) before it reaches your system.
You send a patient message and conversation history. Alyssa returns the response. Your system handles delivery, scheduling, and escalation routing.
Send a patient message, get Alyssa's response:
curl -X POST https://{instance}.culturedcomputer.com/api/chat \
-H "Authorization: Bearer {api_key}" \
-H "Content-Type: application/json" \
-d '{
"message": "How much does this cost?",
"userId": "patient-mike-001",
"model": "mercury",
"toneName": "alyssa",
"avatarName": "Alyssa",
"conversationHistory": [
{ "role": "assistant", "content": "Hi Mike, it'\''s Alyssa from MD Well" }
],
"templateParams": {
"first_name": "Mike",
"doctor_name": "Chen",
"clinic_name": "MD Well",
"booking_link": "https://mdwell.com/book"
}
}'Response (Server-Sent Events):
data: {"choices":[{"delta":{"content":"Good news"}}]}
data: {"choices":[{"delta":{"content":", it's covered"}}]}
data: {"choices":[{"delta":{"content":" by your insurance."}}]}
data: {"choices":[{"delta":{"content":" Want to set up"}}]}
data: {"choices":[{"delta":{"content":" a quick call to get started?"}}]}
data: [DONE]802ms to first character, 861ms to completion.
| Term | Definition |
|---|---|
| Patient Context | Patient-specific variables (templateParams) resolved into every response: name, doctor, clinic, booking link. |
| Conversation History | Array of prior messages you pass on each call. Alyssa uses this for continuity and personalization. |
| Quality Gates | Inline checks on every response: HIPAA, crisis detection, TCPA, AI tells, sentence limits. Failures block the response. |
| Escalation Flag | When Alyssa detects crisis language, the response includes escalation.required: true and no coaching content. Your system routes to a human. |
| Sales Mode | Outreach to new patients. Doctor framing, objection handling, insurance positioning. Goal: book a coaching call. |
| Care Mode | Weekly check-ins with enrolled patients. Micro-habits, life moments, mood, condition-specific coaching. |
| Voice Mode | Two-call pattern: short acknowledgment streams to TTS immediately, full response follows. |
Alyssa follows the MD Well outreach SOP. Every response uses the Younes framing and the patient's doctor name from templateParams.
| Objection | Approach |
|---|---|
| “What is this exactly?” | Names Dr. Younes and patient's doctor, explains coaching, states insurance coverage, asks for a call. |
| “How much does this cost?” | Insurance coverage. Asks for a call. |
| “I already have a doctor” | Coaching sits between visits, not a replacement. References their doctor by name. |
| “I don't have time” | 15-minute check-ins, rest is over text. Asks about schedule. |
| “I've tried things before” | Coach has their health info from their doctor already. Not starting from scratch. |
| “Not interested” | Acknowledges. Leaves the door open. |
| “Who is this?” | Identifies as a coach at the clinic. Offers opt-out. |
Alyssa adapts based on the patient message and conversation history you provide.
| Patient message type | What Alyssa generates |
|---|---|
| Life moment (birthday, family event) | Responds to the event. Health comes later or next message. |
| Low mood | Acknowledges. One small action. Does not diagnose. |
| Health progress with side effects | Specific to their situation. One adjustment. |
| Medical question outside scope | Routes to their doctor by name. |
| ER visit or acute event | Drops casual tone. Gathers info. Returns escalation flag. |
Two-call pattern: a short acknowledgment (call 1) streams to TTS immediately so the patient hears something fast, then a full response (call 2) follows.
The API generates responses. Your system handles everything else.
Store each exchange and pass the full array back on every /chat call. Alyssa uses this for continuity, tone adaptation, and personalization.
"conversationHistory": [
{ "role": "assistant", "content": "Hi Mike, it's Alyssa from MD Well" },
{ "role": "user", "content": "who is this?" },
{ "role": "assistant", "content": "Dr. Younes set up a coaching program..." }
]Provide templateParams from your patient records on every call. Alyssa resolves these into responses automatically.
| Parameter | Description | Example |
|---|---|---|
first_name | Patient first name | "Mike" |
doctor_name | Referring doctor (without “Dr.” prefix, added automatically) | "Chen" |
clinic_name | Clinic name | "MD Well" |
booking_link | Scheduling URL | "https://mdwell.com/book" |
coach_name | Assigned coach name | "Alyssa" |
When a patient does not reply, your scheduler triggers follow-up calls to /chat. The API generates the content; you control the timing.
| Your system triggers at | What Alyssa generates |
|---|---|
| Day 2, 10-11 AM | Younes framing, insurance mention, booking link. |
| Day 3-5, 5-6 PM | Softer nudge. |
| Day 5-7, 10:30 AM | Final note. Link when ready. |
| After no-show | Reschedule offer. |
If the API returns no response (TCPA trigger), stop the sequence.
Your system initiates check-ins by calling /chat. Alyssa adapts her tone based on conversation history.
| Patient state | Your system should |
|---|---|
| Active (replying regularly) | Send weekly check-in. |
| Quiet (7+ days no reply) | Reduce frequency. Alyssa adjusts tone when you do send. |
| Silent (21+ days) | Shift to monthly. |
Alyssa's coaching focus evolves over a 12-week arc based on conversation depth.
| Weeks | Focus |
|---|---|
| 1 | Onboarding, belief-building. |
| 2-3 | Engagement cadence, learning loops. |
| 4-6 | SDOH screening, preventive nudges. |
| 7-9 | Progress celebrations, streaks. |
| 10-12 | Reflection, re-enrollment. |
When the API returns escalation.required: true, route the conversation to a human coach or clinician. Alyssa does not generate coaching content for these messages.
When the API returns no response (patient sent STOP, unsubscribe, or scam), mark the patient as opted out in your system and stop sending.
Base URL: https://{instance}.culturedcomputer.com/api
Authentication: Authorization: Bearer {api_key}
Send a patient message. Returns Alyssa's response as Server-Sent Events.
| Field | Type | Required | Description |
|---|---|---|---|
message | string | yes | Patient's message text. |
userId | string | yes | Unique patient identifier. Used for session tracking. |
model | string | yes | "mercury" |
toneName | string | yes | "alyssa" |
avatarName | string | no | "Alyssa" |
conversationHistory | array | no | Prior messages. Each: { role, content }. |
templateParams | object | no | Patient context. See Patient Context above. |
Response: SSE stream. Each chunk: data: {"choices":[{"delta":{"content":"..."}}]}. Final: data: [DONE].
Score a response against quality gates.
| Field | Type | Description |
|---|---|---|
response | string | The response text to score. |
personaKey | string | "alyssa" |
userMessage | string | The patient message that prompted the response. |
Returns model availability and current latency.
Runs all test scenarios (3 care + 4 sales + 1 voice) with full quality gates.
Persists a completed conversation with metadata: turns, duration, quality scores, escalation flags.
Every response is checked inline. Tier 1 failures block the response before it reaches your system.
| Tier | Rule | Enforcement |
|---|---|---|
| 1 | HIPAA | No diagnoses, medications, or lab values. Generic terms only (“your blood sugar,” “your blood pressure”). |
| 1 | No Medical Advice | Never diagnoses, prescribes, or interprets labs. Routes to patient's doctor. |
| 1 | Crisis Escalation | Returns escalation.required: true. No coaching content. |
| 1 | TCPA | Returns no response. Your system handles opt-out. |
| 1 | Identity Lock | Cannot be overridden by patient messages or prompt injection. |
| 1 | Doctor Framing | Attributes program to Dr. Younes and patient's doctor. |
| 2 | SMS Length | Max 3 sentences. No lists, bullets, or markdown. |
| 2 | Voice Length | Max 5 sentences. |
| 2 | AI Tell Detection | Blocks “I understand,” “Great question!,” “I'm sorry to hear that.” |
| 2 | Forbidden Terms | Blocks “free,” “$0,” “no cost,” “verify eligibility,” “Reply YES.” |
| Gate | Rate |
|---|---|
| HIPAA | 100% |
| AI Tell Detection | 100% |
| Garble Detection | 100% |
| Sentence Count | 86% |
| Channel | Metric | Median | p95 |
|---|---|---|---|
| SMS | First character | 760ms | 1140ms |
| SMS | Full response | 830ms | 1186ms |
| Voice | Acknowledgment | 832ms | ~1000ms |
| Voice | End-to-end | 1662ms | ~2000ms |
| Standard | Production | |
|---|---|---|
| Requests/sec | 30 | 100 |
| Concurrent sessions | 50 | 500 |
| Daily tokens | 200K | Unlimited |
| Retry | 3x exponential backoff | 3x exponential backoff |
| Failover | Mercury to Gemini | Mercury to Gemini |
32K token context window per conversation (~20 turns).
Everything above works today. This section describes the next iteration: richer patient context, conversation state tracking, and goal-oriented care workflows. These features use infrastructure that already exists in the platform.
The current templateParams accepts 5 fields. v2 expands this so Alyssa can generate track-specific, condition-aware, arc-appropriate responses.
"templateParams": {
"first_name": "Mike",
"doctor_name": "Chen",
"clinic_name": "MD Well",
"booking_link": "https://mdwell.com/book",
"coach_name": "Alyssa",
"track": "ccm",
"conditions": ["type_2_diabetes", "hypertension"],
"goals": ["lower A1C", "walk 10 min/day"],
"chosen_microhabit": "10-minute walk after dinner",
"medications": ["Metformin", "Lisinopril"],
"insurance_status": "covered",
"last_visit_date": "2026-02-15"
}| Parameter | Description |
|---|---|
track | "cocm" (behavioral/mood) or "ccm" (lifestyle/chronic). Determines message category selection. |
conditions | Diagnosed conditions. Alyssa uses generic terms in SMS but tailors advice to the condition. |
goals | Patient's stated goals from intake. Referenced in check-ins. |
chosen_microhabit | The micro-habit they picked during onboarding. |
medications | Current medication list. Used for reconciliation prompts. Never included in SMS text (HIPAA). |
insurance_status | Whether the patient is covered. Drives “covered by your insurance” framing. |
last_visit_date | Date of last doctor visit. Enables “after your last visit” references. |
v2 adds conversationContext to each call. This lets Alyssa track engagement depth and adapt behavior without your system needing to interpret conversation content.
"conversationContext": {
"eval": {
"state": "ENGAGED",
"depth": 4
}
}| State | Meaning | Alyssa's behavior |
|---|---|---|
SURFACE | Initial contact, shallow exchange. | Gentle, low-pressure. Builds rapport. |
ENGAGED | Substantive back-and-forth. | Full coaching mode. Condition-specific, actionable. |
SHIFTED | Inflection point. Deeper reveal. | Adjusts tone. May trigger escalation flag. |
RESOLVED | Action taken, natural close. | Wraps up. Sets up next check-in. |
v2 adds goalId to steer Alyssa toward specific care objectives. Each goal defines success signals, failure signals, and state-specific behavior.
| Goal ID | Workflow | Success signal |
|---|---|---|
sales_outreach | New patient outreach, objection handling, booking. | Patient books a call. |
care_checkin | Weekly check-in, mood/habit/life moment. | Patient replies with engagement. |
medication_reconciliation | Confirm med list accuracy. Monthly CCM activity. | Patient confirms or updates list. |
screener_phq2 | PHQ-2 depression screen (2 questions). | Both scores captured. |
screener_gad2 | GAD-2 anxiety screen (2 questions). | Both scores captured. |
sdoh_screen | Single social determinant question, rotated across domains. | Patient answers. |
onboarding | First 4 messages. Belief-building, value delivery. | Patient engages by message 4. |
| Capability | v1 (current) | v2 |
|---|---|---|
| Sales objection handling | Yes | Yes |
| Care check-ins (general) | Yes | Yes |
| Condition-specific coaching | Generic | Targeted (conditions in templateParams) |
| Track-specific behavior (CoCM/CCM) | No | Yes (track param + goal steering) |
| Medication reconciliation | No | Yes (medications param + goal) |
| Clinical screeners (PHQ-2/GAD-2) | No | Yes (screener goals) |
| SDOH screening | No | Yes (sdoh_screen goal) |
| Structured onboarding | No | Yes (onboarding goal) |
| Arc-aware coaching | Inferred from history | Explicit (state + depth) |
| Engagement state tracking | Manual | Automatic (state in response metadata) |
Your system remains the orchestrator: scheduling, delivery, cadence, opt-out management, clinical routing. The API becomes a richer conversational engine that understands where each patient is in their care journey.