--- name: ai-pre-visit-clearance-voice-agent title: "AI Pre-Visit Clearance Voice Agent" description: "Inbound voice agent for healthcare pre-visit insurance clearance. Patients call to request prior authorization for a procedure, test, or medication. The agent verifies identity by DOB, collects procedure/provider/insurer, classifies urgency with AI, creates a structured intake ticket for billing staff, and sends an SMS confirmation." language: python framework: flask telnyx_products: [Voice, AI Inference, Messaging] integrations: [Slack] channel: [voice, sms] --- # AI Pre-Visit Clearance Voice Agent Inbound voice and SMS agent for healthcare pre-visit insurance clearance. Patients call to request prior authorization for a procedure, test, or medication. The agent verifies identity by DOB, classifies urgency with AI Inference, creates a structured intake ticket for billing staff, and sends an SMS confirmation. Non-clinical: no medical advice, no coverage decisions. ## Telnyx API Endpoints Used - **Call Control: Answer**: `POST /v2/calls/{id}/actions/answer` - [API reference](https://developers.telnyx.com/api/call-control/answer-call) - **Call Control: Speak**: `POST /v2/calls/{id}/actions/speak` - [API reference](https://developers.telnyx.com/api/call-control/speak) - **Call Control: Gather Using AI**: `POST /v2/calls/{id}/actions/gather_using_ai` - [API reference](https://developers.telnyx.com/api/call-control/gather-using-ai) - **AI Inference**: `POST /v2/ai/chat/completions` - [API reference](https://developers.telnyx.com/api/inference/chat-completions) ## Setup ```bash 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 ```
Programmatic / CLI setup ```bash # Install CLI — https://developers.telnyx.com/development/cli go install github.com/team-telnyx/telnyx-cli/cmd/telnyx@latest telnyx auth login # Provision resources telnyx available-phone-numbers list --country US --features sms telnyx number-orders create --phone-number +15551234567 ``` For full API discovery, point your agent at [`llms-full.txt`](https://developers.telnyx.com/llms-full.txt).
## API Reference ### `GET /health` ```bash curl http://localhost:5000/health ``` ```json {"open_tickets": 0, "patients": 1, "status": "ok", "active_calls": 0} ``` ### `POST /patients` ```bash curl -X POST http://localhost:5000/patients -H "Content-Type: application/json" -d '{"patient_id":"P001","name":"Jordan","phone":"+15551112233","dob":"03/15/1990","insurance":"Blue Cross","provider":"Dr. Smith"}' ``` ### `GET /tickets` ```bash curl http://localhost:5000/tickets ``` ## Troubleshooting | Issue | Cause | Fix | |-------|-------|-----| | `401 Unauthorized` | Invalid API key | Verify `TELNYX_API_KEY` in [Portal](https://portal.telnyx.com/api-keys) | | Webhook not received | Local server not reachable | Use ngrok and set webhook in [Portal](https://portal.telnyx.com) | ## Related Examples - [AI Medical Appointment Prep Caller](https://raw.githubusercontent.com/team-telnyx/telnyx-code-examples/main/ai-medical-appointment-prep-caller-python/README.md) - [AI Insurance Claims Intake](https://raw.githubusercontent.com/team-telnyx/telnyx-code-examples/main/ai-insurance-claims-intake-voice-python/README.md) - [Prescription Refill Line](https://raw.githubusercontent.com/team-telnyx/telnyx-code-examples/main/prescription-refill-line-python/README.md) ## Agent Discovery This example is part of the [Telnyx Code Examples](https://github.com/team-telnyx/telnyx-code-examples) catalog. - **Agent signup**: [telnyx.com/agent-signup.md](https://telnyx.com/agent-signup.md) — automated account provisioning via agent mail; get an API key with no human intervention - **Agent CLI**: [github.com/team-telnyx/ai/tree/main/cli](https://github.com/team-telnyx/ai/tree/main/cli) — composite commands for agents ([commands reference](https://github.com/team-telnyx/ai/tree/main/cli/src/commands)) - **Agent skills**: [github.com/team-telnyx/ai/tree/main/skills](https://github.com/team-telnyx/ai/tree/main/skills) - **Telnyx AI repo**: [github.com/team-telnyx/ai](https://github.com/team-telnyx/ai) - **LLM-optimized docs**: [`llms-full.txt`](https://developers.telnyx.com/llms-full.txt) - **Example index**: [`llms.txt`](https://raw.githubusercontent.com/team-telnyx/telnyx-code-examples/main/llms.txt) - **Telnyx CLI (human)**: [developers.telnyx.com/development/cli](https://developers.telnyx.com/development/cli) — `go install github.com/team-telnyx/telnyx-cli/cmd/telnyx@latest` ## Resources - [Call Control Guide](https://developers.telnyx.com/docs/voice/call-control) - [AI Inference Guide](https://developers.telnyx.com/docs/inference) - [Telnyx Developer Docs](https://developers.telnyx.com) - [Telnyx Portal](https://portal.telnyx.com) ## Why Telnyx Telnyx is an **AI Communications Infrastructure** platform - voice, messaging, SIP, AI, and IoT on one private, global network.