Custom Applications Module Documentation
Table of Contents
- Module Overview (Technical)
- Module Overview (Commercial/Business)
- Module Overview (End User/Administrator)
- Configuration Fields Reference
- Call Flow / Logic Explanation
- Common Scenarios & Examples
- Limitations & Important Notes
- Troubleshooting Tips
- Glossary
- Suggested UI Improvements
---
1. Module Overview (Technical)
What Are Custom Applications?
Custom Applications allow administrators to create programmable call logic using Lua scripts or XML dialplan entries. When a user dials the trigger number, FreeSWITCH executes the custom code before optionally routing to a final destination.
Two Application Types
| Type | Description | Use Case | |
|---|---|---|---|
| Lua Script | Programmatic logic with Lua code | Complex logic, API calls, database queries | |
| XML Dialplan | Declarative FreeSWITCH XML | Simple routing, variable setting |
Architecture
Key Tables
| Table | Purpose |
|---|---|
public.custom_applications | Application definitions (name, trigger, script) |
Script Storage
Scripts are stored as files in FreeSWITCH:
Available Variables
| Variable | Description | |
|---|---|---|
CUSTOM_APP_DOMAIN | The domain/tenant the call is in | |
CUSTOM_APP_UUID | Unique ID of this application | |
caller_id_number | Caller's phone number | |
caller_id_name | Caller's name | |
destination_number | Number that was dialed |
Key Files
| File | Description | |
|---|---|---|
admin/apps/web/src/modules/customApplications/ | Frontend module | |
admin/apps/web/src/i18n/en/customApplications.json | English translations | |
telephony/freeswitch/lua/main/custom_app_handler.lua | Lua handler |
2. Module Overview (Commercial/Business)
Business Value
Custom Applications provide extensibility without core modifications:
| Without Custom Apps | With Custom Apps | |
|---|---|---|
| Hardcoded logic only | Dynamic programmable logic | |
| Developer required | Admin can create via UI | |
| System restart needed | Hot-deployed scripts | |
| No customization | Unlimited flexibility |
Use Cases
- Custom IVR Logic
- Database lookups for personalized greetings
- API integrations with external systems
- Pre-Call Announcements
- Holiday hour announcements
- Emergency notifications
- Call Routing Logic
- VIP caller detection
- Geographic routing
- Integration Points
- Ticket creation on call start
- SMS notifications
Feature Highlights
| Feature | Benefit | |
|---|---|---|
| Lua Scripting | Full programming language for complex logic | |
| XML Dialplan | Simple declarative routing | |
| Final Destination | Route anywhere after script completes | |
| Skip Destination | Script handles everything (hangup internally) | |
| Hot Deploy | Changes apply immediately |
3. Module Overview (End User/Administrator)
What Can You Do?
- Create custom applications with Lua or XML code
- Assign trigger numbers (extension or feature code)
- Define final destinations for post-script routing
- Enable/disable applications without deleting
User Workflow
Quick Tips
---
4. Configuration Fields Reference
General Settings Tab
| Field | Description | Example | Required | |
|---|---|---|---|---|
| Name | Unique application name | Recording Disclaimer | Yes | |
| Trigger Number | Extension/feature code | 99, 8001 | Yes | |
| Description | Purpose documentation | Plays recording notice | No | |
| Application Type | Lua Script or XML Dialplan | Lua Script | Yes | |
| Enabled | Active/inactive | On/Off | Yes |
Script Content Tab
| Field | Description | Notes |
|---|---|---|
| Script Content | Lua code or XML dialplan | Monaco editor with syntax highlighting |
Final Destination Section
| Field | Description | Options | |
|---|---|---|---|
| Skip Final Destination | Don't route after script | On = script handles hangup | |
| Destination Type | Where to route | Extension, Queue, IVR, Conference, Voicemail, Announcement, External, Hangup, Time Condition, Call Flow, Ring Group | |
| Destination Value | Target identifier | Depends on type |
Destination Types
| Type | Value Format | Example | |
|---|---|---|---|
| Extension | Extension number | 1001 | |
| Queue | Queue name | support_queue | |
| Ring Group | Ring group ID | sales_group | |
| IVR | IVR name | main_menu | |
| Voicemail | Extension number | 1001 | |
| Announcement | Announcement ID | holiday_hours | |
| Conference | Conference extension | 8000 | |
| Hangup | (none) | Ends call | |
| External | Phone number | +15551234567 | |
| Time Condition | Time condition ID | business_hours | |
| Call Flow | Call flow ID | main_flow |
5. Call Flow / Logic Explanation
Custom Application Execution Flow
---
6. Common Scenarios & Examples
Scenario 1: Recording Disclaimer
Purpose: Play "This call may be recorded" before connecting to support. Configuration:| Setting | Value | |
|---|---|---|
| Name | Recording Disclaimer | |
| Trigger | 99 | |
| Type | Lua Script | |
| Skip Destination | No | |
| Final Destination | Queue: support_queue |
Scenario 2: VIP Caller Detection
Purpose: Check if caller is VIP and route accordingly. Configuration:| Setting | Value | |
|---|---|---|
| Name | VIP Router | |
| Trigger | 77 | |
| Type | Lua Script | |
| Skip Destination | Yes (script handles routing) |
Scenario 3: Emergency Announcement
Purpose: Play emergency message and hang up. Configuration:| Setting | Value | |
|---|---|---|
| Name | Emergency Notice | |
| Trigger | 911 | |
| Type | Lua Script | |
| Skip Destination | Yes |
Scenario 4: Simple XML Routing
Purpose: Set a variable and transfer. Configuration:| Setting | Value | |
|---|---|---|
| Name | Department Router | |
| Trigger | 50 | |
| Type | XML Dialplan | |
| Skip Destination | Yes |
---
7. Limitations & Important Notes
Technical Limitations
Best Practices
- Keep Scripts Simple: Complex logic is harder to debug
- Use Logging: Add
freeswitch.consoleLog("INFO", message)for debugging - Handle Errors: Wrap critical code in pcall() for error handling
- Test Offline: Test Lua scripts in a Lua interpreter first
- Document Code: Add comments explaining what the script does
Security Considerations
---
8. Troubleshooting Tips
Common Issues
| Symptom | Possible Cause | Solution | |
|---|---|---|---|
| Application not triggered | Trigger number conflict | Check for duplicate extensions | |
| Script error | Lua syntax error | Check FreeSWITCH console logs | |
| No audio | session:answer() missing | Ensure call is answered first | |
| Final destination ignored | skip_final_destination = true | Set to false if routing needed | |
| Variables undefined | Wrong variable name | Check available variables |
Debugging in FreeSWITCH
Enable Lua debugging: Watch for custom app execution:Diagnostic SQL
List custom applications: Check script file:---
9. Glossary
| Term | Definition | |
|---|---|---|
| Custom Application | User-defined script that executes when a trigger number is dialed | |
| Lua | Lightweight programming language used for FreeSWITCH scripting | |
| XML Dialplan | FreeSWITCH's declarative routing configuration format | |
| Trigger Number | The extension or feature code that activates the application | |
| Final Destination | Where the call is routed after the script completes | |
| Skip Destination | Option to not route after script (script handles hangup) | |
| Hot Deploy | Changes take effect immediately without restart | |
| session | Lua object representing the active call/channel | |
| Channel Variable | Named values attached to a call for data passing |
10. Suggested UI Improvements
Enhanced Tooltips (Already Good)
The existing tooltips are comprehensive. Minor enhancements:
| Field | Suggested Addition | |
|---|---|---|
| scriptContent | Add link to Lua API documentation | |
| triggerNumber | Add conflict check warning |
UX Enhancements
- Syntax Validation: Real-time Lua/XML syntax checking in editor
- Script Templates: Dropdown of common script templates:
- VIP Detection
- Time-Based Routing
- API Integration
- Test Button: "Test this application" that initiates a test call
- Version History: Track changes to scripts over time
- Duplicate Detection: Warn if trigger number conflicts with existing entries
- Log Viewer: Show recent execution logs for this application
Editor Improvements
| Current | Suggested | |
|---|---|---|
| Monaco editor | Add Lua autocomplete for FreeSWITCH API | |
| Plain text | Syntax highlighting for FreeSWITCH functions | |
| No validation | Real-time syntax error highlighting |
Lua Script Status ✅
Integration Module
| Component | Status | Notes |
|---|---|---|
| Custom Applications | ✅ Active | Executes custom Lua scripts defined in the application's configuration |
Documentation last updated: January 2026*