VICIfast
Carriers & SIP

Stripping or Adding Digits Before the Carrier Sees Them

VICIdial almost never sends the carrier exactly what was dialed. Here is how the dialplan strips and adds digits so your trunk gets the format it expects.

VICIfast Support
··4 min read
Stripping or Adding Digits Before the Carrier Sees Them

When an agent dials a number, the digits that VICIdial captures are rarely the digits your carrier wants to receive. VICIdial adds a leading prefix so the call matches an outbound pattern, and then it strips part of that prefix back off before handing the call to the trunk. If you get this wrong, the carrier rejects the call or routes it to the wrong place.

This post walks through exactly where the stripping and adding happen, so you can read a carrier dialplan entry and know what is going out the wire.

Why a prefix gets added in the first place

VICIdial uses a leading 9 (and often a 1) to mark a number as an outbound call. A campaign dial prefix is glued onto the front of the lead phone number, so a 10-digit US number becomes something like 913125550123. That extra 91 is what the dialplan pattern matches on. The pattern in a carrier entry looks like _91NXXNXXXXXX, where N means a digit 2 through 9 and X means any digit 0 through 9.

So the prefix is doing two jobs at once: it tells VICIdial "this is an outbound call, route it," and it gives the dialplan a clean pattern to anchor on. But your carrier does not want the 91. That is where stripping comes in.

How EXTEN substring stripping works

Asterisk exposes the matched number as ${EXTEN}. You strip leading digits with a substring: ${EXTEN:2} returns everything after the first two characters. So if the call came in as 913125550123, then ${EXTEN:2} is 13125550123. A typical Dial line looks like Dial(SIP/trunk/${EXTEN:2}), which hands the carrier the 1+10-digit number with the 9 removed.

Want to send only the last 10 digits instead? Use a negative offset: ${EXTEN:-10} grabs the final ten characters regardless of what is in front. This is the same trick used elsewhere when a downstream script needs a bare 10-digit number. The Dialplan is just doing arithmetic on a string.

Adding digits is even simpler. You concatenate. If your carrier needs an account code or a stray prefix in front, you write Dial(SIP/trunk/8881${EXTEN:2}) and the literal 8881 rides along ahead of the stripped number.

flowchart TD
  A[Agent dials 3125550123] --> B[Campaign adds 91 prefix]
  B --> C[Dialplan matches _91NXXNXXXXXX]
  C --> D[Strip first 2 with EXTEN colon 2]
  D --> E[Optional add carrier prefix]
  E --> F[Dial out SIP trunk]
  F --> G[Carrier receives 13125550123]

Matching the format your carrier expects

Carriers disagree on format. Some want a bare 10-digit number, some want 1 plus 10, and some want full E.164 with a + and the country code (so +13125550123). Your job is to make the dialplan output line up with what the trunk accepts, or every call comes back rejected.

  • Carrier wants 11 digits (1NXXNXXXXXX): keep ${EXTEN:2} on a _91 pattern.
  • Carrier wants 10 digits (NXXNXXXXXX): strip three with ${EXTEN:3} on a _911 pattern, or use ${EXTEN:-10}.
  • Carrier wants E.164 (+1NXXNXXXXXX): add a plus with Dial(SIP/trunk/+${EXTEN:3}).

This is closely tied to how the campaign assigns the prefix in the first place. If you change the strip count without changing the prefix the pattern matches, calls silently stop matching. For the campaign side of the same coin, see how a dial prefix routes to a carrier.

Count your characters, not your intentions. A _91 pattern needs ${EXTEN:2} to drop the 9 and keep the 1. If you reflexively write ${EXTEN:3} you will also eat the 1, and a carrier expecting 11 digits will reject the call with no obvious error in the agent screen.

International and special cases

For international dialing you usually match a longer pattern like _9011. and strip the leading 9, sending 011 plus the country code and number. Different carriers want different country-code handling, so confirm the format before you load a single lead. Pattern order matters too: Asterisk picks the most specific match, so a tight _91NXXNXXXXXX wins over a loose _9. catch-all sitting in the same context.

If you run more than one carrier, each one can strip and add differently in its own dialplan entry, which is part of how failover and least-cost routing stay clean. See the full carrier integration guide for how the pieces fit together across multiple trunks.

Wrapping up

Stripping and adding digits is just string math sitting between your campaign and your SIP trunk: the prefix gets the call routed, the substring trims it to what the carrier wants, and a concatenation adds anything extra. Get the count right and outbound just works.

On VICIfast we provision a hardened VICIdial box in under 40 seconds with sane default dialplans already in place, so you only edit the strip count when a carrier asks for something unusual. See plans and 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. “Stripping or Adding Digits Before the Carrier Sees Them”. VICIfast LLC, June 24, 2026. Retrieved from https://vicifast.com/blog/vicidial-strip-add-digits-dialplan

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.