← Back to list

Your Call Data Should Explain Itself

Build a CDR usage analytics dashboard with Python, Flask, and Telnyx AI Inference.

Sonam G. · 2026-07-09 19:16 · 0 claps · 1.4 min read
#llm-inference #llm #telnyx
Open on Medium ↗
Wiki topics: LLM · Large Language Models OPS · LLMOps & Inference GRW · Growth & Analytics 🌐 · Web Development 🎬 · Film & Television

Your Call Data Should Explain Itself

Build a CDR usage analytics dashboard with Python, Flask, and Telnyx AI Inference.

Call Detail Records are one of the most useful datasets in a communications product, but they usually start life in a format built for systems, not people.

They know how many calls happened. They know when traffic peaked. They know which routes were used, which calls were short, which ones failed, and what the usage cost. But if you hand raw CDRs to a developer, support engineer, or ops team, the first step is usually the same: turn the records into something a human can scan.

That is what this example does.

I built a small Python Flask app that pulls Telnyx CDR data, calculates useful usage metrics, and adds an AI insights endpoint on top with Telnyx AI Inference.

Code: https://github.com/team-telnyx/telnyx-code-examples/tree/main/cdr-usage-analytics-dashboard-python

The app idea

The app exposes a few endpoints that are shaped for a dashboard:

  • /cdrs for retrieving records in a date range
  • /analytics/summary for call count, duration, cost, and grouped status metrics
  • /analytics/peak-hours for hourly traffic patterns
  • /analytics/top-routes for route-level activity
  • /analytics/daily for daily call and cost totals
  • /analytics/ai-insights for a short AI-generated interpretation of the usage pattern

The goal is not to make a giant BI system. It is to show the foundation of one.

The important part: split the work

For analytics apps, I do not want the model doing arithmetic.

The deterministic part belongs in code: total calls, total cost, average duration, median duration, p95 duration, busiest hours, and top routes.

Then the model gets a compact summary and does the thing models are actually good at: explaining what the pattern may mean and suggesting what to investigate.

How to try it

git clone https://github.com/team-telnyx/telnyx-code-examples.git
cd telnyx-code-examples/cdr-usage-analytics-dashboard-python
cp .env.example .env
pip install -r requirements.txt
python app.py

Add your Telnyx API key in .env:

TELNYX_API_KEY=your_telnyx_api_key
AI_MODEL=moonshotai/Kimi-K2.6
HOST=127.0.0.1

Try it:

curl http://localhost:5000/health
curl "http://localhost:5000/analytics/summary?start_date=2026-07-01&end_date=2026-07-08" | python3 -m json.tool
curl http://localhost:5000/analytics/ai-insights | python3 -m json.tool

Resources

Telnyx AI skills and toolkits: https://github.com/team-telnyx/ai

Telnyx AI Inference docs: https://developers.telnyx.com/docs/inference

Chat Completions API: https://developers.telnyx.com/api/inference/chat-completions

Telnyx Portal: https://portal.telnyx.com/


메타데이터
post_id
ac2beb414d9e
slug
your-call-data-should-explain-itself-ac2beb414d9e
url
https://medium.com/@sonam.gupta1105/your-call-data-should-explain-itself-ac2beb414d9e
canonical_url
https://medium.com/@sonam.gupta1105/your-call-data-should-explain-itself-ac2beb414d9e
author_url
https://medium.com/@sonam.gupta1105
status
ok
fetched_at
2026-07-14 19:29:30