Ctrl K
ring2all.com

AI Agents Module Documentation

Table of Contents

  1. Module Overview (Technical)
  2. Module Overview (Commercial/Business)
  3. Module Overview (End User/Administrator)
  4. Configuration Sections
  5. Settings Reference
  6. Common Scenarios & Examples
  7. Limitations & Important Notes
  8. Troubleshooting Tips
  9. 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.

IMPORTANT
Dependency: This module requires the mod_openai_realtime FreeSWITCH module to be compiled and loaded. Without it, AI call handling will not function.

Architecture

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│                    AI Agents Architecture                       │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  ┌─────────────────────────────────────────────────────────────┐│
│  │                      Frontend (Admin UI)                    ││
│  │  ┌──────────────┐  ┌───────────────┐  ┌─────────────────┐  ││
│  │  │ Agent List   │  │ 6-Tab Form    │  │ Prompt Preview  │  ││
│  │  │ & Wizard     │  │ Configuration │  │ & AI Generator  │  ││
│  │  └──────────────┘  └───────────────┘  └─────────────────┘  ││
│  └─────────────────────────────────────────────────────────────┘│
│                              │                                  │
│                              ▼                                  │
│  ┌─────────────────────────────────────────────────────────────┐│
│  │                     Backend API                             ││
│  │  POST /ai-agents (create) │ PUT /ai-agents/:id (update)    ││
│  │  POST /ai-agents/generate-prompt (AI synthesis)            ││
│  └─────────────────────────────────────────────────────────────┘│
│                              │                                  │
│                              ▼                                  │
│  ┌─────────────────────────────────────────────────────────────┐│
│  │                    PostgreSQL (ss_telephony)                ││
│  │  ai_agents ◄── ai_profiles ◄── ai_providers                ││
│  └─────────────────────────────────────────────────────────────┘│
│                              │                                  │
│                              ▼                                  │
│  ┌─────────────────────────────────────────────────────────────┐│
│  │                    FreeSWITCH Layer                         ││
│  │  lua/ai/ai_realtime_handler.lua ──► mod_openai_realtime    ││
│  │                                          │                  ││
│  │                                          ▼                  ││
│  │                                    OpenAI Realtime API      ││
│  │                                    (wss://api.openai.com)   ││
│  └─────────────────────────────────────────────────────────────┘│
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Key Tables

TablePurpose
public.ai_agentsAgent configuration & persona
public.ai_profilesAI service profiles (linked)
public.ai_providersAPI credentials (linked)

Key Files

FileDescription
modules/ai-agents/Frontend module
api/telephony/ai-agents/Backend service
lua/ai/ai_realtime_handler.luaFreeSWITCH Lua handler
mod_openai_realtimeNative C/C++ FreeSWITCH module

Module Dependency

Plaintext
┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│  AI Providers   │◄────│   AI Profiles   │◄────│    AI Agents    │
│  (Credentials)  │     │   (Templates)   │     │   (Personas)    │
└─────────────────┘     └─────────────────┘     └─────────────────┘
                                                        │
                                                        ▼
                                               ┌─────────────────┐
                                               │mod_openai_realtime│
                                               │   (REQUIRED)    │
                                               └─────────────────┘

---

2. Module Overview (Commercial/Business)

Business Value

AI Agents provides automated voice interactions:

Without ModuleWith Module
Manual call handling24/7 AI assistants
High staffing costsReduced labor costs
Inconsistent serviceUniform experience
Limited scalabilityUnlimited concurrent calls

Use Cases

  1. Customer Support
- First-line call screening

- FAQ handling

- Ticket creation

  1. Sales & Leads
- Product information

- Appointment scheduling

- Lead qualification

  1. Internal Services
- IT help desk

- HR inquiries

- Directory assistance

  1. After-Hours Coverage
- Message taking

- Emergency routing

- Callback scheduling

Feature Highlights

FeatureBenefit
6 Voices AvailableChoose from alloy, echo, fable, onyx, nova, shimmer
Structured PersonaName, Role, Personality, Company context
Behavioral RulesDo/Don't guidelines for consistent responses
AI Prompt GenerationProfessional prompts created by AI
Real-time Barge-InNatural conversation interruption
Call TransferAI can route calls to humans
TranscriptionFull conversation logging
Multi-languageAuto-detect or force language
Multi-Modal SupportDeploy 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:

  1. 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.
  2. 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

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│              AI Agents                                          │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  Configure AI-powered voice assistants                         │
│                                                                 │
│  [+ Create New] [🪄 AI Wizard]                                  │
│                                                                 │
│  [🔍 Search agents...]                                          │
│                                                                 │
│  ┌───────────────────────────────────────────────────────────┐  │
│  │ Name          │ Extension │ Voice   │ Profile    │ Status │  │
│  ├───────────────┼───────────┼─────────┼────────────┼────────┤  │
│  │ Maya Support  │ 8001      │ nova    │ GPT-4o RT  │ ● Active│  │
│  │ Sales Bot     │ 8002      │ alloy   │ GPT-4o RT  │ ● Active│  │
│  │ HR Assistant  │ 8003      │ shimmer │ GPT-4o RT  │ ○ Draft │  │
│  └───────────────────────────────────────────────────────────┘  │
│                                                                 │
│  Actions: [👁️ Preview] [✏️ Edit] [🗑️ Delete]                   │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Add/Edit AI Agent (6-Tab Form)

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│              Create AI Agent                 [👁️ Preview Prompt]│
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  [General] [Context] [Instructions] [Advanced] [Behavior] [Security]
│                                                                 │
│  ▼ General Tab                                                  │
│  ┌─────────────────────────────────────────────────────────────┐│
│  │  Extension:  [8001    ]   Agent Name: [Maya Support      ] ││
│  │  AI Profile: [GPT-4o Realtime ▼]                           ││
│  │  Description: [Customer support AI assistant             ] ││
│  │  Transcription Profile: [OpenAI Whisper ▼]                 ││
│  │  Prompt Generator: [GPT-4o Mini ▼] (for AI synthesis)      ││
│  │  Personality: [Professional ▼]                              ││
│  │  Conversation Mode: [Natural ▼]  Max Duration: [300] sec   ││
│  └─────────────────────────────────────────────────────────────┘│
│                                                                 │
│  ▼ Context Tab                                                  │
│  ┌─────────────────────────────────────────────────────────────┐│
│  │  Company Name: [ACME Corporation          ]                ││
│  │  Products/Services:                                         ││
│  │  ┌───────────────────────────────────────────┐              ││
│  │  │ Cloud hosting                            │              ││
│  │  │ Managed services                         │              ││
│  │  │ 24/7 support                             │              ││
│  │  └───────────────────────────────────────────┘              ││
│  │  Key Points: [Brief company info and key messages...]      ││
│  └─────────────────────────────────────────────────────────────┘│
│                                                                 │
│  ▼ Instructions Tab                                             │
│  ┌─────────────────────────────────────────────────────────────┐│
│  │  Persona Name: [Maya           ]                           ││
│  │  Role Description: [Customer support specialist...]        ││
│  │  ✓ DO Rules (green):                                       ││
│  │  ┌───────────────────────────────────────────┐              ││
│  │  │ Be helpful and patient                   │              ││
│  │  │ Escalate complex issues                  │              ││
│  │  └───────────────────────────────────────────┘              ││
│  │  ✗ DON'T Rules (red):                                      ││
│  │  ┌───────────────────────────────────────────┐              ││
│  │  │ Share pricing without verification       │              ││
│  │  │ Make promises about delivery dates       │              ││
│  │  └───────────────────────────────────────────┘              ││
│  │  Greeting: [Hello! This is Maya from ACME...]              ││
│  │  Closing: [Thank you for calling ACME...]                  ││
│  └─────────────────────────────────────────────────────────────┘│
│                                                                 │
│  ▼ Advanced Tab                                                 │
│  ┌─────────────────────────────────────────────────────────────┐│
│  │  Additional Instructions:                                   ││
│  │  ┌───────────────────────────────────────────────────────┐  ││
│  │  │ (Manual expert notes that persist across generations) │  ││
│  │  │ - Always verify customer ID before discussing account │  ││
│  │  │ - Spanish speakers: route to extension 8010           │  ││
│  │  └───────────────────────────────────────────────────────┘  ││
│  └─────────────────────────────────────────────────────────────┘│
│                                                                 │
│  ▼ Behavior Tab                                                 │
│  ┌─────────────────────────────────────────────────────────────┐│
│  │  Barge-In Enabled: ✓    Sensitivity: [0.5]                 ││
│  │  Live Transcript: ✓     Store Transcripts: ✓               ││
│  │  ── AI Function Capabilities ──                             ││
│  │  Enable Hang Up: ✓      Enable Transfer: ✗                 ││
│  └─────────────────────────────────────────────────────────────┘│
│                                                                 │
│  ▼ Security Tab                                                 │
│  ┌─────────────────────────────────────────────────────────────┐│
│  │  AI Disclosure: ✓                                           ││
│  │  Disclosure Message: [You are speaking with an AI...]      ││
│  │  PII Redaction: ✗                                           ││
│  └─────────────────────────────────────────────────────────────┘│
│                                                                 │
│  [Save ▼] [Cancel]                                              │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Prompt Preview Modal

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│              System Prompt Preview              [AI Generated ▼]│
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  ┌───────────────────────────────────────────────────────────┐  │
│  │ ## IDENTITY                                               │  │
│  │ I am Maya, a customer support specialist at ACME Corp.   │  │
│  │                                                           │  │
│  │ ## PERSONALITY                                            │  │
│  │ I maintain a professional tone while being helpful...    │  │
│  │                                                           │  │
│  │ ## BEHAVIORAL GUIDELINES                                  │  │
│  │ ### Things I Always Do:                                   │  │
│  │ - Be helpful and patient                                  │  │
│  │ - Escalate complex issues                                 │  │
│  │ ...                                                       │  │
│  └───────────────────────────────────────────────────────────┘  │
│                                                                 │
│  [🪄 Generate with AI] [📋 Copy] [✓ Apply to System Prompt]    │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Quick Tips

TIP
Preview First: Always preview the prompt before saving to verify AI output.
TIP
Use AI Generation: The "Generate with AI" button creates professional prompts from your structured data.
WARNING
Orange Indicator: When the "Preview Prompt" button turns orange, form changes haven't been regenerated into the prompt yet.

---

4. Configuration Sections

General Tab

FieldDescription
Agent NameDisplay name for the agent
ExtensionDialable extension number
AI ProfileRealtime API profile to use
DescriptionBrief description of the agent's purpose
Transcription ProfileWhisper profile for caller speech-to-text
Prompt GeneratorProfile for AI prompt synthesis
Conversation ModeFast or Natural
Max DurationCall 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.

FieldDescriptionOptions
VoiceAI voice persona for speech synthesisalloy, ash, ballad, cedar, coral, echo, marin, sage, shimmer, verse
Agent PersonalityCore personality trait defining interaction styleFriendly & Approachable, Professional & Polished, Calm & Patient, Enthusiastic & Energetic, Empathetic & Supportive
Tone of VoiceEmotional delivery styleWarm, Confident, Neutral, Encouraging, Direct
Language LevelFormality of language usedCasual (informal), Conversational (friendly & clear), Formal (professional), Technical (domain-specific)
Speaking StylePacing and delivery of responses (Voice Agents only)Natural (balanced), Fast-paced (quick), Slow & Clear (emphasis on clarity), Expressive (dynamic emotions)
Response LengthSentences per response turnBrief (1-2), Standard (2-3), Detailed (3-4)
Natural Filler WordsAllow "um", "uh", "well" for human-like speech (Voice Agents only)On/Off
Reduce RepetitionPrevent repeated phrases for natural varietyOn/Off
NOTE
Form Normalization: When configuring a Web Chatbot, the UI automatically hides voice-exclusive fields (Voice, Speaking Style, and Natural Filler Words) to maintain a clean, text-centric configuration experience.

Personality Matrix Recommendations

Use CasePersonalityToneLanguageStyleLength
Customer SupportEmpatheticWarmConversationalNaturalStandard
Sales/LeadsEnthusiasticConfidentConversationalNaturalStandard
Technical HelpCalmDirectTechnicalSlow & ClearDetailed
Appointment BookingFriendlyWarmConversationalFast-pacedBrief
Executive AssistantProfessionalNeutralFormalNaturalBrief
Casual HotlineFriendlyEncouragingCasualExpressiveStandard
TIP

Enable Natural Filler Words for casual/conversational agents to sound more human. Disable for professional/formal contexts.

TIP

Enable Reduce Repetition (recommended) to prevent the AI from using the same phrases repeatedly during longer calls.

Context Tab

FieldDescription
Company NameOrganization identity
Products/ServicesWhat the company offers
Key PointsImportant information to convey
Team MembersPeople the AI should know about
PronunciationsSpecial word pronunciations

Instructions Tab

FieldDescription
Persona NameThe AI's display name
Role DescriptionWhat the AI does
Do RulesThings to always do
Don't RulesThings to avoid
Greeting MessageHow to start calls
Closing MessageHow to end calls

Advanced Tab

FieldDescription
Additional InstructionsManual expert notes (never overwritten by AI)

Behavior Tab

FieldDescription
Barge-In EnabledAllow caller interruption
Barge-In SensitivityDetection 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 TranscriptReal-time text output
Store TranscriptsSave conversation logs
Enable Hang UpAI can end calls
Enable TransferAI can route calls

Understanding Greeting Protection

IMPORTANT
Greeting Protection is a critical setting when using speakerphone or hands-free devices.
The Problem:

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:

  1. An interruption (barge-in), cutting off its own greeting
  2. Speech in another language (causing "language hallucinations" where the AI suddenly switches to Mandarin or other languages)

The Solution:

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:
EnvironmentGreeting ProtectionNotes
Headset/Handset1000-2000 msLow noise, minimal protection needed
Speakerphone3000-4000 msDefault, good for most scenarios
Noisy Environments5000-7000 msCall centers, open offices
Long GreetingsMatch greeting lengthProtect entire greeting message
TIP

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

FieldDescription
AI DisclosureReveal AI identity when asked
Disclosure MessageWhat to say when asked if AI
PII RedactionRemove sensitive data from logs
---

5. Settings Reference

Available Voices

VoiceDescription
alloyNeutral, versatile
echoWarm, approachable
fableStorytelling quality
onyxDeep, authoritative
novaBright, energetic
shimmerPleasant, professional

Personality Styles

StyleBehavior
ProfessionalFormal, business-appropriate
FriendlyWarm, personal
CasualRelaxed, conversational
FormalVery structured, corporate
EnthusiasticEnergetic, positive

Conversation Modes

ModeDescription
NaturalAllows pauses, more human-like
FastQuick responses, efficient

Language Modes

ModeDescription
AutoDetect caller language
ForcedAlways use specified language

Prompt Status Indicators

IndicatorMeaning
Normal buttonPrompt is up-to-date
Orange button with !Form has changes not reflected in prompt
---

6. Common Scenarios & Examples

Scenario 1: Create Customer Support Agent

  1. Click Create New
  2. General Tab:
- Name = "Maya Support"

- Extension = "8001"

- AI Profile = GPT-4o Realtime

- Voice = nova

- Personality = Professional

  1. Context Tab:
- Company Name = "ACME Corporation"

- Products = Cloud hosting, Support services

  1. Instructions Tab:
- Persona Name = "Maya"

- 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..."

  1. Click "Preview Prompt" → "Generate with AI" → "Apply"
  2. Save

Scenario 2: Sales Lead Qualification Bot

  1. Create New
  2. Configure General with sales-appropriate voice (alloy)
  3. Context with product information
  4. Instructions with qualification questions in Do Rules
  5. Enable Transfer in Behavior tab
  6. Generate AI prompt
  7. Save

Scenario 3: After-Hours Message Taker

  1. Create New
  2. Set Extension to after-hours hunt group destination
  3. Configure with message-taking instructions
  4. Disable Transfer (only take messages)
  5. Enable Hang Up so AI can end gracefully
  6. Generate and apply prompt
  7. Save

Scenario 4: Update Existing Agent

  1. Edit agent
  2. Modify Context or Instructions
  3. Notice orange "Preview Prompt" indicator
  4. Click Preview → Generate with AI → Apply
  5. Save (indicator clears)

---

7. Limitations & Important Notes

Technical Requirements

IMPORTANT
mod_openai_realtime Required: The FreeSWITCH module must be compiled and loaded:

Bash
> cd /var/www/softswitch/freeswitch/modules/mod_openai_realtime/build
> cmake .. && make
> sudo cp libmod_openai_realtime.so /usr/lib/freeswitch/mod/mod_openai_realtime.so
> fs_cli -x "reload mod_openai_realtime"
> 

AI Profiles Prerequisites

IMPORTANT
Minimum 2 AI Profiles Required for full functionality:
ProfileTypePurposeRequired
Realtime VoiceReal TimePowers live AI conversations via OpenAI Realtime APIYES
Prompt GeneratorGeneralGenerates system prompts from form dataYES
Whisper TranscriptionWhisperSpeech-to-text for caller audio transcriptionOptional
Wizard AssistantGeneralPowers the AI Agent creation wizardOptional

1. Realtime Voice Profile (REQUIRED)

  • Type: Real Time
  • Model: gpt-4o-realtime-preview (or compatible)
  • Purpose: Handles all live voice conversations
  • Used by: AI Profile field 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 Generator field 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 Profile field in agent configuration

NOTE

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.

TIP

The Prompt Generator can have a custom system prompt optimized for creating AI agent instructions. If not provided, the system uses a default template.

Suggested Prompt Generator System Prompt:

Plaintext
You are an expert at writing system prompts for conversational AI voice agents.
Given structured information about a persona, role, company, and behavioral rules,
you must synthesize a comprehensive, natural-sounding system prompt that:
- Defines the AI's identity clearly
- Incorporates all behavioral guidelines
- Maintains a consistent personality
- Is optimized for real-time voice conversations
Output only the final system prompt, no explanations.

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

Plaintext
You are an expert Conversational AI Architect specialized in real-time voice systems,
FreeSWITCH telephony, and low-latency AI agents using OpenAI Realtime API.

Your role is NOT to chat casually.
Your role is to GUIDE, ANALYZE, VALIDATE, and OPTIMIZE the configuration of an AI Voice Agent
based on answers provided through a wizard UI.

You must behave like a senior solution architect helping a customer design
a HUMAN-LIKE, REAL-TIME AI AGENT for phone calls.

---

## 🎯 PRIMARY OBJECTIVE

Your objective is to:
1) Collect configuration preferences through the wizard
2) Analyze them holistically
3) Detect contradictions, risks, or suboptimal choices
4) Propose improvements and defaults
5) Produce a FINAL, OPTIMIZED AGENT CONFIGURATION
   that is technically feasible, low-latency, and natural for telephony

You must always prioritize:
- Real-time performance
- Natural conversation
- Barge-in capability
- FreeSWITCH constraints
- OpenAI Realtime API capabilities

---

## 🧩 CONTEXT YOU MUST ASSUME

- Platform: Ring2All
- Telephony engine: FreeSWITCH
- Audio is real-time (RTP / media stream)
- Multi-domain environment
- AI runs via OpenAI Realtime API over WebSocket
- Calls are live; latency above ~300–400 ms is noticeable
- Users are NOT AI experts

---

## 🧠 HOW YOU MUST THINK

You must think in these layers simultaneously:
1) Telephony reality (latency, codecs, barge-in, VAD)
2) Conversational UX (turn-taking, interruptions, human rhythm)
3) AI constraints (model behavior, streaming, context)
4) Business use case (support, sales, IVR replacement)
5) Operational stability (timeouts, fallbacks)

Never blindly accept a choice if it creates a bad experience.

---

## 🧭 WIZARD GUIDANCE RULES

### 1️⃣ Ask ONE question at a time
- Do not overwhelm the user
- Each question must be clearly motivated

### 2️⃣ Explain WHY you are asking
Before each question, briefly explain its impact.

### 3️⃣ Detect intent behind answers
If the user answer implies a use case (e.g. call center vs IVR),
adapt future questions accordingly.

### 4️⃣ Challenge bad configurations
If a choice would cause:
- High latency
- No barge-in
- Robotic behavior
- User frustration

You MUST explain the issue and propose a better alternative.

### 5️⃣ Suggest defaults when user is unsure
Never leave the user blocked.

---

## 🧩 CONFIGURATION DIMENSIONS YOU MUST COVER

You must guide the wizard through ALL these areas:

### A) Use Case
- Receptionist
- Support agent
- Sales agent
- IVR replacement
- Queue overflow
- Internal assistant

### B) Conversation Style
- Short / concise
- Natural / friendly
- Formal / professional

### C) Language Handling
- Auto-detect language
- Force a language
- Multilingual handling

### D) Barge-in (INTERRUPTION)
Guide configuration for:
- Enable barge-in (default: YES)
- Sensitivity
- Minimum speech duration to interrupt

### E) Transcription
- Live transcription?
- Store transcripts?

### F) Translation
- Real-time translation needed?
- Target language?

### G) Voice & Audio
- Voice selection
- Speaking speed

### H) Error Handling & Fallbacks
- What happens if AI fails?

---

## 🧪 VALIDATION PHASE

Once all answers are collected:
1) Summarize the configuration
2) Identify latency risks and UX problems
3) Propose improvements
4) Mark REQUIRED vs RECOMMENDED vs OPTIONAL changes

---

## 📦 FINAL OUTPUT FORMAT

At the end, output:
1) Configuration Summary (User-friendly)
2) Technical Configuration (Structured JSON)
3) Risk & Notes

---

## 🎯 SUCCESS CRITERIA

A successful session results in:
- A configuration that feels HUMAN on the phone
- Minimal latency
- Safe interruption (barge-in)
- Clear fallback behavior

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

Plaintext
You are an expert AI Configuration Parser specialized in real-time voice agents
for telephony systems (FreeSWITCH + OpenAI Realtime API).

## 🎯 YOUR MISSION
Analyze the user's input (description, JSON, or prompt) and generate an
OPTIMIZED configuration for a voice AI agent designed for live phone calls.

## 🧠 CRITICAL CONTEXT
This is for a REAL-TIME VOICE AGENT on phone calls:
- Responses are SPOKEN, not displayed
- Latency matters (300ms+ is noticeable)
- Barge-in (interruption) is essential
- Conversations happen live with real humans

## 📋 PARSING RULES
1) Extract agent name, purpose, and personality
2) Infer voice characteristics from tone/style
3) Identify behavioral rules (DOs and DON'Ts)
4) Detect company/product context
5) Map any existing configuration to our format

## 🎛️ SMART DEFAULTS (if not specified)
- conversation_mode: "natural" (better for voice)
- barge_in_enabled: true (always for phone)
- barge_in_sensitivity: "medium"
- max_duration_seconds: 300 (5 minutes)
- greeting_message: SHORT (max 15 words for voice)
- personality: Infer from description

## ⚠️ VALIDATION
Before outputting, verify:
- Greeting is SHORT (under 15 words) and natural for SPEAKING
- No long pauses or complex sentences
- Barge-in is enabled
- Persona sounds human, not robotic

## 📤 OUTPUT FORMAT
Respond ONLY with a valid JSON object matching our schema.
No explanations, no markdown, just the pure JSON.

Default System Prompts (Automatic Fallback)

NOTE
No Profile Required for Wizard: If you don't configure a Wizard Assistant Profile, the wizard will use the built-in default prompts described above.

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
This ensures the wizard always works, even without custom configuration.

Destination Routing

The General tab includes Destination Routing fields that control where calls are routed after the AI session ends:

FieldPurposeUse Case
Timeout DestinationWhere to route when AI session times outTransfer to queue/voicemail after max_duration
Failure DestinationFallback when AI encounters errorsRoute to live agent on connection issues
NOTE
Transfer Destination is Dynamic: The AI decides transfer destinations during the conversation. There is no static "Transfer Destination" field because the AI can dynamically route to any extension, queue, or IVR based on the caller's request.
Supported Destination Types:
  • Extension
  • Queue
  • IVR
  • Ring Group
  • Voicemail
  • Time Condition
  • Hangup

TIP

Always configure a Failure Destination to ensure callers are never left in silence if the AI connection fails.

NOTE
AI Profile Required: An AI Profile with a valid OpenAI API key must be configured first.
WARNING
Realtime API Costs: OpenAI Realtime API has per-minute pricing. Monitor usage.

Prompt Management

FieldPurpose
additional_instructionsUser's manual notes (NEVER overwritten)
system_promptAI-generated/final prompt
prompt_outdatedFlag indicating regeneration needed

Best Practices

  1. Generate After Changes: Always regenerate prompt after modifying form fields
  2. Use Additional Instructions: Keep custom notes that persist across regenerations
  3. Test Before Deploy: Use the preview to verify prompts sound correct
  4. Enable Carefully: Only enable Transfer if agent should route calls
  5. Set Time Limits: Use max_duration to prevent runaway call costs

---

8. Troubleshooting Tips

Common Issues

SymptomPossible CauseSolution
Call goes silentmod_openai_realtime not loadedCheck fs_cli: module_exists mod_openai_realtime
AI doesn't respondInvalid API keyVerify AI Provider credentials
Wrong voiceProfile mismatchCheck AI Profile assignment
Orange indicator won't clearChanges not appliedGenerate with AI → Apply → Save
AI promises transfer but can'tTransfer disabledEnable in Behavior tab

Verify Module Installation

Bash
# Check if module is loaded
fs_cli -x "module_exists mod_openai_realtime"
# Should return: true

# Check syntax help
fs_cli -x "help uuid_openai_realtime"
# Should list command options

Check Lua Handler

Bash
# Verify Lua script exists
ls -la /usr/share/freeswitch/scripts/ai/ai_realtime_handler.lua

Test API Connection

Bash
# Test OpenAI Realtime API access
curl https://api.openai.com/v1/realtime/sessions \
  -H "Authorization: Bearer sk-xxxxxx" \
  -H "Content-Type: application/json"

Common Log Messages

TermDefinition
AI Handler: Agent X loadedAgent configuration found
mod_openai_realtime loadedModule is active
WebSocket connectedOpenAI connection established
Instructions configured (length=X)Prompt successfully sent
Transcription enabled from channel variableWhisper transcription active
Arg[X]: transcription_enabled=1Parameter parsed correctly

Caller Transcription Issues

IMPORTANT
Caller Transcription Architecture: Caller audio is transcribed using OpenAI Whisper (configured via Transcription Profile). The C module exposes transcripts via channel variables that the Lua handler polls.
SymptomPossible CauseSolution
AI transcripts work, caller missingParameter truncationCheck logs for Arg[X]: transcription_enabled=1
Arg[X]: transcription_enabled=1 conversation_start=agentArguments mergedUpdate mod_openai_realtime.c to argv[20]
Transcription always disabledChannel variable not setVerify Lua sets openai_transcription_enabled

How Transcription Parameters Are Passed

The system uses a Channel Variable Offloading pattern to avoid FreeSWITCH's argument limit:

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│                   Parameter Flow                                 │
├─────────────────────────────────────────────────────────────────┤
│                                                                  │
│  ai_realtime_handler.lua                                         │
│  ┌────────────────────────────────────────────────────────────┐  │
│  │  session:setVariable("openai_transcription_enabled", "1")  │  │
│  │  session:setVariable("openai_transcription_model", "...")  │  │
│  │  session:setVariable("openai_conversation_start", "agent") │  │
│  │  session:setVariable("openai_transfer_routes_b64", "...")  │  │
│  └────────────────────────────────────────────────────────────┘  │
│                              │                                   │
│                              ▼                                   │
│  mod_openai_realtime.c                                           │
│  ┌────────────────────────────────────────────────────────────┐  │
│  │  1. Parse command-line arguments (api_key, model, etc.)    │  │
│  │  2. Read channel variables for optional configs            │  │
│  │  3. Merge into final openai_config_t structure             │  │
│  └────────────────────────────────────────────────────────────┘  │
│                                                                  │
└─────────────────────────────────────────────────────────────────┘

Channel Variables Used:
VariablePurposeValues
openai_transcription_enabledEnable Whisper for caller audio1 or 0
openai_transcription_modelWhisper model to usewhisper-1
openai_conversation_startWho speaks firstagent or caller
openai_transfer_routes_b64Base64 transfer destinationsJSON array
---

9. Glossary

TermDefinition
AI AgentA configured AI persona for voice calls
AI ProfileTemplate with model, temperature, and base config
AI ProviderAPI credentials for AI services
Barge-InCaller interrupting AI speech
System PromptInstructions sent to the AI model
Additional InstructionsManual notes appended to prompts
Prompt OutdatedFlag indicating form changes need regeneration
mod_openai_realtimeFreeSWITCH C module for OpenAI Realtime
VADVoice Activity Detection
Realtime APIOpenAI's WebSocket-based voice API
---

Lua Script Status ℹ️

Integration Module

ComponentStatusLocation
AI Realtime Handler✓ Activelua/ai/ai_realtime_handler.lua
The Lua handler retrieves agent configuration from the database and initiates the uuid_openai_realtime command with the appropriate parameters (API key, voice, instructions, capabilities).

Native Module Requirement

ComponentStatusNotes
mod_openai_realtimeREQUIREDMust be compiled and loaded
See the Proprietary Module Guide for build instructions.

---

Documentation last updated: January 2026
AI Assistant

👋 Hello! I'm your Ring2All documentation assistant. I can help you find information about configuring and using the Ring2All PBX platform.

How can I help you today?