I built a small Flask example that turns voicemail into a routing workflow.
Code:
https://github.com/team-telnyx/telnyx-code-examples/tree/main/voicemail-smart-router-python
The app accepts either:
- a voicemail transcript
- an uploaded voicemail audio file
For audio, it transcribes the voicemail first. Then it uses Telnyx AI Inference to classify the message and decide where it should go.
Categories
The app classifies voicemails into:
urgentbillingsupportsalesspamroutine
Each category maps to a route:
urgent -> Slack alert
billing -> email
support -> ticket queue
sales -> CRM lead
spam -> blocklist + archive
routine -> daily digest
Enter fullscreen mode Exit fullscreen mode
Run it
git clone https://github.com/team-telnyx/telnyx-code-examples.git
cd telnyx-code-examples/voicemail-smart-router-python
cp .env.example .env
pip install -r requirements.txt
python app.py
Enter fullscreen mode Exit fullscreen mode
Configure .env:
TELNYX_API_KEY=your_telnyx_api_key
AI_MODEL=zai-org/GLM-5.2
FALLBACK_MODEL=meta-llama/Llama-3.3-70B-Instruct
HOST=127.0.0.1
Enter fullscreen mode Exit fullscreen mode
Optional Slack webhook for urgent messages:
SLACK_WEBHOOK=https://hooks.slack.com/...
Enter fullscreen mode Exit fullscreen mode
Classify a transcript
curl -X POST http://localhost:5000/voicemails/transcript \
-H "Content-Type: application/json" \
-d '{
"transcript": "This is an emergency. Our production system is down and we need help immediately.",
"caller_number": "+17177247292"
}'
Enter fullscreen mode Exit fullscreen mode
Example response:
{
"category": "urgent",
"confidence": 1.0,
"priority": "high",
"reason": "The caller reports a production system outage requiring immediate attention.",
"suggested_action": "Escalate immediately to the on-call engineering team.",
"route": "slack",
"routed_to": "#oncall-alerts",
"routing_status": "delivered"
}
Enter fullscreen mode Exit fullscreen mode
Process voicemail audio
curl -X POST http://localhost:5000/voicemails/process \
-F "[email protected]" \
-F "caller_number=+17177247292"
Enter fullscreen mode Exit fullscreen mode
For audio, the app calls:
POST /v2/ai/audio/transcriptions
Enter fullscreen mode Exit fullscreen mode
using:
distil-whisper/distil-large-v2
Enter fullscreen mode Exit fullscreen mode
Then it calls:
POST /v2/ai/chat/completions
Enter fullscreen mode Exit fullscreen mode
to classify the transcript.
Routes included
POST /voicemails/transcriptPOST /voicemails/processGET /voicemailsGET /voicemails/<id>GET /routesGET /health
Production ideas
This sample uses in-memory storage and a simple routing map.
For production, I would add:
- auth
- durable storage
- webhook ingestion from real voicemail events
- retries for failed delivery
- real email, ticket, and CRM integrations
- review queues for low-confidence messages
- audit logs
- configurable routing rules
- PII handling before storing transcripts
The useful pattern is not just classification. It is classification plus action. The model turns a voicemail into structured intent, and the application routes it to the right workflow.
Resources:
- Code: https://github.com/team-telnyx/telnyx-code-examples/tree/main/voicemail-smart-router-python
- Telnyx AI Inference docs: https://developers.telnyx.com/docs/inference
- Audio Transcriptions API: https://developers.telnyx.com/api/inference/create-transcription
- Chat Completions API: https://developers.telnyx.com/api/inference/chat-completions
- Telnyx AI skills and toolkits: https://github.com/team-telnyx/ai
0 Comments
Log in to join the conversation.No comments yet. Be the first to share your thoughts.