04 — Technical Showcase

Unified Multimodal AI Agent

Engineering the bridge between conversational text AI and real-time voice telephony. A complete system that transitions a WhatsApp chat into a live AI voice call — using Twilio SIP Domains, ElevenLabs, and LLM orchestration.

  • Stages

    5

  • Integrations

    Twilio · ElevenLabs · LLM

  • Modes

    Text + Voice

System Architecture Flow

  1. 01

    WhatsApp Message Arrives

    User sends a message via WhatsApp Business API. The webhook fires to our FastAPI ingestion service, parsing intent, language, and context in real-time.

    • WhatsApp Business API
    • FastAPI
    • Webhook Handler
  2. 02

    LLM Reasoning Layer

    The message payload hits the LLM orchestration layer (OpenAI GPT-4o / Google Gemini 1.5). The model decides: generate a text reply, or trigger the voice pipeline? Intent classification happens here.

    • OpenAI GPT-4o
    • Google Gemini 1.5
    • LangChain
    • Intent Routing
  3. 03

    Voice Synthesis via ElevenLabs

    When the voice path is chosen, the LLM-generated text response is passed to ElevenLabs streaming API. A cloned or multilingual voice renders the response as a high-fidelity WAV/MP3 audio stream.

    • ElevenLabs Streaming API
    • Voice Cloning
    • Text-to-Speech
    • SSML
  4. 04

    Twilio SIP Domain Routing

    A Twilio SIP Domain is configured as the PSTN bridge. The audio stream is routed via TwiML — the call is initiated to the user's number with the ElevenLabs-generated voice. Real-time bidirectional audio over WebRTC/SIP.

    • Twilio SIP Domains
    • TwiML
    • WebRTC
    • PSTN Bridge
  5. 05

    User Receives Voice Call

    The agent delivers the AI-generated voice response as a real phone call. The user can interact back (speech-to-text via Whisper), creating a full conversational loop — from text message to live phone AI agent.

    • OpenAI Whisper STT
    • Real-time ASR
    • Conversation Memory
    • Context Window
orchestrator.pyPython
# Simplified orchestration flow
async def handle_whatsapp_message(payload: WebhookPayload):
# 1. Parse intent with LLM
intent = await llm_router.classify(payload.body)
if intent.requires_voice:
# 2. Generate response text
response = await openai_client.chat.completions.create(
model="gpt-4o",
messages=build_conversation(payload)
)
# 3. Synthesize voice via ElevenLabs
audio_stream = await elevenlabs.generate(
text=response.choices[0].message.content,
voice="ankush-custom-voice",
stream=True
)
# 4. Initiate Twilio SIP call
call = twilio_client.calls.create(
twiml=build_twiml(audio_stream),
to=payload.from_number,
from_=settings.TWILIO_SIP_DOMAIN
)
return {"call_sid": call.sid, "status": "voice_delivered"}
return await send_whatsapp_reply(payload, intent.text_response)
⚡

Real-time streaming

ElevenLabs audio streamed directly into Twilio TwiML — sub-2s latency voice delivery

🔁

Bidirectional loop

Whisper STT captures user's spoken reply, routes back to LLM for context-aware follow-up

🌐

Multilingual ready

ElevenLabs multilingual v2 + Gemini enable native voice responses in 29+ languages