How to set Asterisk to remove caller ID from call recording filename


Trying to solve an issue with call recordings where there is a strange Caller ID # in the filename (The caller ID number shows as “+15221”). Having this + symbol write to the filename breaks it so that we aren’t able to easily pull up the call using Queuemetrics. The file is not associated with the call when we look for it. This prevents Supervisors from finding the calls when they need them.

Loway support advised that we could change things so that Asterisk does not include the Caller ID # in the filename and this would be an easy fix. Can someone tell me how to accomplish this?

Current filename:

Want it to be:

System info:
PBX Firmware: 2.210.62-1
PBX Service Pack:

Thanks in advance!,


This sounds like it could be a bug. I would get in touch with their support:

I think if they urlencode the filename it will take care of things.

You need to fix your trunking, an initial “+” indicates to the telephony world that you are using e164 where the + is metadata for your local international dialcode, the second digit “1” indicates that you are getting a call from NANP land, 522 is an unassigned area code and +1 always needs 10 more digits. So whover is sendoing you that CallerID needs to fix it :slight_smile:

(But I agree with James, Queuemetrics are also wrong and need to fix their stuff also, I don’t think e164 is going to go away anytime soon)

Thank you for the info! Will look into it and post the outcome. I did already put this in as a bug with QM support, they did not mention anything about fixing the bug, just that I can change the filename as a workaround :confused:

I see, if you don’t care about it you can set Asterisk in order to not
put the caller ID in the filename.


Looking on the server, I’m actually seeing more files with the + in
Appears that it is not a one-time issue.

Hi Ryan,
in some versions of QueueMetrics there’s a bug where the filename of
the recording contains a plus. If this is a one-time issue I suggest
you to just rename the file (the is that the filename contains the
asterisk call id).

Kind Regards

“You need to fix your trunking, an initial “+” indicates to the telephony world that you are using e164 where the + is metadata for your local international dialcode, the second digit “1” indicates that you are getting a call from NANP land, 522 is an unassigned area code and +1 always needs 10 more digits. So whover is sendoing you that CallerID needs to fix it smile”

Just to clarify, is this something we need to fix on our end with our trunks? Or can this only be resolved at the carrier or caller level?

Also, as a workaround until Queuemetrics addresses the bug, would you happen to know where we can change things so that the caller ID # is not added to the filename when written?

presumably your carrier is screwing up . whois 1522. . anyway. you can mangle inbound calls using the e164 inbound template in extensions.conf just make a custom context in extensions_custom.conf and send your inbound calls to that.

Sorry, I am still trying to wrap my head around this. I am very new to asterisk as well as linux, please excuse my ignorance. The vendor who installed [and is supposed to support] our asterisk system has been unwilling to fix any of our ongoing issues, we got ripped off, so I am just trying to wing it and fix what issues I can until we get another phone vendor to provide support for us.

I found extensions_custom.conf and when I look in this file I see the following lines in there:

exten => s,1,AGI(
exten => s,1,AGI(
exten => s,n,Goto(from-internal,${dtmfval},1)

About what’s in there:
All I personally know is palookup is a destination we send inbound calls to that will route all callers from Pennsylvania to the appropriate department and then Inbound2CApp is a program that works off of the last 5 digits of a TFN that sends calls to misc applications for call routing.

So, from your message, all I understand is I need to modify this file / files and add a template of some sort that will tell it to strip off the +1 from inbound calls.

A few more questions I have if you don’t mind:
1: Could you tell me what exactly I need to add to extensions_custom.conf? You mentioned there is a template for e164. Could you show me what this should look like? I’ve never edited a .conf on this phone system but I do have a QA FreePBX server I set up I can test with to make sure I don’t break anything.
2: Do I also need to edit extensions.conf in order for this to work?

I can do it if I have some more specific instruction, but could not figure out exactly what I need to do after reading your message. Thank you for your time and apologies for the long note here.

Side note:
What we tried here (My manager found this in another support article and asked that I try it because neither of us know how to make the change that you mentioned), was go to FreePBX Administrator > Connectivity > Trunks > Select Inbound Trunk > edit the PEER details:

Change line ‘context=from-trunk’ to ‘;context=from-trunk’ to comment it out
Add line ‘context=from-pstn-e164-us’

After making that change, I can see it still adds the +1 to the filename for inbound calls. I now understand that the PEER details is only for -outbound-settings, this explains why it did not work. The article he read was for someone that wanted the +1 removed for a problem they were having when dialing out. Not the same problem I have.

I then tried adding that line to USER details which is the only option under inbound settings, and this did not work either so I removed the line out of there.

You have my sympathies, but run as quick as you can and as far as you can from this provider, without looking at the AGI scripts, no-one can know what they they do, few will debug someone else’s duck &^&%$ and if it looks like a duck and quacks like a duck and Sh15ts like a duck it is probably a duck.

Good luck butr REALLY get a real provider :wink:

Understood. Thanks anyways for all your help dicko.


we confirm the bug has been solved. The fix will be available with the new release of QueueMetrics.

Best Regards

Our provider gave me the following context to strip +1 off of inbound CID, we added it, it works, but I need to change it so it strips the + off of any call that comes in, not just CIDs that start with +1. (For example, I have calls coming in that are showing a CID of “+2002”

So my question is, what would be the proper way to adjust this context so that it strips the + off all incoming calls? Not just calls that start with +1?

Context from extensions_custom.conf:

exten => _X.,1,GotoIf($["${CALLERID(num):0:2}" != “+1”]?noplusatstart)
exten => _X.,n,NoOp(Changing Caller ID number from ${CALLERID(num)} to ${CALLERID(num):2})
exten => _X.,n,Set(CALLERID(num)=${CALLERID(num):2})
exten => _X.,n,Set(CALLERID(ANI)=${CALLERID(num)})
exten => _X.,n(noplusatstart),Goto(from-trunk,${EXTEN},1)

Thanks in advance!,


Asterisk/FreePBX includes a more rigorous context in /etc/asterisk/extensions.conf, namely:-


If you are in NANP land it works well, if not then you could template it to suit your locale and the vagaries of your provider in extensions_custom.conf

In your case you maybe you could use their context but substitute

exten => _X.,1,GotoIf($["${CALLERID(num):0:1}" != “+”]?noplusatstart)
exten => _X.,n,NoOp(Changing Caller ID number from ${CALLERID(num)} to ${CALLERID(num):1})

I would also add that incoming CID’s of 4 digits would suggest that your VSP don’t know what they are doing and gave you misinformation.

Thanks very much for the help again! Will do some testing and follow up.