<div class="gmail_quote">2011/6/2 Antonio Modesto <span dir="ltr">&lt;<a href="mailto:modesto@isimples.com.br">modesto@isimples.com.br</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">



  
  

<div>
Good afternoon,<br>
<br>
I&#39;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.<br>

<br clear="all"></div></blockquote><div><br>The way I did it was to use a DeadAGI from the &#39;h&#39; exten that created a call file.  This is how I did it for a client on Asterisk 1.4.x:<br><br>[rec-call-back-in]<br>exten =&gt; new,1,Answer()<br>
exten =&gt; new,n,Wait(1)<br>exten =&gt; new,n,Playback(vm-intro)<br>exten =&gt; new,n,Playback(beep)<br>exten =&gt; new,n,Set(timestamp=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)})<br>exten =&gt; new,n,Set(FILENAME=reccallback/${CALLERID(num)}-${timestamp})<br>
exten =&gt; new,n,Record(${FILENAME}.gsm,,,q)<br>exten =&gt; new,n,Playback(vm-goodbye)<br>exten =&gt; new,n,Hangup()<br><br>exten =&gt; h,1,Verbose(Hangup after recording)<br>exten =&gt; h,n,DeadAGI(reccallback.agi,${FILENAME},${TIMESTAMP})<br>
<br>[rec-call-back-out]<br>exten =&gt; out,1,Wait(2)<br>exten =&gt; out,n,Playback(${playbackfile})<br>exten =&gt; out,n,Hangup()<br><br>reccallback.agi:<br>#!/usr/bin/perl<br><br>use Asterisk::AGI;<br>use File::Copy;<br>
<br>$AGI = new Asterisk::AGI;<br><br>my %input = $AGI-&gt;ReadParse();<br>my $callerid = $input{&#39;callerid&#39;};<br><br>my $recfile = $ARGV[0];<br>my $timestamp = $ARGV[1];<br><br>open CALLFILE, &quot;&gt;/var/spool/asterisk/tmp/$callerid-$timestamp.call&quot;;<br>
if (length($callerid) &gt; 4) {<br>    print CALLFILE &quot;Channel: SIP/external-sip-provider/+1$callerid\n&quot;;<br>} else {<br>    print CALLFILE &quot;Channel: SIP/$callerid\n&quot;;<br>}<br>print CALLFILE &quot;CallerID: \&quot;CUSTOMER\&quot; &lt;XXXXXXXXXX&gt;\n&quot;;<br>
print CALLFILE &quot;MaxRetries: 2\n&quot;;<br>print CALLFILE &quot;RetryTime: 60\n&quot;;<br>print CALLFILE &quot;WaitTime: 20\n&quot;;<br>print CALLFILE &quot;Context: rec-call-back-out\n&quot;;<br>print CALLFILE &quot;Extension: out\n&quot;;<br>
print CALLFILE &quot;Priority: 1\n&quot;;<br>print CALLFILE &quot;Set: playbackfile=$recfile\n&quot;;<br>close CALLFILE;<br>sleep(5);<br><br>copy(&quot;/var/spool/asterisk/tmp/$callerid-$timestamp.call&quot;, &quot;/var/spool/asterisk/outgoing/$callerid-$timestamp.call&quot;) or die &quot;copy failed: $!&quot;;<br>
<br>exit;<br> <br></div></div><br>-- <br>Thanks,<br>--Warren Selby, dCAP<br>Our website just got a facelift!  Check it out!<br><a href="http://www.selbytech.com" target="_blank">http://www.SelbyTech.com</a><br><br>