# Turn Phone Numbers into Lead Signals

> Source: <https://dev.to/sonam_50a41a4ced7e6b4f3fa/turn-phone-numbers-into-lead-signals-3f7k>
> Published: 2026-06-30 22:14:22+00:00

Subtitle: Build a Python app that combines Telnyx Number Lookup with Telnyx AI Inference to qualify leads and recommend the best follow-up channel.

A lead form usually gives you just enough information to create a question.

Someone 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?

That is the workflow behind this example:

[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)

It 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.

The app exposes three routes:

`POST /enrich`

for one phone number`POST /enrich/bulk`

for up to 50 phone numbers`GET /health`

for app healthIt uses two Telnyx APIs:

```
GET /v2/number_lookup/{phone}
POST /v2/ai/chat/completions
```

The current default model is set in `.env.example`

:

```
AI_MODEL=MiniMaxAI/MiniMax-M3-MXFP8
```

The pattern is simple: gather phone intelligence first, then use an inference model to turn that data into a lead-quality decision.

The request is intentionally small:

```
curl -X POST http://localhost:5000/enrich \
  -H "Content-Type: application/json" \
  -d '{
    "phone_number": "+12125550123"
  }'
```

The app looks up the number and extracts fields like carrier name, carrier type, caller name, line type, country, and validity.

Then it asks the model to return JSON like:

```
{
  "lead_quality": "hot",
  "reasoning": "Valid mobile number with usable carrier data",
  "is_mobile": true,
  "is_voip": false,
  "recommended_channel": "sms"
}
```

That 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.

Lead enrichment usually turns into a pile of small decisions:

Number Lookup gives you the underlying phone intelligence. AI Inference lets you apply a lightweight reasoning layer over that data.

That is a nice AI app pattern because the model is not doing everything. It is operating on structured context from a real API.

The app asks the model to return only JSON, with no prose and no markdown fences.

It 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.

The example keeps everything readable in one Flask app, which makes it easy to adapt.

For production, I would add:

The 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.

Code:

[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)

Telnyx AI skills and toolkits:

[https://github.com/team-telnyx/ai](https://github.com/team-telnyx/ai)

Number Lookup API:

[https://developers.telnyx.com/api/number-lookup/lookup](https://developers.telnyx.com/api/number-lookup/lookup)

Telnyx AI Inference docs:

[https://developers.telnyx.com/docs/inference](https://developers.telnyx.com/docs/inference)

Chat Completions API:

[https://developers.telnyx.com/api/inference/chat-completions](https://developers.telnyx.com/api/inference/chat-completions)

Telnyx Portal:

[https://portal.telnyx.com/](https://portal.telnyx.com/)
