VICIfast
Guides & tutorials

Per-area-code caller ID with agi-VDADselective_CID.agi

agi-VDADselective_CID.agi runs before each outbound call is placed and selects a caller ID number based on the lead's area code, improving local-number matching for outbound campaigns.

VICIfast Support
··3 min read
Per-area-code caller ID with agi-VDADselective_CID.agi

When you dial a number in area code 312, a caller ID (the number your system presents to the called party) CID (caller ID) that also starts with 312 gets answered more often than one from a distant state. agi-VDADselective_CID.agi is the AGI (Asterisk Gateway Interface) script that makes that matching happen automatically. It runs inside the Asterisk Dialplan before the Dial() command, reads the area code of the number being dialed, and sets the outbound caller ID to a matching local number you have configured.

VICIdial marks this script as experimental, which means it is functional but may behave differently across Asterisk versions or carrier configurations. It is appropriate for outbound Campaign use when you have a pool of local numbers and want each call to present the closest geographic match to the Lead being dialed.

How area-code matching works

flowchart TD
  A[Outbound dial triggered] --> B[call_log.agi logs the call]
  B --> C[agi-VDADselective_CID.agi runs]
  C --> D{Read area code from dialed number}
  D --> E[Match area code to configured CID pool]
  E --> F{Match found?}
  F -->|Yes| G[Set CALLERID to local number for that area code]
  F -->|No| H[Use default campaign CID]
  G --> I[Dial command executes with selected CID]
  H --> I
  I --> J[Call connects to lead]

The script receives the dialed extension as its argument. It parses the area code from that number and looks up the corresponding caller ID value from its configuration. If a match is found, it sets the outbound caller ID before Asterisk places the call. If no match exists for that area code, the call proceeds with the default caller ID the campaign already has configured.

Dialplan placement

The script must run before Dial() so the caller ID is set in time. The standard placement looks like this:

exten => _91NXXNXXXXXX,1,AGI(call_log.agi,${EXTEN})
exten => _91NXXNXXXXXX,2,AGI(agi-VDADselective_CID.agi,${EXTEN})
exten => _91NXXNXXXXXX,3,Dial(${TRUNKX}/${EXTEN:1},55,tTo)
exten => _91NXXNXXXXXX,4,Hangup

Step 1 logs the call attempt. Step 2 runs the selective CID script with the full dialed extension. Step 3 dials via your configured Trunk with the now-modified caller ID. The ${EXTEN:1} strips the leading prefix digit before sending the number to the carrier.

Caller ID spoofing and compliance considerations

Presenting a number that looks local is a form of Caller ID spoofing — sending a caller ID that does not match the originating line. Whether that is legal in your jurisdiction depends on the purpose of the call and local regulations. In the United States, the Truth in Caller ID Act prohibits using spoofed numbers with intent to defraud. If you use agi-VDADselective_CID.agi to present local numbers you genuinely own and have registered with your Carrier, you are within standard industry practice. Presenting numbers you do not own or control is a different matter and should be verified with your legal team.

This script is marked EXPERIMENTAL. Test it thoroughly in a non-production environment before using it on live outbound campaigns. Behavior may vary across Asterisk versions, and some carriers may override the caller ID you set regardless of what the script sends.

There is also a companion script, agi-VDADselective_CID_hangup.agi (also marked experimental), that hangs up the call if the dialed number is not within a specified set of area codes. That script is useful when you want to restrict outbound dialing to specific regions entirely.

To see how this AGI fits within the broader set of VICIdial tools, read the VICIdial API and AGI overview. For a related look at inbound caller ID handling, the guide on the VICIdial API source parameter covers how the source field tracks where calls and leads originate.

If you want a managed VICIdial server where the outbound dialplan is pre-configured and ready for scripts like this one, check the VICIfast plans — each one spins up in under 40 seconds.

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. “Per-area-code caller ID with agi-VDADselective_CID.agi”. VICIfast LLC, June 28, 2026. Retrieved from https://vicifast.com/blog/use-agi-vdadselective-cid

Have questions?

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.