{"slug": "route-voicemails-with-python-and-telnyx-ai", "title": "Route Voicemails with Python and Telnyx AI", "summary": "Telnyx released a Python Flask example that uses AI to classify voicemails and route them to appropriate workflows such as Slack alerts, email, or ticket queues. The app transcribes audio voicemails, then uses Telnyx AI Inference to categorize messages into types like urgent, billing, or spam, triggering corresponding actions.", "body_md": "I built a small Flask example that turns voicemail into a routing workflow.\n\nCode:\n\n[https://github.com/team-telnyx/telnyx-code-examples/tree/main/voicemail-smart-router-python](https://github.com/team-telnyx/telnyx-code-examples/tree/main/voicemail-smart-router-python)\n\nThe app accepts either:\n\nFor audio, it transcribes the voicemail first. Then it uses Telnyx AI Inference to classify the message and decide where it should go.\n\nThe app classifies voicemails into:\n\n`urgent`\n\n`billing`\n\n`support`\n\n`sales`\n\n`spam`\n\n`routine`\n\nEach category maps to a route:\n\n``` php\nurgent  -> Slack alert\nbilling -> email\nsupport -> ticket queue\nsales   -> CRM lead\nspam    -> blocklist + archive\nroutine -> daily digest\ngit clone https://github.com/team-telnyx/telnyx-code-examples.git\ncd telnyx-code-examples/voicemail-smart-router-python\ncp .env.example .env\npip install -r requirements.txt\npython app.py\n```\n\nConfigure `.env`\n\n:\n\n```\nTELNYX_API_KEY=your_telnyx_api_key\nAI_MODEL=zai-org/GLM-5.2\nFALLBACK_MODEL=meta-llama/Llama-3.3-70B-Instruct\nHOST=127.0.0.1\n```\n\nOptional Slack webhook for urgent messages:\n\n```\nSLACK_WEBHOOK=https://hooks.slack.com/...\ncurl -X POST http://localhost:5000/voicemails/transcript \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"transcript\": \"This is an emergency. Our production system is down and we need help immediately.\",\n    \"caller_number\": \"+17177247292\"\n  }'\n```\n\nExample response:\n\n```\n{\n  \"category\": \"urgent\",\n  \"confidence\": 1.0,\n  \"priority\": \"high\",\n  \"reason\": \"The caller reports a production system outage requiring immediate attention.\",\n  \"suggested_action\": \"Escalate immediately to the on-call engineering team.\",\n  \"route\": \"slack\",\n  \"routed_to\": \"#oncall-alerts\",\n  \"routing_status\": \"delivered\"\n}\ncurl -X POST http://localhost:5000/voicemails/process \\\n  -F \"file=@voicemail.wav\" \\\n  -F \"caller_number=+17177247292\"\n```\n\nFor audio, the app calls:\n\n```\nPOST /v2/ai/audio/transcriptions\n```\n\nusing:\n\n```\ndistil-whisper/distil-large-v2\n```\n\nThen it calls:\n\n```\nPOST /v2/ai/chat/completions\n```\n\nto classify the transcript.\n\n`POST /voicemails/transcript`\n\n`POST /voicemails/process`\n\n`GET /voicemails`\n\n`GET /voicemails/<id>`\n\n`GET /routes`\n\n`GET /health`\n\nThis sample uses in-memory storage and a simple routing map.\n\nFor production, I would add:\n\nThe 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.\n\nResources:", "url": "https://wpnews.pro/news/route-voicemails-with-python-and-telnyx-ai", "canonical_source": "https://dev.to/sonam_50a41a4ced7e6b4f3fa/route-voicemails-with-python-and-telnyx-ai-39n1", "published_at": "2026-07-30 18:18:05+00:00", "updated_at": "2026-07-30 18:32:39.101597+00:00", "lang": "en", "topics": ["artificial-intelligence", "natural-language-processing", "developer-tools"], "entities": ["Telnyx", "Flask", "Python", "Slack", "GitHub"], "alternates": {"html": "https://wpnews.pro/news/route-voicemails-with-python-and-telnyx-ai", "markdown": "https://wpnews.pro/news/route-voicemails-with-python-and-telnyx-ai.md", "text": "https://wpnews.pro/news/route-voicemails-with-python-and-telnyx-ai.txt", "jsonld": "https://wpnews.pro/news/route-voicemails-with-python-and-telnyx-ai.jsonld"}}