Thanks Daniel.
I was not able to make this work with exactly what you sent but it has helped me get closer.
First it’s /
and not \
that separates the extension from the caller id number.
I see you are inserting this in from-pstn, what about from-trunk or from-trunk-trunkname? In fact, what seems to be happening is that from-trunk-sip-trunkname is being called by default (where trunkname = the name of the trunk). This seems to partly work:
[from-trunk-sip-US-fixcid]
exten => _.,1,Set(CALLERID(num)=CALLERID(ANI))
same => n,Goto(from-trunk-sip-US,${EXTEN},1)
then added context=from-trunk-sip-US-fixcid to the PEER details for the trunk. Note that for the moment I haven’t even matched on the caller id yet, I just wanted to make sure it was working.
Without this, when I call my US number from my UK mobile phone, I see the caller id start with 07… like it was a UK number.
Using the ANI is more interesting. By doing the above, I get a number that starts with a countrycode (44) in my case, no +, no 00, the mobile number looks like 447… Ok so I tried the following:
exten => _.,1,Set(CALLERID(num)=00${CALLERID(ANI)})
but it doesn’t work at all. When I call it from my UK mobile number, I get a caller id string that starts like 07…, no 44, and the 00 is not there! I tried several variations on this and I found no way to prepend the 00. Even just setting:
exten => _.,1,Set(CALLERID(num)=${CALLERID(ANI)})
you would think I would get the same thing as the above, but nope, I am back to a caller id like 07…
so clearly there is something I don’t understand about appending strings in asterisk and about how the CALLERID() function works. I’m not sure what the difference is between ${CALLERID(ANI)} and just CALLERID(ANI). Can anyone shed some light on this?