A complete voice agent system built with Moss Voice Platform, featuring a Python-based agent deployment manager and a Next.js web interface for real-time voice interactions.
- Overview
- Architecture
- Prerequisites
- Getting Started
- Part 1: Deploy the Voice Agent (Manager)
- Part 2: Run the Web Interface (Agent UI)
- Voice Server Package (@moss-tools/voice-server)
- Customizing Your Agent
- Additional Resources
- Support
- Manager (Python): Deploys voice agent with custom tools
- Agent UI (Next.js): Web interface for voice interactions
Manager (Python) β Moss Platform β Agent UI (Next.js)
- Python+ (for Manager)
- Node.js+ (for Agent UI)
- pnpm (package manager for Agent UI)
- Git (optional, for version control)
You'll need three pieces of information from your Moss Platform account:
- MOSS_PROJECT_ID - Your project UUID
- MOSS_PROJECT_KEY - Your project read key (starts with
moss_) - MOSS_VOICE_AGENT_ID - Your voice agent UUID
How to get these:
- Sign up at Moss Platform
- Create a new project
- Navigate to your project settings to find your Project ID, API Key and Voice Agent ID
cd voice-manage-testYour project structure should look like this:
voice-manage-test/
βββ manager/ # Python deployment manager
β βββ main.py # Agent deployment script
β βββ pyproject.toml # Python dependencies
β βββ .env # Environment variables
βββ agent-ui/ # Next.js web interface
βββ app/ # Next.js app directory
βββ package.json # Node dependencies
βββ .env.local # Environment variables
The Manager is a Python script that deploys your voice agent configuration to the Moss Platform.
cd managerCreate or edit the .env file with your Moss credentials:
# manager/.env
MOSS_PROJECT_ID=your-project-uuid-here
MOSS_PROJECT_KEY=moss_your-project-key-here
MOSS_VOICE_AGENT_ID=your-voice-agent-uuid-here# Create a Python virtual environment using uv
uv venv
# Activate the virtual environment
# On macOS/Linux:
source .venv/bin/activate
# On Windows:
# .venv\Scripts\activate# Install required Python packages from PyPI
uv pip install moss-voice-agent-manager python-dotenv
This will install:
- `moss-voice-agent-manager` - SDK for deploying agents
- `python-dotenv` - For loading environment variables
### Step 1.5: Deploy Your Agent
```bash
python main.pyExpected Output:
============================================================
π Deploying voice agent with custom tools
============================================================
β
Deployment successful!
π― Voice Agent ID: 9c11b621-44bf-42ee-9e40-9b81804b48f0
============================================================
# From the manager directory, go back and enter agent-ui
cd ../agent-uiCreate or edit .env.local with your Moss credentials:
# agent-ui/.env.local
MOSS_PROJECT_ID=your-project-uuid-here
MOSS_PROJECT_KEY=moss_your-project-key-here
MOSS_VOICE_AGENT_ID=your-voice-agent-uuid-hereNote: Use the same credentials as manager/.env
pnpm installpnpm devExpected Output:
β² Next.js 15.5.9
- Local: http://localhost:3000
- Environments: .env.local
β Starting...
β Ready in 2.3s
- Open your web browser
- Navigate to: http://localhost:3000
- You should see the voice agent interface
- Click the "Start" button
- Allow microphone access when prompted
- Start speaking to the agent
The Agent UI uses @moss-tools/voice-server to connect to your deployed agent.
- app/api/connection-details/route.ts - Creates voice server connections
- lib/utils.ts - Handles token fetching
import { MossVoiceServer } from "@moss-tools/voice-server";
// Create voice server instance
const voiceServer = await MossVoiceServer.create({
projectId: process.env.MOSS_PROJECT_ID!,
projectKey: process.env.MOSS_PROJECT_KEY!,
voiceAgentId: process.env.MOSS_VOICE_AGENT_ID!,
});
// Get server URL
const serverUrl = voiceServer.getServerUrl();
// Create participant token
const participantToken = await voiceServer.createParticipantToken(
{ identity: participantIdentity, name: participantName },
roomName,
agentName
);{
serverUrl: string;
roomName: string;
participantName: string;
participantToken: string;
}Edit manager/main.py to add new functions:
def get_weather(city: str) -> str:
"""Get current weather for a city."""
# Your implementation here
return f"The weather in {city} is sunny!"
def main():
# ... existing code ...
response = client.deploy(
voice_agent_id=voice_agent_id,
prompt="Updated prompt mentioning weather...",
initial_greeting="Hello! I can help with age, discounts, and weather!",
function_tools=[
get_user_age,
calculate_discount,
get_weather # Add your new tool
],
)Requirements for tool functions:
- Must have type hints for parameters
- Must have a docstring (used by LLM to understand the tool)
- Must return a string (the agent will speak this)
Modify the prompt parameter in manager/main.py:69:
response = client.deploy(
voice_agent_id=voice_agent_id,
prompt="""You are a professional financial advisor named Alex.
You help users with calculations and provide detailed explanations.
Always be formal and precise in your responses.""",
initial_greeting="Good day! I'm Alex, your financial advisor. How may I assist you?",
function_tools=[get_user_age, calculate_discount],
)The UI components are in agent-ui/app directory:
- Modify styling in Tailwind classes
- Customize components in
agent-ui/components/ - Update layout and branding as needed
After making changes:
# 1. Re-deploy the agent (if you changed tools/prompt)
cd manager
python main.py
# 2. Restart the UI (if you changed UI code)
cd ../agent-ui
# Stop the dev server (Ctrl+C) and restart
pnpm devvoice-manage-test/
βββ manager/
β βββ main.py # Agent deployment script
β βββ pyproject.toml # Python dependencies & project config
β βββ .env # Environment variables (gitignored)
β βββ .venv/ # Python virtual environment
β βββ README.md # (create for manager-specific docs)
β
βββ agent-ui/
βββ app/
β βββ api/
β β βββ connection-details/
β β βββ route.ts # API endpoint for voice connections
β βββ page.tsx # Main page component
βββ components/ # React components
βββ lib/ # Utility functions
βββ public/ # Static assets
βββ package.json # Node dependencies
βββ .env.local # Environment variables (gitignored)
βββ README.md # (create for UI-specific docs)
If you encounter issues:
- Check the troubleshooting section above
- Review Moss Platform documentation for credential setup
- Check browser console for client-side errors
- Check terminal output for server-side errors
- Verify environment variables match between manager and agent-ui