AI Agents Module Documentation
Table of Contents
- Module Overview (Technical)
- Module Overview (Commercial/Business)
- Module Overview (End User/Administrator)
- Configuration Sections
- Settings Reference
- Common Scenarios & Examples
- Limitations & Important Notes
- Troubleshooting Tips
- Glossary
---
1. Module Overview (Technical)
What Are AI Agents?
AI Agents is a conversational AI management module that enables real-time voice conversations between callers and AI assistants powered by OpenAI's Realtime API. Each agent has a unique persona, voice, behavioral rules, and can be reached via a dedicated extension.
Architecture
Key Tables
| Table | Purpose | |
|---|---|---|
public.ai_agents | Agent configuration & persona | |
public.ai_profiles | AI service profiles (linked) | |
public.ai_providers | API credentials (linked) |
Key Files
| File | Description | |
|---|---|---|
modules/ai-agents/ | Frontend module | |
api/telephony/ai-agents/ | Backend service | |
lua/ai/ai_realtime_handler.lua | FreeSWITCH Lua handler | |
mod_openai_realtime | Native C/C++ FreeSWITCH module |
Module Dependency
---
2. Module Overview (Commercial/Business)
Business Value
AI Agents provides automated voice interactions:
| Without Module | With Module | |
|---|---|---|
| Manual call handling | 24/7 AI assistants | |
| High staffing costs | Reduced labor costs | |
| Inconsistent service | Uniform experience | |
| Limited scalability | Unlimited concurrent calls |
Use Cases
- Customer Support
- FAQ handling
- Ticket creation
- Sales & Leads
- Appointment scheduling
- Lead qualification
- Internal Services
- HR inquiries
- Directory assistance
- After-Hours Coverage
- Emergency routing
- Callback scheduling
Feature Highlights
| Feature | Benefit | |
|---|---|---|
| 6 Voices Available | Choose from alloy, echo, fable, onyx, nova, shimmer | |
| Structured Persona | Name, Role, Personality, Company context | |
| Behavioral Rules | Do/Don't guidelines for consistent responses | |
| AI Prompt Generation | Professional prompts created by AI | |
| Real-time Barge-In | Natural conversation interruption | |
| Call Transfer | AI can route calls to humans | |
| Transcription | Full conversation logging | |
| Multi-language | Auto-detect or force language | |
| Multi-Modal Support | Deploy as Voice Agents (telephony) or Web Chatbots (text) |
Voice Agents vs. Web Chatbots
The AI Agents module supports two distinct deployment modalities from the exact same persona engine:
- Voice Agents: Connect to extensions in the PBX and handle live telephony calls using the OpenAI Realtime API (audio-in/audio-out). They require voice parameters like TTS, pitch, and barge-in sensitivity.
- Web Chatbots: Connect to website widgets for text-based chatting. The system automatically normalizes the configuration form for chatbots, removing voice-exclusive parameters (like filler words or speaking style) and optimizing the prompts for text interaction.
---
3. Module Overview (End User/Administrator)
What Can You Do?
- Create AI voice agents with unique personas
- Assign dedicated extensions for call routing
- Configure behavioral rules (Do/Don't)
- Generate professional prompts with AI assistance
- Enable/disable call control features (hangup, transfer)
- Monitor regeneration status for outdated prompts
- Test and preview system instructions
AI Agents - List View
Add/Edit AI Agent (6-Tab Form)
Prompt Preview Modal
Quick Tips
---
4. Configuration Sections
General Tab
| Field | Description | |
|---|---|---|
| Agent Name | Display name for the agent | |
| Extension | Dialable extension number | |
| AI Profile | Realtime API profile to use | |
| Description | Brief description of the agent's purpose | |
| Transcription Profile | Whisper profile for caller speech-to-text | |
| Prompt Generator | Profile for AI prompt synthesis | |
| Conversation Mode | Fast or Natural | |
| Max Duration | Call time limit (seconds) |
Personality Tab
The Personality Tab provides fine-grained control over how the AI agent communicates. These settings follow OpenAI's Realtime Prompting Guide recommendations.
| Field | Description | Options | |
|---|---|---|---|
| Voice | AI voice persona for speech synthesis | alloy, ash, ballad, cedar, coral, echo, marin, sage, shimmer, verse | |
| Agent Personality | Core personality trait defining interaction style | Friendly & Approachable, Professional & Polished, Calm & Patient, Enthusiastic & Energetic, Empathetic & Supportive | |
| Tone of Voice | Emotional delivery style | Warm, Confident, Neutral, Encouraging, Direct | |
| Language Level | Formality of language used | Casual (informal), Conversational (friendly & clear), Formal (professional), Technical (domain-specific) | |
| Speaking Style | Pacing and delivery of responses (Voice Agents only) | Natural (balanced), Fast-paced (quick), Slow & Clear (emphasis on clarity), Expressive (dynamic emotions) | |
| Response Length | Sentences per response turn | Brief (1-2), Standard (2-3), Detailed (3-4) | |
| Natural Filler Words | Allow "um", "uh", "well" for human-like speech (Voice Agents only) | On/Off | |
| Reduce Repetition | Prevent repeated phrases for natural variety | On/Off |
Personality Matrix Recommendations
| Use Case | Personality | Tone | Language | Style | Length | |
|---|---|---|---|---|---|---|
| Customer Support | Empathetic | Warm | Conversational | Natural | Standard | |
| Sales/Leads | Enthusiastic | Confident | Conversational | Natural | Standard | |
| Technical Help | Calm | Direct | Technical | Slow & Clear | Detailed | |
| Appointment Booking | Friendly | Warm | Conversational | Fast-paced | Brief | |
| Executive Assistant | Professional | Neutral | Formal | Natural | Brief | |
| Casual Hotline | Friendly | Encouraging | Casual | Expressive | Standard |
Enable Natural Filler Words for casual/conversational agents to sound more human. Disable for professional/formal contexts.
Enable Reduce Repetition (recommended) to prevent the AI from using the same phrases repeatedly during longer calls.
Context Tab
| Field | Description | |
|---|---|---|
| Company Name | Organization identity | |
| Products/Services | What the company offers | |
| Key Points | Important information to convey | |
| Team Members | People the AI should know about | |
| Pronunciations | Special word pronunciations |
Instructions Tab
| Field | Description | |
|---|---|---|
| Persona Name | The AI's display name | |
| Role Description | What the AI does | |
| Do Rules | Things to always do | |
| Don't Rules | Things to avoid | |
| Greeting Message | How to start calls | |
| Closing Message | How to end calls |
Advanced Tab
| Field | Description |
|---|---|
| Additional Instructions | Manual expert notes (never overwritten by AI) |
Behavior Tab
| Field | Description | |
|---|---|---|
| Barge-In Enabled | Allow caller interruption | |
| Barge-In Sensitivity | Detection threshold (0-1) | |
| Min Speech (ms) | Minimum speech duration to trigger barge-in (prevents false triggers from brief sounds) | |
| Greeting Protection (ms) | Duration to ignore caller audio at call start (prevents speakerphone noise from interrupting greeting) | |
| Live Transcript | Real-time text output | |
| Store Transcripts | Save conversation logs | |
| Enable Hang Up | AI can end calls | |
| Enable Transfer | AI can route calls |
Understanding Greeting Protection
When calls are made on speakerphone, environmental noise from the caller's device can reach the AI's microphone during the first few seconds. The AI may interpret this noise as:
- An interruption (barge-in), cutting off its own greeting
- Speech in another language (causing "language hallucinations" where the AI suddenly switches to Mandarin or other languages)
Greeting Protection ignores ALL caller audio for a configurable duration at the start of the call. This gives the AI a "protected window" to complete its greeting without being interrupted by speakerphone noise.
Recommended Settings:| Environment | Greeting Protection | Notes | |
|---|---|---|---|
| Headset/Handset | 1000-2000 ms | Low noise, minimal protection needed | |
| Speakerphone | 3000-4000 ms | Default, good for most scenarios | |
| Noisy Environments | 5000-7000 ms | Call centers, open offices | |
| Long Greetings | Match greeting length | Protect entire greeting message |
Set Greeting Protection to at least the duration of your AI's greeting message to ensure it completes before caller audio is processed.
Security Tab
| Field | Description | |
|---|---|---|
| AI Disclosure | Reveal AI identity when asked | |
| Disclosure Message | What to say when asked if AI | |
| PII Redaction | Remove sensitive data from logs |
5. Settings Reference
Available Voices
| Voice | Description | |
|---|---|---|
| alloy | Neutral, versatile | |
| echo | Warm, approachable | |
| fable | Storytelling quality | |
| onyx | Deep, authoritative | |
| nova | Bright, energetic | |
| shimmer | Pleasant, professional |
Personality Styles
| Style | Behavior | |
|---|---|---|
| Professional | Formal, business-appropriate | |
| Friendly | Warm, personal | |
| Casual | Relaxed, conversational | |
| Formal | Very structured, corporate | |
| Enthusiastic | Energetic, positive |
Conversation Modes
| Mode | Description | |
|---|---|---|
| Natural | Allows pauses, more human-like | |
| Fast | Quick responses, efficient |
Language Modes
| Mode | Description | |
|---|---|---|
| Auto | Detect caller language | |
| Forced | Always use specified language |
Prompt Status Indicators
| Indicator | Meaning | |
|---|---|---|
| Normal button | Prompt is up-to-date | |
| Orange button with ! | Form has changes not reflected in prompt |
6. Common Scenarios & Examples
Scenario 1: Create Customer Support Agent
- Click Create New
- General Tab:
- Extension = "8001"
- AI Profile = GPT-4o Realtime
- Voice = nova
- Personality = Professional
- Context Tab:
- Products = Cloud hosting, Support services
- Instructions Tab:
- Role = "Customer support specialist"
- Do Rules = Be helpful, Escalate when needed
- Don't Rules = No pricing without verification
- Greeting = "Hello! This is Maya from ACME..."
- Click "Preview Prompt" → "Generate with AI" → "Apply"
- Save
Scenario 2: Sales Lead Qualification Bot
- Create New
- Configure General with sales-appropriate voice (alloy)
- Context with product information
- Instructions with qualification questions in Do Rules
- Enable Transfer in Behavior tab
- Generate AI prompt
- Save
Scenario 3: After-Hours Message Taker
- Create New
- Set Extension to after-hours hunt group destination
- Configure with message-taking instructions
- Disable Transfer (only take messages)
- Enable Hang Up so AI can end gracefully
- Generate and apply prompt
- Save
Scenario 4: Update Existing Agent
- Edit agent
- Modify Context or Instructions
- Notice orange "Preview Prompt" indicator
- Click Preview → Generate with AI → Apply
- Save (indicator clears)
---
7. Limitations & Important Notes
Technical Requirements
AI Profiles Prerequisites
| Profile | Type | Purpose | Required | |
|---|---|---|---|---|
| Realtime Voice | Real Time | Powers live AI conversations via OpenAI Realtime API | ✓ YES | |
| Prompt Generator | General | Generates system prompts from form data | ✓ YES | |
| Whisper Transcription | Whisper | Speech-to-text for caller audio transcription | Optional | |
| Wizard Assistant | General | Powers the AI Agent creation wizard | Optional |
1. Realtime Voice Profile (REQUIRED)
- Type: Real Time
- Model: gpt-4o-realtime-preview (or compatible)
- Purpose: Handles all live voice conversations
- Used by:
AI Profilefield in agent configuration
2. Prompt Generator Profile (REQUIRED)
- Type: General
- Model: gpt-4o-mini, gpt-4o, or similar
- Purpose: Synthesizes professional system prompts from structured form data
- Used by:
Prompt Generatorfield in agent configuration
3. Whisper Transcription Profile (OPTIONAL)
- Type: Whisper
- Model: whisper-1 (or compatible)
- Purpose: Transcribes caller speech to text in real-time
- Used by:
Transcription Profilefield in agent configuration
If no Transcription Profile is selected but transcription is enabled, the system defaults to whisper-1. Selecting a specific profile allows future flexibility when OpenAI releases new Whisper models.
The Prompt Generator can have a custom system prompt optimized for creating AI agent instructions. If not provided, the system uses a default template.
3. Wizard Assistant Profile (OPTIONAL)
- Type: General
- Model: gpt-4o-mini, gpt-4o, or similar
- Purpose: Powers the conversational AI Agent creation wizard
- Used by: Wizard modal when creating new agents
If not configured, the wizard uses the default system prompt. For optimal results, use a specialized prompt:
Click to expand: Recommended Wizard System Prompt
4. Quick Import System Prompt
When using the Quick Import wizard mode (paste a description or JSON), the system uses a specialized parsing prompt:
Click to expand: Quick Import System Prompt
Default System Prompts (Automatic Fallback)
The system automatically falls back to these prompts when:
- No AI Profile is selected for the wizard
- The selected profile has no system_prompt configured
Destination Routing
The General tab includes Destination Routing fields that control where calls are routed after the AI session ends:
| Field | Purpose | Use Case | |
|---|---|---|---|
| Timeout Destination | Where to route when AI session times out | Transfer to queue/voicemail after max_duration | |
| Failure Destination | Fallback when AI encounters errors | Route to live agent on connection issues |
- Extension
- Queue
- IVR
- Ring Group
- Voicemail
- Time Condition
- Hangup
Always configure a Failure Destination to ensure callers are never left in silence if the AI connection fails.
Prompt Management
| Field | Purpose | |
|---|---|---|
additional_instructions | User's manual notes (NEVER overwritten) | |
system_prompt | AI-generated/final prompt | |
prompt_outdated | Flag indicating regeneration needed |
Best Practices
- Generate After Changes: Always regenerate prompt after modifying form fields
- Use Additional Instructions: Keep custom notes that persist across regenerations
- Test Before Deploy: Use the preview to verify prompts sound correct
- Enable Carefully: Only enable Transfer if agent should route calls
- Set Time Limits: Use max_duration to prevent runaway call costs
---
8. Troubleshooting Tips
Common Issues
| Symptom | Possible Cause | Solution | |
|---|---|---|---|
| Call goes silent | mod_openai_realtime not loaded | Check fs_cli: module_exists mod_openai_realtime | |
| AI doesn't respond | Invalid API key | Verify AI Provider credentials | |
| Wrong voice | Profile mismatch | Check AI Profile assignment | |
| Orange indicator won't clear | Changes not applied | Generate with AI → Apply → Save | |
| AI promises transfer but can't | Transfer disabled | Enable in Behavior tab |
Verify Module Installation
Check Lua Handler
Test API Connection
Common Log Messages
| Term | Definition | |
|---|---|---|
AI Handler: Agent X loaded | Agent configuration found | |
mod_openai_realtime loaded | Module is active | |
WebSocket connected | OpenAI connection established | |
Instructions configured (length=X) | Prompt successfully sent | |
Transcription enabled from channel variable | Whisper transcription active | |
Arg[X]: transcription_enabled=1 | Parameter parsed correctly |
Caller Transcription Issues
| Symptom | Possible Cause | Solution | |
|---|---|---|---|
| AI transcripts work, caller missing | Parameter truncation | Check logs for Arg[X]: transcription_enabled=1 | |
Arg[X]: transcription_enabled=1 conversation_start=agent | Arguments merged | Update mod_openai_realtime.c to argv[20] | |
| Transcription always disabled | Channel variable not set | Verify Lua sets openai_transcription_enabled |
How Transcription Parameters Are Passed
The system uses a Channel Variable Offloading pattern to avoid FreeSWITCH's argument limit:
Channel Variables Used:| Variable | Purpose | Values | |
|---|---|---|---|
openai_transcription_enabled | Enable Whisper for caller audio | 1 or 0 | |
openai_transcription_model | Whisper model to use | whisper-1 | |
openai_conversation_start | Who speaks first | agent or caller | |
openai_transfer_routes_b64 | Base64 transfer destinations | JSON array |
9. Glossary
| Term | Definition | |
|---|---|---|
| AI Agent | A configured AI persona for voice calls | |
| AI Profile | Template with model, temperature, and base config | |
| AI Provider | API credentials for AI services | |
| Barge-In | Caller interrupting AI speech | |
| System Prompt | Instructions sent to the AI model | |
| Additional Instructions | Manual notes appended to prompts | |
| Prompt Outdated | Flag indicating form changes need regeneration | |
| mod_openai_realtime | FreeSWITCH C module for OpenAI Realtime | |
| VAD | Voice Activity Detection | |
| Realtime API | OpenAI's WebSocket-based voice API |
Lua Script Status ℹ️
Integration Module
| Component | Status | Location |
|---|---|---|
| AI Realtime Handler | ✓ Active | lua/ai/ai_realtime_handler.lua |
uuid_openai_realtime command with the appropriate parameters (API key, voice, instructions, capabilities).
Native Module Requirement
| Component | Status | Notes |
|---|---|---|
| mod_openai_realtime | REQUIRED | Must be compiled and loaded |
---
Documentation last updated: January 2026