ENGINEERING BLUEPRINT · VOICE AGENT MVP

From AI Studio to
working voice MVP.

The step-by-step technical guide to wrapping Gemini Live WebSocket streaming into a high-performance browser interface for Priya PharmaGrow.

AUTOMATELY / G01
01NEW ENQUIRYDetails capturedCalls · Forms · Messages
02FOLLOW-UPNeed understoodQuestions · Preferences · Timing
03TEAM ACTIONNext step assignedOwner notified · Context attached
✳A CLEARER
CUSTOMER WORKFLOW
11 Steps · Engineering Guide ~2 Hours to Working Prototype Stack: Node.js + WebSocket + Gemini Live
01 Understand what you actually have ↓

The code AI Studio gave you is a Node.js script — it runs on a server, not in a browser. It connects to Gemini Live via WebSocket, sends a text message, gets an audio response, and saves it as a WAV file. That’s the core engine. Your MVP needs to take this engine and wrap a browser UI around it so a client can open a webpage, click a button, speak, and hear Priya respond.

02 The architecture you're building ↓

The browser cannot talk to Gemini Live directly — CORS blocks it. Your Node.js server sits in the middle and relays audio both ways.

Browser (landing page)
  ↕ WebSocket
Node.js server (your bridge)
  ↕ WebSocket
Gemini Live API
03 Set up your local environment ↓

On your Mac, open Terminal and create a new project folder, then install dependencies:

mkdir pharmagrow-voice-agent
cd pharmagrow-voice-agent
npm init -y
npm install @google/genai ws express
npm install -D typescript @types/node ts-node
04 Set your API key ↓

Never hardcode the key in code. Set it as an environment variable in your terminal:

export GEMINI_API_KEY="AIzaSy..."
05 Fix the model name in SDK code ↓

The model name gemini-3.1 does not exist in standard SDKs. Use the stable Live API model identifier:

// Stable Live API model identifier
const model = 'models/gemini-2.0-flash-live-001';
06 The two files you need to write ↓

1. server.ts (Node.js backend): Serves landing page HTML, opens WebSocket server, connects Gemini Live session. 2. index.html (browser landing page): Shows PharmaGrow branding, captures mic audio via MediaRecorder, plays received audio.

07 Understand the audio format conversions ↓

Browser MediaRecorder outputs: audio/webm or audio/ogg. Gemini Live API expects: Raw PCM at 16kHz, 16-bit, mono. Gemini Live API returns: Raw PCM at 24kHz, 16-bit, mono. Your server converts webm → PCM 16kHz via ffmpeg.

brew install ffmpeg
08 The exact relay flow in server.ts ↓

1. Browser connects via WebSocket to ws://localhost:3000
   ↓
2. Server opens a Gemini Live session via session = await ai.live.connect()
   ↓
3. Browser sends { type: 'audio', data: base64webm }
   ↓
4. Server converts webm → PCM 16kHz
   ↓
5. Server sends PCM to Gemini via session.sendRealtimeInput()
   ↓
6. Gemini returns audio chunks (handleModelTurn)
   ↓
7. Server wraps each chunk in WAV header
   ↓
8. Server sends { type: 'audio', data: base64wav } to browser
   ↓
9. Browser decodes base64 and plays audio via AudioContext
09 Run and test locally first ↓

Once server.ts is written, start it locally and test microphone input:

npx ts-node server.ts
# Open http://localhost:3000 and test speaking to Priya
10 Deploy to DigitalOcean or VPS for client demo ↓

Push the project to your droplet, install dependencies, and run with pm2 for persistent uptime:

npm install -g pm2
pm2 start "npx ts-node server.ts" --name pharmagrow-agent
11 What to show the client — the 5 demo questions ↓

Have the client ask these five questions in order to demonstrate maximum value:

01
"What territories are available in Haryana?" Tests Knowledge Base accuracy
02
"How much investment do I need for a franchise?" Tests numbers & tier handling
03
"Tell me about your quality certifications (WHO-GMP / ISO)" Tests concise answer synthesis
04
"Do I get exclusive monopoly rights in my district?" Tests franchise agreement terms
05
"How do I place an opening order and get started?" Tests operational booking flow

Ready to deploy a custom voice assistant?

Automately configures production telephony, WhatsApp workflows, and CRM synchronisation tailored for your industry.

Schedule a Technical Walkthrough ↗