# Build a CDR Usage Analytics Dashboard in Python

> Source: <https://dev.to/sonam_50a41a4ced7e6b4f3fa/build-a-cdr-usage-analytics-dashboard-in-python-1cbh>
> Published: 2026-07-09 19:09:39+00:00

Raw Call Detail Records are useful, but they are not exactly fun to read.

If you are building with voice, messaging, or any communications workflow, CDR-style data can answer practical questions:

I put together a small Python example that turns Telnyx CDR data into a Flask analytics API, then uses Telnyx AI Inference to generate a short operational readout.

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

The example includes these routes:

```
GET /cdrs
GET /analytics/summary
GET /analytics/peak-hours
GET /analytics/top-routes
GET /analytics/daily
GET /analytics/ai-insights
GET /health
```

The analytics routes do the normal dashboard work in Python:

Then `/analytics/ai-insights`

takes a compact summary of the metrics and sends it to Telnyx AI Inference through the chat completions API.

Because the model should not be the calculator here.

For this kind of app, I like the split:

That way, your totals and costs stay deterministic, but your dashboard can still give users a helpful plain-English summary.

Clone the examples repo:

```
git clone https://github.com/team-telnyx/telnyx-code-examples.git
cd telnyx-code-examples/cdr-usage-analytics-dashboard-python
```

Create your `.env`

file:

```
cp .env.example .env
```

Add your Telnyx API key:

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

Install and run:

```
pip install -r requirements.txt
python app.py
```

Test it:

```
curl http://localhost:5000/health
```

Get a summary:

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

Ask for AI insights:

```
curl http://localhost:5000/analytics/ai-insights | python3 -m json.tool
```

This is intentionally small, but the pattern is useful:

The repo is also agent-readable, so you can point a coding agent at the example and ask it to extend the dashboard, add charts, wire in auth, or adapt the metrics to your own workflow.
