Passing caller ID variable from dialplan to .call file

I have an intercom dialplan (let’s say it’s ext 555) that calls a .call file which in turns dials my intercom paging group (111). This works fine, but the caller ID in my .call file is static (whatever I set “CallerID” to).

Here’s my .call file:

Channel: local/111@ext-paging
CallerID: Intercom
MaxRetries: 2
RetryTime: 5
WaitTime: 30
Context: pa-call-file
Extension: 10

So when I would dial 555, I can record my announcement, and then it will page the 111 group and play back the announcement. It works fine, but the only downside is the caller ID always shows “Intercom” … or whatever I set it to. I’d rather it always show the person who dialed 555 in the first place, so people can see who is making the announcement.

Is this easy to do? I would imagine it’s a simple matter of putting a caller ID variable into the .call file, but I can’t seem to find any info online on how to do that.



I think you need to parse the CallerID as a variable then write the .call file dynamically, where the CallerID part will read off that variable of the source of the call.

I believe the CallerID should read like this

CallerID: “name”

Some parts got clipped off, checkout this link

Ah, I think I get what you’re saying, and that makes sense. I’ll look through that page and see if I can learn how to create the .call file from the dialplan.


Okay… I found a solution.

I don’t know how to write files from a dialplan (although I bet it’s very simple), BUT I know how to write files from PHP. So I just called a PHP script that writes the .call file and puts in the caller ID variable.

Relevant portion of the PHP script is:

$CallFile = “/var/lib/asterisk/sounds/intercom/callfiles/”;
$fh = fopen($CallFile, ‘w’) or die(“can’t open file”);
$stringData = “Channel: local/111@ext-paging\r\n”;
fwrite($fh, $stringData);
$stringData = "CallerID: " . $CallerID . “\r\n”;
fwrite($fh, $stringData);
$stringData = “MaxRetries: 2\r\n”;
fwrite($fh, $stringData);
$stringData = “RetryTime: 5\r\n”;
fwrite($fh, $stringData);
$stringData = “WaitTime: 30\r\n”;
fwrite($fh, $stringData);
$stringData = “Context: pa-call-file\r\n”;
fwrite($fh, $stringData);
$stringData = “Extension: 10\r\n”;
fwrite($fh, $stringData);