Practice Negotiations with an AI Phone Agent — Real-Time Roleplay with Telnyx Voice AI | Low Latency Club
Skip to main content
Blog<br>Code-first technical deep dives
Glossary<br>Voice AI & telecom terminology
Developer Docs<br>API references & integration guides
GitHub<br>Open-source repos & SDKs
Articles<br>Tutorials & support articles
AI Agents<br>Build voice AI agents
Voice API<br>Programmable voice calls
ClawHouse<br>AI-powered voice assistant
ClawdTalk<br>Conversational AI platform
Events<br>Videos<br>Podcast<br>Integrations
Resources
Blog<br>Code-first technical deep dives
Glossary<br>Voice AI & telecom terminology
Developer Docs<br>API references & integration guides
GitHub<br>Open-source repos & SDKs
Articles<br>Tutorials & support articles
Products
AI Agents<br>Build voice AI agents
Voice API<br>Programmable voice calls
ClawHouse<br>AI-powered voice assistant
ClawdTalk<br>Conversational AI platform
Contact us<br>Join our Slack
Imagine picking up your phone, dialing a number, and practicing a salary negotiation against an AI that plays the hiring manager — one that pushes back on your first offer, counters with budget constraints, and then scores your technique after you hang up. No scheduling a mock interview, no paying a coach, no awkward roleplay with a colleague.
This is the AI Negotiation Practice Phone — a 110-line Python app built with Telnyx Call Control and AI Inference. Three scenarios (salary, sales deal, vendor contract), voice-driven conversation, and a structured performance score delivered after every call. The AI stays in character, adapts to your approach, and gives you actionable feedback.
In this walkthrough, you'll build it from scratch. Clone the repo, configure a phone number, and start practicing in minutes.
What You'll Build
A phone number anyone can call to practice negotiations:
Caller dials in — Telnyx answers and offers a menu
Scenario selection — press 1 for salary negotiation, 2 for sales deal, 3 for vendor contract
AI opens — the AI plays the opposing role (hiring manager, enterprise buyer, or vendor account manager) and makes an opening position
Live negotiation — caller speaks naturally, AI responds in character, pushes back, counters, and adapts
Post-call scoring — on hangup, the AI scores the negotiation across 5 dimensions and returns structured JSON
Session history — every practice session is stored and accessible via GET /sessions
The whole interaction is voice-driven: Text-to-Speech reads the AI's lines, and the caller responds with natural speech. The model (Llama 3.3 70B via Telnyx AI Inference) handles both the real-time roleplay and the post-call evaluation.
Why This Is Interesting
Most negotiation training tools are text-based chatbots or static video courses. Neither captures the pressure of a live conversation — the pauses, the pushback, the moment you have to think on your feet. This one puts you on a real phone call with an AI that has a budget, a role, and a hidden constraint (like "max 15% discount" or "budget is $155K with flexibility to $165K").
The scoring system makes it more than a conversation. After you hang up, the AI evaluates your performance across five dimensions — anchoring, concession strategy, active listening, creativity, and confidence — plus an overall score and specific strengths/improvements. You can practice the same scenario five times and track whether your technique improves.
It also demonstrates the DTMF + speech pattern: the app uses DTMF (keypad input) for scenario selection and speech recognition for the negotiation itself. This two-input pattern shows up in many real IVR workflows.
Prerequisites
Python 3.8+
A Telnyx account with funded balance
A Telnyx API key
A Telnyx phone number with voice enabled
A Call Control Application configured with your webhook URL
ngrok for exposing your local server to Telnyx webhooks
The Architecture
Phone Call<br>Telnyx Call Control (webhook events)<br>Flask app (app.py, 110 lines)<br>├──► call.initiated → answer the call<br>├──► call.answered → TTS menu (press 1, 2, or 3)<br>├──► call.speak.ended → gather DTMF (scenario selection)<br>├──► call.gather.ended → DTMF → pick scenario → AI opening line<br>│ └──► speech → AI inference → TTS response (negotiation loop)<br>└──► call.hangup → score negotiation as JSON → store<br>Telnyx AI Inference (Llama 3.3 70B)<br>Structured score (JSON with 5 dimensions + feedback)<br>The app is a state machine with two phases: selection (DTMF menu) and negotiating (speech conversation). Each Telnyx webhook event drives the next action. After hangup, the full conversation is sent to the AI with a scoring prompt that returns structured JSON.
Step 1: Clone and Configure
git clone https://github.com/team-telnyx/telnyx-code-examples.git<br>cd telnyx-code-examples/ai-negotiation-practice-phone-python<br>cp .env.example .env<br>pip install -r requirements.txt<br>Edit .env with your...