Ctrl K
ring2all.com

Dynamic Destinations 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. Call Flow / Logic Explanation
  6. Common Scenarios & Examples
  7. Limitations & Important Notes
  8. Troubleshooting Tips
  9. Glossary

---

1. Module Overview (Technical)

What Are Dynamic Destinations?

Dynamic Destinations allow real-time call routing decisions based on external data sources. The system queries a database or HTTP API, evaluates the response, and routes the call to a matching destination.

Architecture

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│                Dynamic Destination System                       │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  Inbound call arrives                                           │
│       │                                                         │
│       ▼                                                         │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │              Dynamic Destination Lookup                  │   │
│  │  SELECT * FROM public.dynamic_destinations               │   │
│  │  WHERE name = [config_name] AND active = TRUE            │   │
│  └──────────────────────────────────────────────────────────┘   │
│       │                                                         │
│       ▼                                                         │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │              Query External Source                       │   │
│  │                                                          │   │
│  │  Source Type: DB                                         │   │
│  │  ├─ Connect to: postgresql://crm.example.com/db         │   │
│  │  └─ Execute: SELECT status FROM clients                 │   │
│  │              WHERE phone='${caller_id_number}'           │   │
│  │                                                          │   │
│  │  Source Type: URL                                        │   │
│  │  ├─ Request: https://api.example.com/lookup             │   │
│  │  └─ Path: /check?caller=${caller_id_number}             │   │
│  │                                                          │   │
│  └──────────────────────────────────────────────────────────┘   │
│       │                                                         │
│       ▼ Response: "VIP"                                        │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │              Match Against Options                       │   │
│  │                                                          │   │
│  │  Option 1: VIP → Queue: vip_support           ← MATCH   │   │
│  │  Option 2: STANDARD → Queue: general_support            │   │
│  │  Option 3: BLACKLIST → Hangup                           │   │
│  │  Default: → Queue: general_support                      │   │
│  │                                                          │   │
│  └──────────────────────────────────────────────────────────┘   │
│       │                                                         │
│       ▼                                                         │
│  Route call to: Queue vip_support                               │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Key Tables

TablePurpose
public.dynamic_destinationsConfiguration (name, source, query)
public.dynamic_destination_optionsMatch values and destinations

Key Files

FileDescription
admin/apps/web/src/modules/dynamicDestinations/Frontend module
admin/apps/web/src/i18n/en/dynamicDestination.jsonTranslations
telephony/freeswitch/lua/main/xml_handlers/dynamic_destination/dynamic_destination.luaHandler
---

2. Module Overview (Commercial/Business)

Business Value

Dynamic Destinations enable intelligent, data-driven routing:

Without Dynamic DestinationsWith Dynamic Destinations
Static routing rulesReal-time decisions
Same treatment for allVIP vs. standard routing
No CRM integrationCRM-aware call handling
Manual blacklist updatesAutomatic blacklist enforcement

Use Cases

  1. CRM-Based VIP Routing
- Query CRM for customer tier

- VIP customers → Priority queue

  1. Credit/Account Status
- Check payment status

- Delinquent → Collections queue

  1. Blacklist Enforcement
- Query blocklist database

- Blocked callers → Hangup or message

  1. Geographic Routing
- Look up caller location

- Route to nearest branch

  1. Business Hours Override
- Query external schedule API

- Dynamic after-hours routing

Feature Highlights

FeatureBenefit
Database SourceQuery PostgreSQL/MySQL directly
HTTP SourceIntegrate with REST APIs
Variable SubstitutionUse ${caller_id_number}, etc.
Multiple OptionsMatch different values to destinations
Default FallbackHandle unmatched cases
Priority OrderingProcess options in order
---

3. Module Overview (End User/Administrator)

What Can You Do?

  • Create routing flows that query external sources
  • Map response values to PBX destinations
  • Configure fallback for unmatched responses
  • Support both database and HTTP queries

Administrator Workflow

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│            Creating a Dynamic Destination                       │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  Step 1: General Settings                                       │
│  ├─ Name: "CRM VIP Lookup"                                     │
│  ├─ Source Type: Database                                      │
│  ├─ Connection: postgresql://crm:pass@crm.local/customers      │
│  ├─ Query: SELECT tier FROM clients                            │
│  │         WHERE phone='${caller_id_number}'                   │
│  └─ Match Field: tier                                          │
│                                                                 │
│  Step 2: Routing Options                                        │
│  ├─ Match "VIP" → Queue: vip_support (Priority 1)              │
│  ├─ Match "GOLD" → Queue: priority_support (Priority 2)        │
│  ├─ Match "BLOCKED" → Hangup (Priority 3)                      │
│  └─ Default → Queue: general_support                           │
│                                                                 │
│  Step 3: Enable and Save                                        │
│                                                                 │
│  Result: Calls are routed based on CRM customer tier           │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Quick Tips

TIP
Variable Substitution: Use ${caller_id_number}, ${destination_number}, etc.
TIP
Always Set Default: Ensure fallback handles query failures.
CAUTION
Query Performance: External queries add latency—keep them fast.

---

4. Configuration Fields Reference

General Settings

FieldDescriptionExampleRequired
NameIdentifierCRM VIP LookupYes
Source TypeDB or URLDatabaseYes
Source ConfigConnection string or URLpostgresql://...Yes
Query TemplateSQL or HTTP pathSELECT tier FROM...Yes
Match FieldResponse key to matchtier, statusYes
Default DestinationFallback routeQueue: generalYes
DescriptionNotesVIP routingNo
ActiveEnabled statusOn/OffYes

Source Types

TypeConfig FormatQuery Format
Databasepostgresql://user:pass@host/dbSQL query
HTTP Requesthttps://api.example.comEndpoint path

Query Template Variables

VariableDescription
${caller_id_number}Caller's phone number
${destination_number}Dialed number
${domain_name}Tenant domain
${caller_id_name}Caller name
${uuid}Call UUID

Routing Options

FieldDescriptionExample
Match ValueValue to matchVIP, BLOCKED
Destination ModuleTarget typeQueue, IVR, Extension
DestinationTarget identifiervip_queue
PriorityProcessing order1 (first), 2, 3...
EnabledActive statusOn/Off
---

5. Call Flow / Logic Explanation

Dynamic Routing Flow

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│                Dynamic Destination Flow                         │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  1. Call arrives, triggers dynamic destination                  │
│     │                                                           │
│     ▼                                                           │
│  2. Load configuration from database                            │
│     ├─ Found & active → Continue                               │
│     └─ Not found → Use default dialplan                        │
│     │                                                           │
│     ▼                                                           │
│  3. Build query with variable substitution                      │
│     ${caller_id_number} → 5551234567                           │
│     │                                                           │
│     ▼                                                           │
│  4. Execute external query                                      │
│     ├─ Database: Run SQL, get result                           │
│     └─ HTTP: Make request, parse response                      │
│     │                                                           │
│     ▼                                                           │
│  5. Extract match field from response                           │
│     Response: {"tier": "VIP"} → Match value: "VIP"             │
│     │                                                           │
│     ▼                                                           │
│  6. Search options (by priority order)                          │
│     ├─ Option "VIP" ← MATCH                                    │
│     │   └─ Route to: Queue vip_support                        │
│     ├─ Option "STANDARD" (skipped)                             │
│     └─ Option "BLOCKED" (skipped)                              │
│     │                                                           │
│     ▼                                                           │
│  7. If no match → Use default destination                       │
│     │                                                           │
│     ▼                                                           │
│  8. Transfer call to resolved destination                       │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

---

6. Common Scenarios & Examples

Scenario 1: CRM Customer Tier Routing

Configuration:
SettingValue
NameCRM Tier Routing
Source TypeDatabase
Connectionpostgresql://crm:pass@crm.local/customers
QuerySELECT tier FROM clients WHERE phone='${caller_id_number}'
Match Fieldtier
Options:
MatchDestination
VIPQueue: vip_support
GOLDQueue: priority_support
STANDARDQueue: general_support
DefaultQueue: general_support

Scenario 2: Blacklist Check via API

Configuration:
SettingValue
NameBlacklist Check
Source TypeHTTP Request
Base URLhttps://blocklist.example.com
Endpoint/check?phone=${caller_id_number}
Match Fieldblocked
Options:
MatchDestination
trueHangup
falseQueue: main_queue
DefaultQueue: main_queue

Scenario 3: Payment Status Routing

Configuration:
SettingValue
NamePayment Status
Source TypeDatabase
QuerySELECT status FROM accounts WHERE phone='${caller_id_number}'
Match Fieldstatus
Options:
MatchDestination
DELINQUENTQueue: collections
SUSPENDEDIVR: payment_options
ACTIVEQueue: customer_service
DefaultQueue: customer_service
---

7. Limitations & Important Notes

Technical Limitations

WARNING
Query Latency: External queries add delay. Keep queries fast (<500ms).
WARNING
Connection Failures: If external source is down, default destination is used.
IMPORTANT
Security: Connection strings are stored in database. Use secure connections.

Best Practices

  1. Fast Queries: Index lookup columns
  2. Timeout Handling: External sources may fail
  3. Default Always: Configure fallback for all cases
  4. Test Thoroughly: Verify all match values route correctly
  5. Monitor Latency: Track query performance

Security Considerations

CAUTION
SQL Injection: Variables are substituted directly—ensure trusted sources.

---

8. Troubleshooting Tips

Common Issues

SymptomPossible CauseSolution
Always uses defaultQuery returns no matchCheck query and match field
"Feature not available"Config not found/disabledVerify active status
Long call setupSlow external queryOptimize query, add indexes
Wrong destinationMatch value mismatchCheck case sensitivity

Diagnostic SQL

List dynamic destinations:

Sql
SELECT name, source_type, match_field, active,
       (SELECT COUNT(*) FROM public.dynamic_destination_options 
        WHERE dynamic_destination_id = d.id) as option_count
FROM public.dynamic_destinations d
WHERE domain_id = [domain_id];

Check options:

Sql
SELECT match_value, destination_module, destination, priority, enabled
FROM public.dynamic_destination_options
WHERE dynamic_destination_id = [dd_id]
ORDER BY priority;

---

9. Glossary

TermDefinition
Dynamic DestinationRouting configuration that queries external sources
Source TypeDatabase (DB) or HTTP Request (URL)
Query TemplateSQL or HTTP path with variable placeholders
Match FieldResponse key containing value to match
Routing OptionMatch value mapped to a destination
Default DestinationFallback when no option matches
Variable SubstitutionReplacing ${var} with call data
PriorityOrder in which options are evaluated
---

Lua Script Status ✅

Integration Module

ComponentStatusLocation
Dynamic Destination Handler✅ Activeapp/dynamic_destination/dynamic_destination.lua
--- 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?