{"slug": "build-a-cdr-usage-analytics-dashboard-in-python", "title": "Build a CDR Usage Analytics Dashboard in Python", "summary": "Telnyx published a Python example that builds a CDR usage analytics dashboard using Flask and Telnyx AI Inference. The dashboard provides routes for metrics like summary, peak hours, and top routes, and uses AI to generate plain-English operational insights from the data. The code is available on GitHub and designed to be extended by developers or coding agents.", "body_md": "Raw Call Detail Records are useful, but they are not exactly fun to read.\n\nIf you are building with voice, messaging, or any communications workflow, CDR-style data can answer practical questions:\n\nI 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.\n\nCode: [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)\n\nThe example includes these routes:\n\n```\nGET /cdrs\nGET /analytics/summary\nGET /analytics/peak-hours\nGET /analytics/top-routes\nGET /analytics/daily\nGET /analytics/ai-insights\nGET /health\n```\n\nThe analytics routes do the normal dashboard work in Python:\n\nThen `/analytics/ai-insights`\n\ntakes a compact summary of the metrics and sends it to Telnyx AI Inference through the chat completions API.\n\nBecause the model should not be the calculator here.\n\nFor this kind of app, I like the split:\n\nThat way, your totals and costs stay deterministic, but your dashboard can still give users a helpful plain-English summary.\n\nClone the examples repo:\n\n```\ngit clone https://github.com/team-telnyx/telnyx-code-examples.git\ncd telnyx-code-examples/cdr-usage-analytics-dashboard-python\n```\n\nCreate your `.env`\n\nfile:\n\n```\ncp .env.example .env\n```\n\nAdd your Telnyx API key:\n\n```\nTELNYX_API_KEY=your_telnyx_api_key\nAI_MODEL=moonshotai/Kimi-K2.6\nHOST=127.0.0.1\n```\n\nInstall and run:\n\n```\npip install -r requirements.txt\npython app.py\n```\n\nTest it:\n\n```\ncurl http://localhost:5000/health\n```\n\nGet a summary:\n\n```\ncurl \"http://localhost:5000/analytics/summary?start_date=2026-07-01&end_date=2026-07-08\" | python3 -m json.tool\n```\n\nAsk for AI insights:\n\n```\ncurl http://localhost:5000/analytics/ai-insights | python3 -m json.tool\n```\n\nThis is intentionally small, but the pattern is useful:\n\nThe 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.", "url": "https://wpnews.pro/news/build-a-cdr-usage-analytics-dashboard-in-python", "canonical_source": "https://dev.to/sonam_50a41a4ced7e6b4f3fa/build-a-cdr-usage-analytics-dashboard-in-python-1cbh", "published_at": "2026-07-09 19:09:39+00:00", "updated_at": "2026-07-09 20:06:03.775403+00:00", "lang": "en", "topics": ["developer-tools", "artificial-intelligence", "ai-tools"], "entities": ["Telnyx", "Flask", "GitHub", "Telnyx AI Inference"], "alternates": {"html": "https://wpnews.pro/news/build-a-cdr-usage-analytics-dashboard-in-python", "markdown": "https://wpnews.pro/news/build-a-cdr-usage-analytics-dashboard-in-python.md", "text": "https://wpnews.pro/news/build-a-cdr-usage-analytics-dashboard-in-python.txt", "jsonld": "https://wpnews.pro/news/build-a-cdr-usage-analytics-dashboard-in-python.jsonld"}}