{"slug": "turn-phone-numbers-into-lead-signals", "title": "Turn Phone Numbers into Lead Signals", "summary": "Telnyx released a Python Flask app that combines Number Lookup and AI Inference to enrich phone numbers and qualify leads. The app scores lead quality and recommends a follow-up channel (SMS or voice) by first gathering carrier and line-type data, then passing it to an AI model for structured JSON output. It exposes endpoints for single and bulk enrichment, and the code is designed to be easily extended for production use.", "body_md": "Subtitle: Build a Python app that combines Telnyx Number Lookup with Telnyx AI Inference to qualify leads and recommend the best follow-up channel.\n\nA lead form usually gives you just enough information to create a question.\n\nSomeone enters a name, an email address, maybe a phone number, and maybe a note about what they want. Now the app has to decide what happens next. Does this lead go to sales? Should the first touch be SMS or voice? Is the phone number even usable?\n\nThat is the workflow behind this example:\n\n[https://github.com/team-telnyx/telnyx-code-examples/tree/main/number-lookup-lead-enrichment-python](https://github.com/team-telnyx/telnyx-code-examples/tree/main/number-lookup-lead-enrichment-python)\n\nIt is a small Python Flask app that takes a phone number, enriches it with Telnyx Number Lookup, then uses Telnyx AI Inference to score the lead and recommend a follow-up channel.\n\nThe app exposes three routes:\n\n`POST /enrich`\n\nfor one phone number`POST /enrich/bulk`\n\nfor up to 50 phone numbers`GET /health`\n\nfor app healthIt uses two Telnyx APIs:\n\n```\nGET /v2/number_lookup/{phone}\nPOST /v2/ai/chat/completions\n```\n\nThe current default model is set in `.env.example`\n\n:\n\n```\nAI_MODEL=MiniMaxAI/MiniMax-M3-MXFP8\n```\n\nThe pattern is simple: gather phone intelligence first, then use an inference model to turn that data into a lead-quality decision.\n\nThe request is intentionally small:\n\n```\ncurl -X POST http://localhost:5000/enrich \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"phone_number\": \"+12125550123\"\n  }'\n```\n\nThe app looks up the number and extracts fields like carrier name, carrier type, caller name, line type, country, and validity.\n\nThen it asks the model to return JSON like:\n\n```\n{\n  \"lead_quality\": \"hot\",\n  \"reasoning\": \"Valid mobile number with usable carrier data\",\n  \"is_mobile\": true,\n  \"is_voip\": false,\n  \"recommended_channel\": \"sms\"\n}\n```\n\nThat response is much easier to build with than a paragraph. A product can route it, store it, show it in a CRM, or use it to kick off a workflow.\n\nLead enrichment usually turns into a pile of small decisions:\n\nNumber Lookup gives you the underlying phone intelligence. AI Inference lets you apply a lightweight reasoning layer over that data.\n\nThat is a nice AI app pattern because the model is not doing everything. It is operating on structured context from a real API.\n\nThe app asks the model to return only JSON, with no prose and no markdown fences.\n\nIt still includes a helper to strip markdown fences and parse the JSON object. I like that because AI app code should be defensive. Prompts reduce variance, but validation is what keeps the output safe to use in an application.\n\nThe example keeps everything readable in one Flask app, which makes it easy to adapt.\n\nFor production, I would add:\n\nThe repo is also structured to be agent-readable. Your coding agent can inspect the README, API reference, guide, environment file, and app code, then help extend it. You can ask it to add CRM writes, tests, stricter validation, or a scheduled enrichment job.\n\nCode:\n\n[https://github.com/team-telnyx/telnyx-code-examples/tree/main/number-lookup-lead-enrichment-python](https://github.com/team-telnyx/telnyx-code-examples/tree/main/number-lookup-lead-enrichment-python)\n\nTelnyx AI skills and toolkits:\n\n[https://github.com/team-telnyx/ai](https://github.com/team-telnyx/ai)\n\nNumber Lookup API:\n\n[https://developers.telnyx.com/api/number-lookup/lookup](https://developers.telnyx.com/api/number-lookup/lookup)\n\nTelnyx AI Inference docs:\n\n[https://developers.telnyx.com/docs/inference](https://developers.telnyx.com/docs/inference)\n\nChat Completions API:\n\n[https://developers.telnyx.com/api/inference/chat-completions](https://developers.telnyx.com/api/inference/chat-completions)\n\nTelnyx Portal:\n\n[https://portal.telnyx.com/](https://portal.telnyx.com/)", "url": "https://wpnews.pro/news/turn-phone-numbers-into-lead-signals", "canonical_source": "https://dev.to/sonam_50a41a4ced7e6b4f3fa/turn-phone-numbers-into-lead-signals-3f7k", "published_at": "2026-06-30 22:14:22+00:00", "updated_at": "2026-06-30 22:18:42.569094+00:00", "lang": "en", "topics": ["artificial-intelligence", "developer-tools", "ai-products"], "entities": ["Telnyx", "Telnyx Number Lookup", "Telnyx AI Inference", "MiniMaxAI/MiniMax-M3-MXFP8", "Python", "Flask"], "alternates": {"html": "https://wpnews.pro/news/turn-phone-numbers-into-lead-signals", "markdown": "https://wpnews.pro/news/turn-phone-numbers-into-lead-signals.md", "text": "https://wpnews.pro/news/turn-phone-numbers-into-lead-signals.txt", "jsonld": "https://wpnews.pro/news/turn-phone-numbers-into-lead-signals.jsonld"}}