Author: Cole Medin
For detailed information about the Voiceflow Dialog API and how to best utilize it with your Voiceflow agents, refer to the official Voiceflow Dialog API documentation.
This integration provides seamless connectivity between Voiceflow agents and the Live Agent Studio. The key feature of this integration is its zero-configuration approach - once you build an agent in Voiceflow, it's immediately ready to use in the Live Agent Studio without any additional setup or customization.
This API endpoint demonstrates the implementation details of how Voiceflow agents are integrated with the Live Agent Studio. While you don't need to modify this code to use your Voiceflow agents, understanding how it works can be valuable for advanced use cases.
This integration enables:
- Instant deployment of Voiceflow agents to Live Agent Studio
- Real-time conversation handling through Voiceflow's Dialog API
- Automatic message history tracking
- Support for rich responses (text, buttons, carousels - future enhancement)
- Secure API authentication
- Session management for maintaining conversation context
- Python 3.11 or higher
- pip (Python package manager)
- Supabase account (for conversation storage)
- Voiceflow account with an API key
- Basic understanding of:
- FastAPI and async Python
- RESTful APIs
- Voiceflow Dialog API
The integration is built using FastAPI, providing:
-
Voiceflow Integration
- Dialog API communication
- Session state management
- Rich response handling
-
Authentication
- Bearer token validation
- Secure endpoint protection
- API key management
-
Database Integration
- Supabase connection for message storage
- Conversation history tracking
- Session management
class AgentRequest(BaseModel):
query: str # The user's input text or JSON action
user_id: str # Unique identifier for the user
request_id: str # Unique identifier for this request
session_id: str # Current conversation session ID
class AgentResponse(BaseModel):
success: bool # Indicates if the request was processed successfully
The integration uses Supabase tables with the following structure:
messages (
id: uuid primary key
created_at: timestamp with time zone
session_id: text
message: jsonb {
type: string # 'human' or 'assistant'
content: string # The message content
data: jsonb # Voiceflow response data
}
)
The VoiceflowFrontendComponent.tsx
demonstrates how Voiceflow traces from the Dialog API are integrated with the Live Agent Studio frontend. This component serves as an example of creating custom frontend components to display rich responses from your agent using the data
field of the AI response instead of raw text output.
- Handles various Voiceflow trace types (text, choice, knowledgeBase)
- Renders interactive buttons for choice responses
- Processes structured message data from Voiceflow's Dialog API
- Maintains conversation context through session management
interface VoiceflowTrace {
type: string;
payload: {
message?: string;
slate?: {
content: Array<{
children: Array<{
text: string;
}>;
}>;
};
buttons?: VoiceflowButton[];
};
}
// Component renders different UI elements based on trace type
const renderTrace = (trace: VoiceflowTrace) => {
switch (trace.type) {
case 'text':
return <p>{trace.payload.message}</p>;
case 'choice':
return <ButtonGroup buttons={trace.payload.buttons} />;
// ... handle other trace types
}
};
-
Environment Variables Create a
.env
file with:SUPABASE_URL=your_supabase_url SUPABASE_SERVICE_KEY=your_supabase_key API_BEARER_TOKEN=your_api_token VOICEFLOW_AGENT_API_KEY=your_voiceflow_api_key
-
Local Development
# Install dependencies pip install -r requirements.txt # Run the server python voiceflow_integration.py
-
Docker Deployment
# Build the container docker build -t voiceflow-integration . # Run the container docker run -d --name voiceflow-integration -p 8001:8001 --env-file .env voiceflow-integration
- Create and publish your agent in Voiceflow
- Copy your Dialog API key from Voiceflow
- Add the API key to your environment variables
- Your agent is now ready to use in the Live Agent Studio!
Handles all communication between Live Agent Studio and your Voiceflow agent.
Request:
{
"query": "Hello!",
"user_id": "user123",
"request_id": "req123",
"session_id": "sess123"
}
Response:
{
"success": true
}
This agent is part of the oTTomator agents collection. For contributions or issues, please refer to the main repository guidelines.