Building an omni-channel lab-results agent on Telnyx Edge Compute
I built a demo last month that I keep coming back to. Not because it's flashy — although the fax-to-phone journey is fun — but because of how it's architected. One durable actor per patient. Everything in one place. No external database.
The scenario
A lab faxes a patient's results to the clinic. A human reviews the PDF and accepts it. The moment they accept, the original fax is deleted from Telnyx storage — the AI never saw it, and it never will. What survives is a reference number and a status. From there, the AI drafts every follow-up: the confirmation email, the SMS replies, the answers on the hotline. A human approves every single message before it reaches the patient.
The code example is here:
https://github.com/team-telnyx/telnyx-code-examples/tree/main/omni-channel-inbox-agent
The architecture decision that made it work
The obvious design is four integrations: one for fax, one for email, one for SMS, one for voice. Four state stores, four identity maps, and an AI that knows nothing about any of them.
We did it differently. One StatefulActor per patient, on Telnyx Edge Compute, keyed by the patient's phone number. Every channel routes to that same actor:
- The fax webhook stores the document on the actor
- The SMS thread lives in the actor's conversation pool
- The email tracking updates the actor's document records
- The hotline call attaches to the same actor before the AI says a word
The actor carries its own embedded SQL — conversations, messages, documents, appointments. No external database. The state is the service.
What the agent does with that memory
Before every AI reply, the actor injects its own state into the model's context: the appointment status, the lab documents, whether the results email went out. So when a patient calls and says "I never got my lab results," the agent doesn't hallucinate. It reads the actor: "your results were sent to your email on Tuesday — check spam."
And the privacy is by construction: the AI only ever sees document metadata — a reference number and a status. The actual lab values were deleted from Telnyx storage the moment a human accepted the fax. There's nothing to leak because there's nothing there.
Human-in-the-loop, everywhere
Every AI reply lands as a draft. The admin inbox shows it in amber — edit, approve, or kill. Voice drafts get spoken on the live call. Emails go out with a display name and a tracking pixel. SMS through Messaging. The agent drafts; a human decides.
The analytics
The insights dashboard tracks sent, delivered, and opened — with a self-hosted tracking pixel served by the same Edge function. When the patient opens the email, the open rate moves live. No third-party tracker.
Run it
The full journey — booking, the visit, the fax, the review, the email, the hotline call, the open-rate flip — runs in demo mode. Clone it, ship it to Edge Compute, and it works.
https://github.com/team-telnyx/telnyx-code-examples/tree/main/omni-channel-inbox-agent
Top comments (0)