Caller ID manipulation

On a sip peer/trunk whats the difference between

callerid= (CALLERID)
and
cid_number= (CID NUMBER)

I am planning to preserve what caller id (origination) the client is sending and at the same time manipulate replace that caller id before going out, WITHOUT losing what caller id the client is sending let say on the cdr.

Thanks

Store original callerid in a channel variable(and later on have original callerid stored in user field of CDR) and set different callerid for outgoing call.

same => n,Set(ORIGINALCIDNUM=${CALLERID(num)})
same => n,Set(ORIGINALCIDNAME=${CALLERID(name)})
… …
… …
same => n,Set(CALLERID(num)=987654321)
same => n,Set(CALLERID(name)=MyName)
same => n,Dial(… … …)

BTW, CALLERID contains lot more information than just a number. wiki.asterisk.org/wiki/display/ … n_CALLERID

–Satish Barot

1 Like

Hi Satish,

Thanks for this, another question would be how can i fetch the stored channel variable and make it available on the CDR.

wiki.asterisk.org/wiki/display/AST/Function_CDR

same => n,Set(ORIGINALCIDNUM=${CALLERID(num)})
same => n,Set(CDR(userfield)=${ORIGINALCIDNUM})
same => n,Set(ORIGINALCIDNAME=${CALLERID(name)})
… …
… …
same => n,Set(CALLERID(num)=987654321)
same => n,Set(CALLERID(name)=MyName)
same => n,Dial(… … …)

–Satish Barot
Ahmedabad, India
+919978599700

Thanks Satish, i think this will work.

Unfortunately, i am using a2billing so will need to look for where to insert this on the agi:

same => n,Set(CALLERID(num)=987654321)
same => n,Set(CALLERID(name)=MyName)
same => n,Dial(… … …)

Since my current dialplan is

exten => _X.,1,Set(CALLERID(num)=${CALLERID(NUM)})
exten => _X.,n,Set(DYNAMIC_FEATURES=)
exten => _X.,n,AGI(a2billing.php,1)
exten => _X.,n,NoOp(=================== HANGUPCAUSE-A2BILLING: ${EXTEN} = ${HANGUPCAUSE} ===================)

That’s an a2billing question, not an Asterisk one.

Yes i understand, thanks anyway.

I haven’t worked with A2billing but you may try following code.

exten => _X.,1,Set(CDR(userfield)=${CALLERID(num)})
exten => _X.,n,Set(ORIGINALCIDNAME=${CALLERID(name)})
exten => _X.,n,Set(CALLERID(num)=987654321)
exten => _X.,n,Set(CALLERID(name)=MyName)
exten => _X.,n,Set(DYNAMIC_FEATURES=)
exten => _X.,n,AGI(a2billing.php,1)
exten => _X.,n,NoOp(=================== HANGUPCAUSE-A2BILLING: ${EXTEN} = ${HANGUPCAUSE} ===================)

–Satish Barot
Ahmedabad,India
+919978599700

It worked!

exten => _X.,1,Set(CDR(userfield)=${CALLERID(num)})
exten => _X.,n,Set(ORIGINALCIDNAME=${CALLERID(name)})
exten => _X.,n,Set(CALLERID(dnid)=${ORIGINALCIDNAME})
exten => _X.,n,Set(CALLERID(num)=Private)
exten => _X.,n,Set(CALLERID(name)=Private)
exten => _X.,n,Set(DYNAMIC_FEATURES=)
exten => _X.,n,AGI(a2billing.php,1)
exten => _X.,n,NoOp(=================== HANGUPCAUSE-A2BILLING: ${EXTEN} = ${HANGUPCAUSE} ===================)

I stored the original CID that i received at the DNID field of the cdr. Thanks Satish for leading me to the solution.

Another question will be regarding cid matching and replacing:

Let say an extension calling out with caller id = 12345 there’s a condition on the dial plan that search for cid = 12345 and if found it will be replaced with 00000.

There are 100+ cid that needs to be matched so there will be a possible need of file where a list of cid stored and their respective equivalent value to be replaced with.

Thanks in Advance!