This repository serves as a reference implementation for integrating function calling capabilities with Deepgram's Voice Agent API. It demonstrates production-ready patterns for building AI Voice Agent applications with clientside function calling.
This reference implementation demonstrates:
- Core function calling patterns with Voice Agent API
- Natural conversation flow using agent filler messages
- Customer information lookup and verification
- Order history retrieval
- Appointment scheduling and management
- Graceful conversation termination through an
end_call
function
The implementation uses a three-layer architecture:
- Function definitions that guide the LLM's behavior
- Function handlers that route requests
- Business logic that executes the actual functionality
Shows how to implement natural dialogue patterns:
- Agent filler messages for lookup operations
- Proper message sequencing
- Audio completion handling
- Clean session termination
├── business_logic.py # Core function implementations
├── client.py # WebSocket client and message handling
├── config.py # Configuration settings
├── functions.py # Function definitions and routing
The implementation uses a mock data system for demonstration:
- Generates realistic customer, order, and appointment data
- Saves data to timestamped JSON files in
mock_data_outputs/
- Configurable through
config.py
The implementation demonstrates how to handle real-world latency:
- Configurable database operation delays in
config.py
- Helps simulate production environment timing
- Install the dependencies:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
- Set your Deepgram API key:
export DEEPGRAM_API_KEY=<your-key-here>
-
Run the client:
python client.py
-
Use headphones to prevent audio feedback (the agent hearing itself).
The voice agent handles natural conversations like:
User: "I need to check my order status"
Agent: "Let me look that up for you..."
[Agent executes customer lookup]
Agent: "I can see you have two recent orders. Your most recent
order from last week is currently being shipped..."
Key settings in config.py
:
ARTIFICIAL_DELAY
: Configurable delays for database operationsMOCK_DATA_SIZE
: Control size of generated test data