
Telnyx has published a working example of an AI phone agent that handles price-quote calls end-to-end without a human. The agent answers, asks 3–4 qualifying questions, and delivers a structured JSON quote with line items and a monthly total before the caller hangs up. The quote is then extracted from the conversation and stored, making it immediately available via API for downstream billing or CRM systems.
Summaries like this, in your inbox every morning.
Sign up free →What happened
Telnyx released an open-source Python application (102 lines) that uses Telnyx Call Control and Llama 3.3 70B AI to answer incoming calls, ask qualifying questions, and generate structured price quotes in real time without human intervention. Callers hear text-to-speech greetings, speak naturally, and receive a quote with line items and monthly total before hanging up.
Why it matters
Traditional quote flows require web forms, email delays, or sales handoffs. This agent eliminates friction by conducting a conversational interview on the phone and extracting clean JSON quotes (with product, quantity, unit price, and subtotal) that are immediately accessible via API — ready to pipe into CRM systems or billing platforms. Businesses can customize the product catalog and questioning style by editing the system prompt.
What to watch
The app stores quotes in memory by default; production deployments will need a database (PostgreSQL or Redis), multi-worker concurrency (gunicorn), timeout handling, webhook signature verification, and integration with CRM systems like Salesforce or HubSpot. Code is available to clone and deploy locally with ngrok in minutes.
Telnyx released a complete, open-source example of an AI phone agent that answers incoming calls, conducts a conversational interview to gather requirements, and delivers a price quote with line items and a monthly total. The application is written in Python (102 lines in app.py), uses Telnyx Call Control to manage the phone interaction, and Llama 3.3 70B via Telnyx AI Inference to drive the conversation and extract structured data.
The workflow is straightforward: a caller dials the Telnyx phone number; the agent greets them with text-to-speech audio asking "What kind of communication services are you looking for?"; the caller responds with natural speech; the AI listens, maintains context across the conversation, and asks 3–4 follow-up questions to estimate quantities (e.g., "How many SMS messages per month?"); once the AI has enough information, it summarizes the quote with line items and a monthly total, again via text-to-speech.
The pricing catalog is built into the system prompt as a JSON object. In the example, it includes voice_minutes (0.005 per unit), SMS_messages (0.004), local_numbers (1.00), toll_free_numbers (2.00), SIP trunking channels (2.50), AI inference tokens (0.01 per 1k), cloud storage (0.05 per GB), and fax pages (0.07). The AI uses this catalog to calculate line-item subtotals and a monthly total on the fly. The system prompt also controls the AI's tone and behavior — instructing it to ask what the caller needs, estimate quantities, and summarize with line items and a monthly total, keeping responses under 2 sentences.
When the call ends, the app captures the entire conversation transcript and sends it back to the AI with a different system prompt: "Extract the price quote. Return JSON: line_items (list of {product, quantity, unit_price, subtotal}), monthly_total (number), notes (string)." The AI parses the transcript and outputs a clean JSON object with line items (each showing product, quantity, unit price, and subtotal), a monthly_total, and optional notes. The app then attaches the caller's phone number and a timestamp (in ISO 8601 format) and stores the quote. Quotes are accessible via a GET /quotes endpoint, which returns the last 20 quotes as JSON — ready to integrate with a CRM, billing system, or analytics dashboard.
The app runs as a Flask server that receives webhooks from Telnyx. The webhook handler is a state machine: on call.initiated, it answers the call and initializes a conversation history (with the system prompt); on call.answered, it speaks the greeting; on call.speak.ended, it gathers the caller's speech input; on call.gather.ended, it appends the speech to the conversation, calls the inference API, appends the response, and speaks it back; on call.hangup, it extracts the quote as JSON and stores it. The entire conversation history is passed to the inference API on each turn, so the AI maintains full context.
The article includes setup instructions: clone the GitHub repository, configure a .env file with Telnyx API key, public key, the AI model name (meta-llama/Llama-3.3-70B-Instruct), and a Telnyx phone number; install Python dependencies; start the Flask app; expose the local server with ngrok; and point the Call Control Application's webhook URL to the ngrok HTTPS URL. Once running, any caller can dial the Telnyx number and receive a quote.
Customization is straightforward: swap the PRICING dictionary to change products and unit costs, edit the SYSTEM_PROMPT to change the AI's questioning style or add discount logic, or add code to send the extracted quote via SMS after the call. The article also outlines production considerations: replace in-memory quote storage with a database (PostgreSQL or Redis), run the app behind gunicorn with multiple workers for concurrency, add error recovery for inference timeouts and call failures, validate API keys on the /quotes endpoint, verify Telnyx webhook signatures, test different system prompts and temperature settings, implement rate limiting, add structured logging and alerting on call success/failure rates, and integrate extracted quotes into CRM systems.
The article presents a working end-to-end example of an AI phone agent designed to eliminate friction from the price-quote sales process. Traditional flows require callers to fill out forms, wait for sales emails, or be transferred to a human — all friction points that reduce conversion. This agent runs a real-time voice conversation, adapts its questions based on the caller's responses (e.g., asking about SMS volume only if the caller mentioned SMS), and delivers a quote on the call itself.
The technical architecture is simple: incoming calls trigger Telnyx webhooks, which drive a state machine in a Flask app. Each event (call initiated, call answered, speech gathered, call ended) triggers the next action. The AI model (Llama 3.3 70B) handles two distinct tasks — conducting the conversation and extracting structured data from it afterward. The post-call extraction is the key innovation: rather than relying on the AI to produce structured JSON during the conversation (which could be error-prone), the app replays the transcript with a specific extraction prompt, yielding a clean, machine-readable quote object ready for integration with billing systems or CRMs.
For production, the article notes that in-memory storage must be replaced with a database, concurrency needs to be managed with a WSGI server (gunicorn), and error recovery and monitoring are essential. The customization surface — the system prompt and pricing catalog — is explicit, allowing businesses to adapt the agent to different product catalogs (consulting, SaaS, manufacturing) and questioning strategies without touching the core logic.
No comments yet. Be the first to share your thoughts!
Log in to join the discussion




Get curated AI news from 200+ sources delivered daily to your inbox. Free to use.
Get Started FreeFree · takes 30 seconds · unsubscribe anytime
1 minute a day. The AI essentials.
200+ sources · Email / LINE / Slack