Ctrl K
ring2all.com

SMS Routes

Ring2All Platform — SMS Routing Configuration
Parent Module: SMS Messaging

---

Overview

SMS Routes determine which provider handles outbound messages based on destination number patterns. Routes support prefix matching, country code filtering, priority ordering, and failover providers.

Admin Panel → SMS → Routes

---

Configuration Fields

Field NameTechnical DescriptionUser-Friendly TooltipExampleNotes
NameRoute identifier in name.A name for this routing rule.US DomesticMust be unique per domain.
Prefix PatternRegex pattern in prefix_pattern.Number pattern to match (regex).^\+1[2-9]Matches numbers starting with this pattern.
Country CodeISO code in country_code.Country code to match (ISO 2-letter).USAlternative to prefix pattern matching.
ProviderPrimary provider in provider_id.Provider to use for matching messages.Twilio USFirst provider to try for this route.
Fallback ProviderBackup in fallback_provider_id.Backup provider if primary fails.TelnyxUsed when primary returns error.
PriorityOrder in priority.Route priority. Lower numbers match first.100Routes are evaluated in priority order.
EnabledToggle in enabled.Enable or disable this route.trueDisabled routes are not evaluated.
---

Route Matching Logic

When sending an SMS, routes are evaluated in this order:

Plaintext
1. Sort all enabled routes by priority (ascending)
2. For each route:
   a. If prefix_pattern exists:
      - Test destination against regex pattern
   b. Else if country_code exists:
      - Extract country from destination, compare
   c. If matched → Use this route's provider
3. If no route matches → Use default provider

Priority Examples

PriorityRoute NamePatternProvider
10Emergency^\+1911Primary
50US Mobile^\+1[2-9]\d{2}[2-9]Twilio
100US Domestic^\+1Twilio
200Canada^\+1[2-9]\d{2}Telnyx
500International.Telnyx
> 💡 Tip: Use lower priority numbers for more specific patterns, higher for catch-all routes.

---

Pattern Matching

Prefix Pattern (Regex)

Prefix patterns use regular expressions:

PatternMatchesDescription
^\+1+1XXXXXXXXXXAll US/Canada numbers
^\+1[2-9]\d{2}+1XXX...US/Canada area codes
^\+44+44XXXXXXXXXUK numbers
^\+52+52XXXXXXXXXMexico numbers
^\+[2-9]Non-+1 numbersAll international
.EverythingCatch-all default

Country Code (ISO)

Alternatively, use 2-letter ISO country codes:

CodeCountry
USUnited States
CACanada
MXMexico
GBUnited Kingdom
DEGermany
> ⚠️ Note: If both prefix pattern AND country code are set, prefix pattern takes precedence.

---

Failover Configuration

Each route can have a fallback provider:

Plaintext
Message to +1555...
    │
    ▼
┌─────────────────┐
│ Route: US Dom   │
│ Provider: Twilio│
└────────┬────────┘
         │
         ▼ Try Twilio
    ┌────────────┐
    │ Success?   │
    └──────┬─────┘
       Yes │  No
       ────┼────
           │
           ▼
    ┌─────────────────┐
    │ Fallback:       │
    │ Telnyx          │
    └────────┬────────┘
             │
             ▼ Try Telnyx

When Fallback Triggers

Fallback is used when primary provider returns:

  • HTTP 5xx errors (server error)
  • Timeout errors
  • Rate limit errors
  • Temporary failures

Fallback is NOT used for:

  • Invalid number errors
  • Authentication errors
  • Permanent failures

---

Common Route Configurations

Simple Single-Provider

One route for all messages:

RoutePatternProvider
All Messages.Twilio US

US + International Split

Separate providers for domestic vs. international:

PriorityRoutePatternProvider
100US Domestic^\+1Twilio US
200International.Telnyx Intl

Multi-Region with Failover

PriorityRoutePatternProviderFallback
100US Mobile^\+1[2-9]TwilioBandwidth
200Canada^\+1[2-9]TelnyxTwilio
300Mexico^\+52Telnyx-
500Default.BandwidthTwilio
---

Troubleshooting

IssueCauseSolution
Wrong provider usedPriority misconfiguredCheck route priorities (lower = first)
No route matchedPattern doesn't matchTest pattern against destination number
Failover not triggeringNon-retryable errorCheck provider error type
Route not evaluatingRoute disabledEnable the route
Default provider used unexpectedlyNo routes matchAdd more specific routes

Testing Route Matching

To test which route a number matches:

  1. Note the destination number (e.g., +15551234567)
  2. List routes sorted by priority
  3. Test each regex pattern against the number
  4. First match wins

---

Database Schema

Sql
CREATE TABLE sms_routes (
    id                   SERIAL PRIMARY KEY,
    uuid                 UUID DEFAULT gen_random_uuid(),
    domain_id            INTEGER NOT NULL,
    name                 VARCHAR(255) NOT NULL,
    prefix_pattern       VARCHAR(100),
    country_code         VARCHAR(2),
    provider_id          INTEGER NOT NULL REFERENCES sms_providers(id),
    fallback_provider_id INTEGER REFERENCES sms_providers(id),
    priority             INTEGER DEFAULT 100,
    enabled              BOOLEAN DEFAULT TRUE,
    created_at           TIMESTAMP DEFAULT NOW(),
    created_by           INTEGER,
    updated_at           TIMESTAMP,
    updated_by           INTEGER,
    UNIQUE(domain_id, name)
);

---

See also: SMS Providers | SMS Numbers | SMS Settings*


Glossary

TermDefinition
SMS RoutingRules directing SMS traffic to specific users or queues
---

Lua Script Status ℹ️

Integration Module

ComponentStatusNotes
SMS Routesℹ️ Configuration moduleRouting rules applied by the main SMS handler
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?