Ctrl K
ring2all.com

Inbound Routes Module Documentation

Table of Contents

  1. Module Overview (Technical)
  2. Module Overview (Commercial/Business)
  3. Module Overview (End User/Administrator)
  4. Configuration Fields Reference
  5. Destination Modules
  6. Pattern Matching
  7. Common Scenarios & Examples
  8. Limitations & Important Notes
  9. Troubleshooting Tips
  10. Glossary

---

1. Module Overview (Technical)

What Are Inbound Routes?

Inbound Routes define how incoming calls are routed from SIP gateways/carriers to internal destinations (extensions, queues, IVRs, etc.). They match DIDs (phone numbers) to destinations based on regex patterns.

Architecture

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│                  Inbound Routes System                          │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  Incoming Call: +15055551234 from Carrier                       │
│       │                                                         │
│       ▼                                                         │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │              route_with_fallback.lua                     │   │
│  │                                                          │   │
│  │  1. Detect call_direction = "inbound"                    │   │
│  │  2. Query public.inbound_routes                          │   │
│  │  3. Match: number_pattern = ^5055551234$                 │   │
│  │  4. Optional: caller_id_filter check                     │   │
│  │  5. Route to destination_module + destination_data       │   │
│  │                                                          │   │
│  └──────────────────────────────────────────────────────────┘   │
│       │                                                         │
│       ▼                                                         │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │           Destination Handler                            │   │
│  │                                                          │   │
│  │  extension → routing/extension.lua                       │   │
│  │  ivr       → routing/ivr.lua                            │   │
│  │  queue     → routing/queue.lua                          │   │
│  │  ring_group → routing/ring_group.lua                    │   │
│  │  conference → routing/conference.lua                    │   │
│  │  ...                                                     │   │
│  │                                                          │   │
│  └──────────────────────────────────────────────────────────┘   │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Key Tables

TablePurpose
public.inbound_routesRoute definitions
public.domainsDomain lookup
public.time_conditionsOptional time-based routing

Key Files

FileDescription
admin/apps/web/src/modules/inboundRoutes/Frontend module
admin/apps/web/src/i18n/en/inboundRoutes.jsonTranslations
telephony/freeswitch/lua/main/xml_handlers/dialplan/route_with_fallback.luaMain routing handler
telephony/freeswitch/lua/main/xml_handlers/routing/.luaDestination handlers
---

2. Module Overview (Commercial/Business)

Business Value

Inbound Routes enable DID-to-destination mapping:

Without Inbound RoutesWith Inbound Routes
All calls to defaultRoute by DID number
No caller filteringFilter by caller ID
No time routingTime-based destinations
No call screeningAnonymous call blocking

Use Cases

  1. DID Routing
- Route +15051234567 → Sales Queue

- Route +15057654321 → Support IVR

  1. Department Lines
- Main number → Auto-Attendant

- Support number → Support Queue

- Fax number → Fax Server

  1. Geographic Routing
- Local calls → Local agents

- International → Language IVR

  1. Time-Based Routing
- Business hours → Main IVR

- After hours → Voicemail

Feature Highlights

FeatureBenefit
Pattern MatchingRegex for DIDs
Caller ID FilterRoute by caller
Time ConditionsTime-based routing
Multiple DestinationsExtension, Queue, IVR, etc.
Call RecordingAuto-record inbound
Anonymous BlockingReject hidden callers
Country FilterGeographic restrictions
Max ConcurrentCapacity limits
---

3. Module Overview (End User/Administrator)

What Can You Do?

  • Create inbound routes for DIDs
  • Define number patterns (regex)
  • Filter by caller ID
  • Set destination (extension, queue, IVR, etc.)
  • Configure time conditions
  • Block anonymous callers
  • Set concurrent call limits

Administrator Workflow

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│              Creating an Inbound Route                          │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  Section: General                                               │
│  ├─ Name: "Main Line"                                          │
│  ├─ Number Pattern: ^5055551234$                               │
│  ├─ Caller ID Filter: (optional)                               │
│  ├─ Priority: 100                                              │
│  └─ Enabled: ✓                                                 │
│                                                                 │
│  Section: Settings                                              │
│  ├─ Destination Module: IVR                                    │
│  ├─ Destination: Main Auto-Attendant                           │
│  ├─ Time Condition: Business Hours (optional)                  │
│  ├─ Failover Module: Voicemail                                 │
│  ├─ Failover Destination: General Mailbox                      │
│  ├─ Record Call: ✓                                             │
│  ├─ Block Anonymous: ✓                                         │
│  └─ Max Concurrent: 20                                         │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Quick Tips

TIP
Use Anchors: ^5055551234$ matches exactly that number.
TIP
Wildcard DIDs: ^505555. matches all 505555xxxx numbers.
CAUTION
Priority Order: Lower number = higher priority (checked first).

---

4. Configuration Fields Reference

General Fields

FieldDescriptionExample
NameRoute identifierMain Line
Number PatternRegex for DID^5055551234$
Caller ID FilterOptional caller pattern^1800.
PriorityEvaluation order (lower = first)100
EnabledRoute activeOn/Off

Destination Fields

FieldDescription
Destination ModuleTarget type (extension, ivr, queue, etc.)
DestinationSpecific destination
Time ConditionOptional time-based routing
Dial ProfileOptional Dial Profile template to control call variables (transfers, ringbacks) for incoming calls
Failover ModuleBackup destination type
Failover DestinationBackup target

Advanced Fields

FieldDescriptionDefault
Record CallAuto-recordOff
AnnouncementPlay before routingNone
Strip DigitsRemove N digits0
Add PrefixPrepend digitsNone
Block AnonymousReject hidden callersOff
Country FilterGeographic restrictionsNone
Allowed GatewaysGateway restrictionsAll
Max ConcurrentCall limitUnlimited
Limit ActionWhen limit reachedBusy
External APIWebhook before routingNone
---

5. Destination Modules

Available Destinations

ModuleDescriptionHandler
ExtensionRoute to extensionrouting/extension.lua
IVRRoute to IVR menurouting/ivr.lua
QueueRoute to call center queuerouting/queue.lua
Ring GroupRoute to ring grouprouting/ring_group.lua
ConferenceRoute to conference roomrouting/conference.lua
AnnouncementPlay announcementrouting/announcement.lua
Call FlowRoute to call flowrouting/call_flow.lua
Time ConditionTime-based routingrouting/time_condition.lua
Direct RouteDirect external routerouting/direct_route.lua
Direct DialSpeed dial destinationrouting/direct_dial.lua
LanguageLanguage selectionrouting/language.lua
FaxFax serverrouting/fax.lua
EmergencyEmergency routingrouting/emergency.lua

Destination Selection Flow

Plaintext
Destination Module: Queue
       │
       ▼
Destination Dropdown loads:
├─ Sales Queue
├─ Support Queue
├─ Billing Queue
└─ ...
       │
       ▼
Select: "Support Queue"

---

6. Pattern Matching

Number Pattern Syntax

PatternMatchesExample DID
^5055551234$Exact number5055551234
^505555.505555 + any digits5055551234, 5055559999
^1800\d{7}$1800 + 7 digits18001234567
.Any numberAll DIDs

Caller ID Filter

PatternFilters
^1800.Toll-free callers
^505.Local callers
^011.International callers
^(PRIVATEANONYMOUS)$Anonymous callers

Pattern Examples

PurposeNumber PatternCaller Filter
Specific DID^5055551234$-
Range of DIDs^505555\d{4}$-
VIP Callers^5055551234$^18001234567$
Block Toll-Free^5055551234$^(?!1800).
---

7. Common Scenarios & Examples

Scenario 1: Main Business Line

Route: "Main Line"
SettingValue
Number Pattern^5055551234$
Destination ModuleIVR
DestinationMain Auto-Attendant
Priority100
Record Call
Block Anonymous

Scenario 2: Support Queue with Time Routing

Route: "Support Line"
SettingValue
Number Pattern^5055559999$
Time ConditionBusiness Hours
Destination ModuleQueue
DestinationSupport Queue
Failover ModuleVoicemail
Failover DestinationSupport Mailbox

Scenario 3: VIP Caller Direct to Extension

Route: "VIP Direct Line"
SettingValue
Number Pattern^5055551234$
Caller ID Filter^15055559999$
Priority50 (higher than main)
Destination ModuleExtension
Destination1001 (CEO)

Scenario 4: Fax Line

Route: "Fax Line"
SettingValue
Number Pattern^5055550000$
Destination ModuleFax
DestinationFax Server
---

8. Limitations & Important Notes

Technical Notes

NOTE
Priority Order: Inbound routes are checked by priority (lowest first). First match wins.
WARNING
Pattern Overlap: If patterns overlap, use priority to control which route wins.
WARNING
Regex Escaping: Use \. for literal dots, \d for digits.

Best Practices

  1. Use Exact Patterns: ^5055551234$ is safer than 505555.
  2. Set Priorities: Lower priority for specific routes (50), higher for catch-all (999)
  3. Test Patterns: Verify patterns match intended DIDs
  4. Configure Failover: Always have a backup destination
  5. Use Time Conditions: Route differently for business/after hours

---

9. Troubleshooting Tips

Common Issues

SymptomPossible CauseSolution
Wrong destinationPattern overlapAdjust priorities
No route foundPattern doesn't matchTest regex pattern
Call rejectedAnonymous blockingDisable or adjust
Failover not workingFailover not configuredSet failover module
Time routing wrongTime condition incorrectCheck time condition

Diagnostic SQL

List inbound routes:

Sql
SELECT id, name, number_pattern, destination_module, destination_data, priority, enabled
FROM public.inbound_routes
WHERE domain_id = [domain_id]
ORDER BY priority;

Test pattern matching:

Sql
SELECT name, number_pattern, destination_module, destination_data
FROM public.inbound_routes
WHERE domain_id = [domain_id]
  AND enabled = TRUE
  AND '5055551234' ~ number_pattern
ORDER BY priority
LIMIT 1;

FreeSWITCH Logs

Bash
# Check inbound routing
grep "inbound_routes" /var/log/freeswitch/freeswitch.log
grep "route_with_fallback" /var/log/freeswitch/freeswitch.log

---

10. Glossary

TermDefinition
Inbound RouteRule for routing incoming calls
DIDDirect Inward Dialing number
Number PatternRegex to match dialed number
Caller ID FilterRegex to match caller number
Destination ModuleType of destination (extension, ivr, etc.)
Time ConditionTime-based routing rule
FailoverBackup destination if primary fails
---

Lua Script Status ✅

Already Correct

ScriptStatus
route_with_fallback.lua✅ Uses public.inbound_routes with correct schema
Relevant code section (lines 281-296):

Lua
dbh:query(string.format([[
  SELECT 
    destination_module,
    destination_data
  FROM public.inbound_routes
  WHERE domain_id = %s
    AND enabled = TRUE
    AND '%s' ~ number_pattern
    AND (caller_id_filter IS NULL OR '%s' ~ caller_id_filter)
  ORDER BY priority ASC
  LIMIT 1
]], domain_id, escape_sql(destination), escape_sql(caller_id_number)), function(row)
  ...
end)

No Lua fixes needed!

---

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?