Building Voice Agents That Close Sales: A Technical Deep Dive
From conversation to payment in one call. How we integrated ElevenLabs, Twilio, and Stripe to create autonomous voice agents that generate revenue 24/7.
The Problem with Current Voice Agents
Most voice agents today can do one thing well: have conversations. They can qualify leads, answer questions, and route calls. But the moment someone says "I want to buy," they hit a wall.
The agent has to transfer to a human. The human has to process the payment. And in that transition, you lose 30-40% of your conversions. The momentum dies.
The Conversion Killer
Every transfer point in a sales process is a leak. When you hand off from AI to human for payment processing, you're adding friction at the exact moment the customer is ready to commit.
Our Solution: Sofia AI
Sofia is a voice agent that can take a sale from "hello" to payment confirmation without any human intervention. Here's the architecture:
The Tech Stack
┌────────────────────────────────────────────┐
│ INCOMING CALL │
│ (Twilio Programmable Voice) │
└─────────────────────┬──────────────────────┘
│
▼
┌────────────────────────────────────────────┐
│ ELEVENLABS VOICE AI │
│ - Natural conversation │
│ - Emotion detection │
│ - Real-time transcription │
└─────────────────────┬──────────────────────┘
│
▼
┌────────────────────────────────────────────┐
│ FASTAPI BACKEND │
│ - Session management │
│ - Product catalog │
│ - Objection handling logic │
└─────────────────────┬──────────────────────┘
│
┌─────────────┴─────────────┐
▼ ▼
┌───────────────┐ ┌───────────────┐
│ STRIPE API │ │ TWILIO SMS │
│ - Payment │ │ - Send link │
│ - Webhooks │ │ - Confirm │
└───────┬───────┘ └───────────────┘
│
▼
┌────────────────────────────────────────────┐
│ REAL-TIME CONFIRMATION │
│ Sofia confirms payment in same call │
└────────────────────────────────────────────┘The Magic: Push-to-Link Payments
The key innovation is what we call "Push-to-Link" payments. When the customer expresses intent to buy, Sofia:
- Generates a Stripe Payment Link with the exact items discussed
- Sends it via SMS to the customer's phone - while they're still on the call
- Keeps them engaged: "I just sent you a payment link. You can open it now."
- Monitors Stripe webhooks for payment confirmation
- Confirms the purchase in the same conversation: "Got it! Your order is confirmed."
The customer never hangs up. The transition from "I want this" to "I bought this" happens in under 60 seconds.
Technical Implementation Details
1. ElevenLabs Conversational AI
We use ElevenLabs' Conversational AI with a custom voice model trained on sales conversations. Key configuration:
{
"voice_settings": {
"stability": 0.75,
"similarity_boost": 0.8,
"style": 0.4,
"use_speaker_boost": true
},
"conversation": {
"first_message": "Hola, gracias por llamar...",
"system_prompt": "You are Sofia, a sales agent...",
"tools": ["create_payment_link", "send_sms"]
}
}2. Stripe Payment Links API
We create dynamic payment links on-the-fly with customer-specific metadata:
async def create_payment_link(items, customer_phone):
link = await stripe.PaymentLink.create(
line_items=[{
"price": item["stripe_price_id"],
"quantity": item["quantity"]
} for item in items],
metadata={
"call_id": current_call.id,
"customer_phone": customer_phone
},
after_completion={
"type": "redirect",
"redirect": {"url": "https://thanks.page"}
}
)
return link.url3. Real-Time Webhook Handling
The backend listens for Stripe webhooks and notifies the voice agent in real-time:
@app.post("/webhook/stripe")
async def handle_stripe_webhook(request: Request):
event = stripe.Event.construct_from(
await request.json(),
stripe.api_key
)
if event.type == "checkout.session.completed":
call_id = event.data.object.metadata.get("call_id")
# Notify the voice agent
await elevenlabs.send_tool_result(
call_id=call_id,
tool="payment_confirmed",
result={"status": "success"}
)
return {"received": True}Results
Try It Live
You can call Sofia right now and experience the full flow:
Want to Build Something Similar?
I help businesses implement voice AI agents for sales, support, and lead qualification. If you're interested in deploying this technology for your use case, let's talk.