How to add two more asterisk commands in callback context

Hi

the default callback context is as follows

[callback]
include => callback-custom
exten => 1,1,Set(CALL=1003)
exten => 1,n,Set(DESTINATION=ivr-7.s.1)
exten => 1,n,Set(SLEEP=60)
exten => 1,n,System(/var/lib/asterisk/bin/callback ${CALL} ${DESTINATION} ${SLEEP} &)
exten => 1,n,Hangup

I like to have as follows

[callback]
include => callback-custom
exten => 1,1,Set(CALL=1003)
exten => 1,n,Set(DESTINATION=ivr-7.s.1)
exten => 1,n,Set(SLEEP=60)
exten => 1,n,System(/var/lib/asterisk/bin/callback ${CALL} ${DESTINATION} ${SLEEP} &)
exten => 1,n,Ringing()
exten => 1,n,wait(10)
exten => 1,n,Hangup

I can edit manually extension_additional.conf to achieve this but next time any change to this file via freeboot web , then I will lose this additional commands (ringing, wait(10))

Please let me know fix this

Thanks

Jay

Hi

Following perl script run by crontab by every 5 minutes helps.

#!/usr/bin/perl -w
$file = “/etc/asterisk/extensions_additional.conf”;
my $now = localtime time;
print “It is now $now\n”;
open FILE, $file or die $!;
my @lines = ;
close FILE;
chomp($) foreach @lines;
#print ‘|’.$
.’|’."\n" foreach @lines;
$pattern = ‘exten => (\d+),n,Hangup’;
$callback = 0;
$index = 1;
$reloadRequired = 0;
foreach $line (@lines) {

if ($line =~ m/callback]/) {
 $callback = 1;
}

if ($line =~ m/^; end of/ ) {
  $callback = 0;
  
}
#print "$line\n" if ($callback == 1);
if ($callback == 1) {
	if ($line =~ m/\/var\/lib\/asterisk\/bin\/callback/) {
		
		if ($lines[$index] =~ m/$pattern/) {
			print $line."\n";
			$line .= "\nexten => $1,n,Ringing()\nexten => $1,n,wait(10)";
			print $line."\n";
			print $lines[$index]."\n";
			$reloadRequired = 1;
		}
	}


}
$index ++;

}

if ($reloadRequired == 1) {
open FILE, “>$file” or die $!;
print FILE $_."\n" foreach (@lines);
close FILE;
sleep(30);
system("//usr/sbin/asterisk -rx ‘dialplan reload’");

} else {
print “No reload required\n”;
}

Oh, sorry, that’s why I said it hadn’t been tested. The only other thing I can think of is maybe if you put your revised callback context (with [callback] as the first line instead of [callback-custom]) into the file extensions_override_freepbx.conf it might work - that basically allows you to replace contexts completely, though I won’t guarantee it will work for that particular context, but it wouldn’t hurt to try. Same cautions as before about new versions.

Can’t really help you with MYSQL, that’s out of my area of knowledge.

Hi

Thanks for the reply

I tried this and it is not working.

When I type following command message is as follows

dialplan show callback

[ Context ‘callback’ created by ‘pbx_config’ ]
‘1’ => 1. Set(CALL=1003) [pbx_config]
2. Set(DESTINATION=ivr-7.s.1) [pbx_config]
3. Set(SLEEP=60) [pbx_config]
4. System(/var/lib/asterisk/bin/callback ${CALL} ${DESTINATION} ${SLEEP} &) [pbx_config]
5. Hangup() [pbx_config]

Include => ‘callback-custom’ [pbx_config]

so the callback-custom is appearing at the end… may be because of that callback-custom was not working

Mean time I wrote a perl script (called by crontab every 3 minutes) if extension_additional.conf changed then modify with additional two commands and call asterisk with dialplan reload

Warm Regards
Jay

PS: where is the retrieve callback from MYSQL to generation of extension_additional.conf coded ? then I can modify that code.

See at the top where it says:
include => callback-custom

That means you can go into /etc/asterisk/extensions_custom.conf and put your modified context there. It must start with the label callback-custom, so in your case this is probably what you’d want to add to that file:

[callback-custom]
exten => 1,1,Set(CALL=1003)
exten => 1,n,Set(DESTINATION=ivr-7.s.1)
exten => 1,n,Set(SLEEP=60)
exten => 1,n,System(/var/lib/asterisk/bin/callback ${CALL} ${DESTINATION} ${SLEEP} &)
exten => 1,n,Ringing()
exten => 1,n,wait(10)
exten => 1,n,Hangup

I have not tested this in any way, but I think the above would work for you. Be aware, though, that any configuration changes that you make, or any program changes the developers make to FreePBX will not change your custom code, so that if you upgrade FreePBX you may need to check to see if the original callback context has been changed, and if so make the equivalent changes in your code.