I Built a Voice AI Agent for Pre-Visit Insurance Clearance

작성자

카테고리:

← 피드로
DEV Community · anusha · 2026-07-23 개발(SW)

Pre-visit insurance clearance is one of those workflows that sounds simple until you see how many phone calls it creates.

A patient calls before an appointment. They need to know whether a procedure, test, or medication requires prior authorization. Staff need to identify the patient, understand what they are asking for, collect payer and provider context, decide how urgent it is, and route the request to the right billing queue.

I built a Telnyx code example that turns that call into a structured intake ticket.

The code example:
https://github.com/team-telnyx/telnyx-code-examples/tree/main/ai-pre-visit-clearance-voice-agent-python

The Flow

A patient calls a Telnyx number. Telnyx sends the inbound call event to a Flask webhook. The app answers with Call Control, then starts gather_using_ai to collect the patient’s spoken pre-clearance request as structured fields.

When Telnyx finishes collecting those fields, the app receives call.ai_gather.ended. From there, the app classifies the request with AI Inference, confirms the details with the patient, creates a staff-facing ticket, sends the patient an SMS confirmation, and optionally alerts billing staff in Slack.

The agent is non-clinical. It doesn’t give medical advice, approve or deny coverage, or diagnose. It collects administrative data and routes it — which is the bottleneck in a lot of healthcare revenue-cycle work.

Why This Pattern Matters

The main Telnyx primitive here is Gather Using AI.

The app asks Telnyx to gather the fields it needs directly inside the call. The webhook response gives the backend something structured enough to use in a workflow.

That makes the rest of the app cleaner:

  • Call Control handles the inbound call lifecycle
  • Gather Using AI collects the spoken intake details
  • call.ai_gather.ended advances the workflow
  • AI Inference classifies urgency and type
  • Messaging sends the patient a confirmation
  • Slack gives billing staff a queue signal

The implementation patterns it covers:

  • DOB fallback when caller ID is unknown
  • command_id on Call Control commands
  • send_silence_when_idle when answering
  • structured JSON classification for procedure, urgency, and request type
  • keyword-based urgency override for phrases like “ASAP” or “can’t wait”
  • confirmation before ticket creation
  • partial ticket creation if the caller hangs up after providing useful context

Run It Locally

git clone https://github.com/team-telnyx/telnyx-code-examples.git
cd telnyx-code-examples/ai-pre-visit-clearance-voice-agent-python
cp .env.example .env
pip install -r requirements.txt
python app.py
ngrok http 5000

Enter fullscreen mode Exit fullscreen mode

Point your Telnyx Call Control Application webhook to:

https://<your-ngrok-domain>/webhooks/voice

Enter fullscreen mode Exit fullscreen mode

Seed a patient:

curl -X POST http://localhost:5000/patients \
  -H "Content-Type: application/json" \
  -d '{"patient_id":"P001","name":"Jordan Lee","phone":"+15551112233","dob":"03/15/1990","insurance":"Blue Cross","provider":"Dr. Smith"}'

Enter fullscreen mode Exit fullscreen mode

Call the number and say:

I need clearance for an MRI on my lower back.

Enter fullscreen mode Exit fullscreen mode

The app collects the request, classifies it, confirms the details, creates a ticket, and sends an SMS confirmation.

Where To Take It Next

Replace in-memory storage with your EHR, PMS, or billing system integration. Wire ticket completion into real prior auth submission APIs. Add privacy review and HIPAA-ready operational controls before production use. Queue Slack and SMS side effects so webhook responses stay fast.

The key boundary should stay the same: the agent collects and routes. Staff and payer systems make the actual coverage decisions.

Resources

원문에서 계속 ↗

코멘트

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다