A clinic phone line is not one workflow.
It is hours and directions. It is billing. It is intake. It is after-hours messages. Sometimes it is a patient saying something that should reach a human immediately.
That is why I like the clinic-triage-handoff example. It is not "AI answers the phone" as a party trick. It is a more useful shape: AI handles the routine path, but the system has a deterministic escape hatch when the call becomes urgent.
Code:
https://github.com/team-telnyx/telnyx-code-examples/tree/main/clinic-triage-handoff
The Pattern
The example uses one Telnyx Edge function as the routing brain.
It answers inbound clinic calls, records who called, injects routing history, and starts the correct AI assistant persona. There are three assistant roles:
- front desk
- billing desk
- clinical desk
Routine calls move between those personas with context. The caller does not have to start over every time the call moves.
The interesting part is urgent escalation. If the assistant identifies an urgent symptom, it does not try to solve the problem in the prompt. It calls a webhook tool. From there, code takes over:
- send an SMS alert to the on-call nurse
- dial the nurse
- speak a briefing
- bridge the patient into the live call
- write the event to a durable log
The AI recognizes the handoff. The system performs the handoff.
Why This Feels Different From a Phone Tree
Phone trees are usually stateless. Each transfer is a reset.
This sample keeps a durable per-caller routing log. The next call can include context like "this caller last asked about billing" or "this caller had an escalation." The care-team view is rendered from the same log, so the demo can show the operational trail instead of only the voice interaction.
That matters because front desk work is not only the call. It is the memory of the call, the handoff, and the proof that something happened.
Why The Urgent Path Belongs in Code
In healthcare-adjacent demos, the boundary matters.
The assistant should not diagnose. It should not make clinical decisions. It should not decide how to improvise an emergency procedure.
In this sample, the urgent path is a code path. The assistant's job is to invoke the escalation tool. The Edge function's job is to execute the workflow every time in the same order.
That gives you something you can test:
- Did the tool endpoint receive the escalation?
- Did the SMS send?
- Did the nurse dial start?
- Did the briefing play?
- Did the bridge happen?
- Did the log update?
That is the difference between "the assistant is instructed to escalate" and "the system escalates."
The Useful Architecture
The pieces are simple:
- Telnyx Call Control for the call lifecycle
- Telnyx AI Assistants for the phone personas
- Telnyx Edge Compute for routing and state
- Telnyx Messaging for the nurse alert
- durable SQL storage for the routing log
The result is a workflow where voice, messaging, AI, and compute live close together. You do not need a separate queue, webhook relay, and database just to prove the handoff.
Try It
git clone https://github.com/team-telnyx/telnyx-code-examples.git
cd telnyx-code-examples/clinic-triage-handoff
npm install
cp .env.example .env
Create the three assistants, configure the Edge secrets, connect the clinic numbers, and call the front desk line. Test one routine transfer and one urgent escalation. Then open the care-team view and look at the log.
That is the whole point of the sample: the voice demo is visible, but the handoff record is the product.
Top comments (0)