Voice AI

The Fax Machine Refuses to Die. So We Built the Workflow Around It.

Walk into any hospital laboratory in the United States and you'll find a fax machine — probably several. An estimated 75–90% of medical communication still runs over fax. Lab results, referral letters, imaging reports: they arrive as paper on a plastic tray, sit there until someone picks them up, and then begin a manual journey of data entry, phone tag, and "did you get my email?" voicemails.

The result: patients wait days for results that were finalized in minutes. Staff lose hours to follow-up calls. PHI sits on paper trays where anyone can read it. And when a patient calls asking "are my results ready?", someone has to walk to a filing cabinet and look.

This is a workflow problem, not a technology problem. The labs aren't going to stop faxing — HIPAA-safe direct messaging adoption has been "two years away" for a decade. So we built the system around the fax instead of waiting for it to die.

The code example is here:

https://github.com/team-telnyx/telnyx-code-examples/tree/main/omni-channel-lab-inbox-agent

What We Built

A hospital intake workflow on Telnyx Edge Compute that turns an analog fax into a digital, auditable, patient-facing process:

  1. The lab faxes the result to a Telnyx intake number — nothing changes for the sending lab, no new software, no training
  2. The fax becomes a digital case — an Edge function receives it, generates a case reference (LAB-20260901-472), and drops it into a unified inbox
  3. A human reviews it — the operator downloads the PDF, checks it's the right patient and legible, and clicks Accept. At that instant the original fax is deleted from Telnx. Permanently. Only the reference and status survive.
  4. The patient is notified — an AI drafts a confirmation email from metadata (reference number, received date — never lab values), the operator approves it, and it sends
  5. The patient self-serves — they text "what floor?" before their appointment, or call after and ask "were my results sent?" — an AI answers from their case record, and escalates anything clinical to staff

The result: no paper tray, no lost faxes, no phone tag, and an audit trail from arrival to delivery. The patient gets their answer in one phone call instead of a three-day game of telephone tag with the front desk.

Why the AI Has Limits — On Purpose

The tempting version of this demo is an AI that reads the lab report and summarizes it. We deliberately didn't build that, for three reasons:

It's a regulatory minefield. An AI interpreting lab values is practicing medicine. Getting it wrong — even slightly — has consequences no code review can fix.

It's unnecessary. The patient doesn't want an AI opinion on their CBC panel. They want to know: did the hospital get my results, and where are they? That's a database lookup, not a diagnosis.

It's the wrong trust model. The operator is the medical professional. The AI is the administrative layer. The workflow enforces this: the AI's only tool returns a status string — the schema makes lab content architecturally unreachable. The reference number doubles as the verification factor: possessing it proves the caller is the patient (it arrives by email, and a production deployment adds DOB verification or OTP as a second factor).

The voice agent demonstrates the boundary live. A patient says "what did my results show?" and the agent replies: "I'm not able to discuss lab results or medical questions, but your full results are in your email, and I can connect you with our staff." That's not a failure of the AI — it's the workflow working exactly as designed.

How It Works

One Edge Compute function. One durable actor per patient, keyed by phone number, with per-actor SQLite holding the entire case state — documents, appointments, conversations, delivery flags. The Telnyx Agent SDK provides the actor primitive, message history, and zero-credential inference.

Hospital Lab ──fax──▶ Intake number ──▶ InboxAgent (per-patient actor)
                                            │
                          Operator (Inbox UI): review / Accept / approve
                                            │
            ┌───────────────────────────────┼──────────────────────┐
            ▼                               ▼                      ▼
      Confirmation email            SMS auto-replies          Voice agent
      (Email API + events)         (from patient record)     (reference-gated)

Channels:

  • Fax — fax.ended webhook → GET /v2/faxes/{id} for the signed PDF → DELETE /v2/faxes/{id} on Accept
  • Email — AI-drafted confirmation via the Email API, with per-message delivery events (queued → sent → delivered → opened) rendered live in the inbox
  • SMS — appointment confirmations, visit-complete notifications, and context-aware auto-replies from the patient's record
  • Voice — a managed AI Assistant with a lookup_lab_document tool that calls back into the Edge function mid-call

What Production Looks Like

This demo runs one department's intake line. The production path scales it in three directions:

Multi-department. Each department (lab, radiology, cardiology) gets its own intake number and actor namespace. The unified inbox aggregates across all of them — an operator sees every case they're responsible for, and the case reference encodes the department (LAB-, RAD-, CARD-).

EHR integration. The Accept action currently deletes the fax and keeps a reference. In production, Accept also fires a webhook into the EHR (Epic, Cerner) to attach the document to the patient's chart via FHIR DocumentReference. The case reference becomes the correlation key between the fax and the chart entry.

Compliance posture. The deletion-on-accept pattern means PHI retention is minutes, not days. The audit trail — who reviewed, who accepted, when the email was sent, when the patient opened it — lives in the case record. Telnyx's HIPAA-eligible voice and messaging infrastructure keeps the transport side covered; the workflow keeps the storage side minimal by construction.

Multi-channel intake. Labs that can send electronically skip the fax: results arrive by secure email into the same inbox, hitting the same case model. The channel is an implementation detail — the case, the reference, and the workflow state are identical.

What the Demo Shows

Every piece is runnable from the deployed function's inbox UI — no external systems needed:

  • Simulate incoming fax — creates a case with a sample lab report
  • Download / Accept — the operator workflow, with the fax deletion enforced
  • Book appointment / Mark visit complete — the SMS appointment flow with real confirmations
  • Simulate: patient opened email — the delivery lifecycle from the patient's side
  • Call the intake number — the voice agent answering status questions from the case record

Full narrated demo script, API reference, and architecture guide are in the repo.

Run It

git clone https://github.com/team-telnyx/telnyx-code-examples.git
cd telnyx-code-examples/omni-channel-lab-inbox-agent
npm install
# configure telnyx.toml + secrets (see README)
npm run ship

The fax machine isn't going away. But the paper tray, the phone tag, and the "did you get my results?" voicemail can.

Ready to build with low-latency voice AI?

Join developers building the future of real-time conversations