Lab result notification is a useful healthcare voice AI workflow because the call pattern is predictable, privacy-sensitive, and operationally expensive.
A patient calls to ask whether results are ready. The clinic needs to verify identity, disclose only the minimum necessary information, and direct the patient to a secure portal for the full report.
The important boundary is that the AI should not diagnose, interpret beyond a provider note, change treatment plans, or replace clinical staff. It should handle a narrow notification workflow and route follow-up to the care team.
The Telnyx code example is here:
https://github.com/team-telnyx/telnyx-code-examples/tree/main/ai-lab-results-notification-voice-python
It is a Python + Flask example that shows how to use Telnyx AI Assistants, Voice, and native assistant messaging to build a lab results notification line.
What This Example Builds
The example starts with an inbound call to a Telnyx number assigned directly to a Telnyx AI Assistant.
From there, the assistant handles the conversation:
- asks for the caller's full legal name
- asks for date of birth
- verifies the caller against mock records
- discloses a minimum necessary lab result summary
- offers a secure portal link by SMS
- keeps lab values out of the SMS body
- uses follow-up language for abnormal or borderline results
The Flask app adds a simple demo dashboard so you have something clean to screen share while explaining the flow.
Architecture
patient calls telnyx number
-> telnyx ai assistant answers
-> assistant asks for full legal name
-> assistant asks for date of birth
-> assistant verifies against mock records
-> assistant gives minimum necessary result summary
-> assistant sends portal link with native send_message
-> flask dashboard shows demo flow and safeguards
This direct path does not require a local tunnel for the live assistant call. The phone number can be assigned directly to the AI Assistant in the Telnyx Portal.
The sample still includes optional Flask extension endpoints for teams that want backend verification, result lookup, audit events, or nurse routing later.
Why Direct Assistant Assignment
For this demo, direct assignment keeps the moving parts small.
The phone number points to the assistant. The assistant is provisioned from code. The secure portal link is sent with the assistant's native send_message tool. The local Flask UI is only for screen share and optional extension code.
That makes the demo easier to explain:
number -> ai assistant -> identity check -> result summary -> secure portal link
The architecture is still realistic enough to show the privacy posture, but simple enough to test on a phone.
HIPAA Compliance Safeguards
This sample is built around the safeguards expected in a HIPAA-compliant lab results notification workflow:
- mock records only
- identity verification before result disclosure
- minimum necessary spoken summary
- SMS contains a secure portal link, not lab values
- assistant recording disabled
- assistant data retention disabled
- prompt boundaries against diagnosis, treatment changes, and emergency handling
- optional backend endpoints for audit and escalation workflows
For production, pair these controls with the required BAA, role-based access controls, audit logging, retention policies, monitoring, and compliance review for your healthcare organization.
Run The Example
git clone https://github.com/team-telnyx/telnyx-code-examples.git
cd telnyx-code-examples/ai-lab-results-notification-voice-python
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
Fill in:
TELNYX_API_KEY=KEY...
TELNYX_PHONE_NUMBER=+18005551234
Start the local dashboard:
python app.py
Open:
http://127.0.0.1:5000
Then create or update the assistant:
python provision_assistant.py
Assign your Telnyx phone number directly to the AI Assistant in the Portal and call the number.
The Core Code
The assistant setup lives in provision_assistant.py.
The provisioning payload configures:
- the model
- the assistant instructions
- the greeting
- native
send_message - interruption handling
- transcription endpointing
- telephony settings
- privacy settings
The SMS tool uses a template like:
telnyx health: your lab results are ready. view securely: https://portal.example.com/r/demo-link expires in 24 hours. no lab values are included in this text.
That is the key privacy behavior: the text says results are ready and points to a secure portal, but it does not carry lab values.
The Flask dashboard lives in app.py. It shows:
- the call flow
- mock test patients
- HIPAA compliance safeguards
- local audit and callback state
It intentionally avoids showing API keys, raw assigned phone numbers, or real patient data.
Why This Pattern Matters
Healthcare voice AI works best when the task is narrow and the boundaries are explicit.
The assistant is not a clinician. It is not interpreting labs. It is not deciding treatment.
It is helping with a common notification workflow:
verify identity
give minimum necessary summary
send patient to secure portal
route follow-up when needed
That is a practical use case for Telnyx AI Assistants because voice, messaging, phone-number assignment, and assistant provisioning can be handled in one platform.