How to Remove +91 / 91 from Incoming Caller ID in VICIdial (Fix Lead Matching Issue)

Problem Overview

 == Using SIP RTP CoS mark 5
       > 0x7f81dc00eab0 -- Strict RTP learning after remote address set to: 172.16.10.222:19274
    -- Executing [5101@trunkinbound:1] NoOp("SIP/JIO-00000003", "Inbound call from +918318841546") in new stack
    -- Executing [5101@trunkinbound:2] ExecIf("SIP/JIO-00000003", "1?Set(CALLERID(num)=8318841546)") in new stack
    -- Executing [5101@trunkinbound:3] ExecIf("SIP/JIO-00000003", "0?Set(CALLERID(num)=18841546)") in new stack
    -- Executing [5101@trunkinbound:4] NoOp("SIP/JIO-00000003", "CallerID after strip: 8318841546") in new stack
    -- Executing [5101@trunkinbound:5] AGI("SIP/JIO-00000003", "agi-DID_route.agi") in new stack
    -- Launched AGI Script /usr/share/asterisk/agi-bin/agi-DID_route.agi
    -- AGI Script Executing Application: (Monitor) Options: (wav,/var/spool/asterisk/monitor/MIX/20260110121607_5101_8318841546)
    -- <SIP/JIO-00000003>AGI Script agi-DID_route.agi completed, returning 0
    -- Executing [99909*2***DID@default:1] Answer("SIP/JIO-00000003", "") in new stack
       > 0x7f81dc00eab0 -- Strict RTP qualifying stream type: audio
       > 0x7f81dc00eab0 -- Strict RTP switching source address to 172.16.60.1:19274
    -- Executing [99909*2***DID@default:2] AGI("SIP/JIO-00000003", "agi-VDAD_ALL_inbound.agi") in new stack

In many VICIdial installations in India, inbound calls arrive with the caller ID in E.164 format, such as:

+91XXXXXXXXXX

or

91XXXXXXXXXX

However, most VICIdial lead databases store phone numbers in 10-digit format:

XXXXXXXXXX

Because of this mismatch, VICIdial fails to:

  • Match inbound calls with existing leads
  • Display correct customer information to agents
  • Properly log inbound calls against leads

This article explains how to fix this issue permanently by stripping +91 or 91 from incoming Caller IDs.


Environment Used

  • VICIdial
  • Asterisk 16
  • SIP trunk (example: Jio SIP)
  • Inbound calls routed through [trunkinbound] context
  • Caller ID received as +91XXXXXXXXXX

Root Cause of the Issue

From the Asterisk CLI logs:

Inbound call from +918318841546
CallerID after strip: +918318841546

The issue occurs because:

  • The dialplan logic checks for 91
  • But the actual number starts with +91
  • Therefore, the condition fails and Caller ID remains unchanged

VICIdial performs lead lookup using CALLERID(num), not the DID or EXTEN.


Correct Solution: Strip +91 and 91 in Asterisk Dialplan

The Caller ID must be normalized before it reaches VICIdial’s agi-DID_route.agi.

File to Edit

/etc/asterisk/extensions-vicidial.conf

(or extensions.conf, depending on your setup)


Working Dialplan Configuration

Use the following configuration in your inbound context (example: [trunkinbound]):

[trunkinbound]
exten => _X.,1,NoOp(Inbound call from ${CALLERID(num)})

; Strip +91XXXXXXXXXX
exten => _X.,n,ExecIf($["${CALLERID(num):0:3}"="+91"]?Set(CALLERID(num)=${CALLERID(num):3}))

; Strip 91XXXXXXXXXX (without plus)
exten => _X.,n,ExecIf($["${CALLERID(num):0:2}"="91"]?Set(CALLERID(num)=${CALLERID(num):2}))

exten => _X.,n,NoOp(CallerID after strip: ${CALLERID(num)})
exten => _X.,n,AGI(agi-DID_route.agi)
exten => _X.,n,Hangup()


How This Works

Incoming Caller IDResult
+9183188415468318841546
9183188415468318841546
8318841546No change

After normalization:

  • VICIdial matches leads correctly
  • Agent screens show proper customer details
  • Call recordings use clean numbers

Apply Changes

Reload the dialplan:

asterisk -rx "dialplan reload"

Verify from Asterisk CLI

Run:

asterisk -rvvvvv

Expected output:

Inbound call from +918318841546
CallerID after strip: 8318841546

This method:

  • Requires no dialplan edits
  • Works across upgrades
  • Is the preferred VICIdial approach

Note:-

In-Group Call Handle Method: CIDLOOKUP uses all system to search leads based on CALLERID

Conclusion

If your inbound calls are not matching leads due to +91 or 91 prefixes:

  • Normalize CALLERID(num) before VICIdial processes the call
  • Handle both +91 and 91 formats
  • Prefer VICIdial’s CID Number Rules for long-term stability

This fix is essential for Indian VICIdial installations using SIP trunks.

This entry was posted in Vicidial and tagged , , , , , . Bookmark the permalink.