VICIfast
Carriers & SIP

How Outbound Calls Find the Right Carrier in VICIdial

When an agent dials, Asterisk matches the number against dialplan patterns to pick a trunk. Here's how that routing actually works.

VICIfast Support
··3 min read
How Outbound Calls Find the Right Carrier in VICIdial

You load leads, an agent clicks dial, and the call goes out. Behind that one click, VICIdial hands the number to Asterisk, Asterisk compares it against a list of patterns, and the first matching pattern decides which carrier carries the call. If you understand that matching step, most carrier-routing problems stop being mysterious.

This post walks through how a dialed number turns into an outbound leg, and where you'd look when a call goes out the wrong trunk or doesn't go out at all.

The dialplan is a list of patterns

The Dialplan is Asterisk's routing table. Each carrier you add contributes a dialplan entry like exten => _91NXXNXXXXXX,1,... The underscore marks it as a pattern, N means any digit 2 through 9, and X means any digit 0 through 9. So _91NXXNXXXXXX matches a 1 plus a 10-digit North American number, with a 9 in front. When a number comes in, Asterisk finds the pattern that matches it and runs that entry's steps.

The last step in a carrier entry is the Dial command, and that's the piece that names the Trunk. Something like Dial(newsip:test@host/${EXTEN:2}) sends the call out the SIP peer called newsip. So the pattern decides whether this carrier is used, and the Dial line decides which peer it leaves through.

Why the leading digits matter

That 9 at the front of the pattern is a Dial prefix, a digit VICIdial bolts onto the number before sending it. The campaign's dial prefix and the pattern's leading digits have to agree, or nothing matches. The ${EXTEN:2} part then strips the first two digits (the 9 and the 1) back off before the number reaches the carrier, because the carrier wants the real number, not your routing prefix.

EXTEN:2 means "everything after the first 2 characters." If your pattern strips the wrong count, the carrier sees a malformed number and rejects the call. Match the strip count to how many routing digits you added in front.

The matching flow, step by step

flowchart TD
  A[Agent dials number] --> B[VICIdial adds dial prefix]
  B --> C[Asterisk searches dialplan]
  C --> D{Pattern matches?}
  D -->|No match| E[Call fails - no route]
  D -->|Matches| F[Run matched extension steps]
  F --> G[Strip routing digits]
  G --> H[Dial out carrier trunk]
  H --> I[Carrier sends to PSTN]

When two patterns could match

Asterisk uses most-specific-wins matching: a more exact pattern beats a looser one. If you have a broad catch-all and a tighter pattern for a specific number range, the tighter one takes the call. This is exactly the lever you use to send some traffic out a cheaper carrier, which is the idea behind Least-cost routing. For now, just know that overlapping patterns aren't random; the more specific match wins.

Each carrier still rides its own SIP trunk, so a clean routing setup is really a clean set of patterns, one per Carrier, with strip counts that line up. If you ever see calls leaving the wrong provider, the culprit is almost always an overlapping or overly broad pattern.

Debugging a route that won't fire

  • Confirm the campaign dial prefix matches the leading digits in the carrier pattern.
  • Check the strip count in ${EXTEN:n} against how many digits you prepend.
  • Make sure the carrier is Active=Y and its peer is registered or whitelisted.
  • Watch the Asterisk CLI while you place a test call to see which extension fires.

For the bigger picture of carrier setup, start with the carrier integration guide. If you want to choose a carrier per dialed number, read using a dial prefix to pick a carrier.

Outbound routing is just pattern matching plus a Dial line. Get the prefix, the pattern, and the strip count to agree, and your calls land on the trunk you intended every time. VICIfast spins up a fully wired dialer in under 40 seconds with your carrier patterns ready to edit. See our pricing to get started.

About VICIfast LLC

VICIfast LLC operates a managed VICIdial hosting + BYOI service for outbound and inbound call centers. We run the dialers, the carriers, the recordings pipeline, and the compliance plumbing so operators don’t have to.

Citing this article

VICIfast Engineering. “How Outbound Calls Find the Right Carrier in VICIdial”. VICIfast LLC, June 24, 2026. Retrieved from https://vicifast.com/blog/vicidial-outbound-dialplan-routing

Have questions?

Related posts

You might be interested in

VICIfast newsletter

Liked this? Get the next one in your inbox.

We ship the kind of stuff you just read — concrete, numbers-first, no drip. One email when a new post goes live. Unsubscribe in one click.

Comments

Comments are reviewed before they appear. We never publish your email.

No comments yet — be the first.