[asterisk-users] How to continue processing a context after a Hangup

Warren Selby wcselby at selbytech.com
Thu Jun 2 14:46:36 CDT 2011


2011/6/2 Antonio Modesto <modesto at isimples.com.br>

>  Good afternoon,
>
> I'm trying to write a simple callback context, but i need to hangup an
> incoming call and then call the origin number back, the problem is that
> asterisk stops processing the call after Hangup() application then it is not
> able to dial the origin number back.
>
>
The way I did it was to use a DeadAGI from the 'h' exten that created a call
file.  This is how I did it for a client on Asterisk 1.4.x:

[rec-call-back-in]
exten => new,1,Answer()
exten => new,n,Wait(1)
exten => new,n,Playback(vm-intro)
exten => new,n,Playback(beep)
exten => new,n,Set(timestamp=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)})
exten => new,n,Set(FILENAME=reccallback/${CALLERID(num)}-${timestamp})
exten => new,n,Record(${FILENAME}.gsm,,,q)
exten => new,n,Playback(vm-goodbye)
exten => new,n,Hangup()

exten => h,1,Verbose(Hangup after recording)
exten => h,n,DeadAGI(reccallback.agi,${FILENAME},${TIMESTAMP})

[rec-call-back-out]
exten => out,1,Wait(2)
exten => out,n,Playback(${playbackfile})
exten => out,n,Hangup()

reccallback.agi:
#!/usr/bin/perl

use Asterisk::AGI;
use File::Copy;

$AGI = new Asterisk::AGI;

my %input = $AGI->ReadParse();
my $callerid = $input{'callerid'};

my $recfile = $ARGV[0];
my $timestamp = $ARGV[1];

open CALLFILE, ">/var/spool/asterisk/tmp/$callerid-$timestamp.call";
if (length($callerid) > 4) {
    print CALLFILE "Channel: SIP/external-sip-provider/+1$callerid\n";
} else {
    print CALLFILE "Channel: SIP/$callerid\n";
}
print CALLFILE "CallerID: \"CUSTOMER\" <XXXXXXXXXX>\n";
print CALLFILE "MaxRetries: 2\n";
print CALLFILE "RetryTime: 60\n";
print CALLFILE "WaitTime: 20\n";
print CALLFILE "Context: rec-call-back-out\n";
print CALLFILE "Extension: out\n";
print CALLFILE "Priority: 1\n";
print CALLFILE "Set: playbackfile=$recfile\n";
close CALLFILE;
sleep(5);

copy("/var/spool/asterisk/tmp/$callerid-$timestamp.call",
"/var/spool/asterisk/outgoing/$callerid-$timestamp.call") or die "copy
failed: $!";

exit;


-- 
Thanks,
--Warren Selby, dCAP
Our website just got a facelift!  Check it out!
http://www.SelbyTech.com <http://www.selbytech.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20110602/637cb057/attachment.htm>


More information about the asterisk-users mailing list