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

> Source: <https://dev.to/botoclock/i-built-a-voice-ai-agent-for-pre-visit-insurance-clearance-57fh>
> Published: 2026-07-22 22:51:50+00:00

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](https://github.com/team-telnyx/telnyx-code-examples/tree/main/ai-pre-visit-clearance-voice-agent-python)

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.

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.ai_gather.ended`

advances the workflowThe implementation patterns it covers:

`command_id`

on Call Control commands`send_silence_when_idle`

when answering

```
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
```

Point your Telnyx Call Control Application webhook to:

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

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"}'
```

Call the number and say:

```
I need clearance for an MRI on my lower back.
```

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

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.

`call.ai_gather.ended`

:
