[Asterisk-Users] Camp on?

Patrick asterisk at puzzled.xs4all.nl
Thu Apr 27 04:33:49 MST 2006


On Thu, 2006-04-27 at 18:08 +0800, Nathan Alberti wrote:
> On 27/04/2006, at 5:45 PM, Patrick wrote:
> 
> > On Thu, 2006-04-27 at 11:10 +0800, Nathan Alberti wrote:
> >>
> >> On 27/04/2006, at 9:15 AM, Eric ManxPower Wieling wrote:
> >>
> >>> Something along the lines of "show application retrydial" ?
> >>>
> >>> dthurn at tstt.net.tt wrote:
> >>>> I am looking for that feature to implement on Asterisk as well.
> >>>> does anyone know how to implement it/
> >>>> Thanks!
> >>>> ----- Original Message ----- From: "Jon Farmer"
> >>>> <viperdude_uk at yahoo.co.uk>
> >>>> To: "Asterisk Users Mailing List - Non-Commercial Discussion"
> >>>> <asterisk-users at lists.digium.com>
> >>>> Sent: Wednesday, April 26, 2006 12:09 PM
> >>>> Subject: Re: [Asterisk-Users] Camp on?
> >>>>> I believe what you refer to is called "Ring Back When Free" at
> >>>>> least thats how I know it in the UK.
> >>>
> >>
> >>
> >> Not quite retrydial, that is more like dial the person and keep
> >> dialing the person until they pickup with the ability to listen to
> >> MOH while you wait.
> >>
> >> I think what the OP is asking for is call someone, they are busy,
> >> press a button to enable callback and as soon as they hang-up from a
> >> call  the callers handset starts ringing to let them know the called
> >> party is now free, when the caller pickups the phone they are
> >> connected to the person they were trying to call.
> >>
> >> I'm not sure how clear my explanation is :S
> >
> > That explanation is fine :) And you are stressing the right point: the
> > caller should be able to put down the phone after pressing "5".
> > RetryDial does not seem to allow that. Perhaps it could be done in "h"
> > with a DeadAGI but I have no idea how to do that. Suggestion &  
> > examples
> > most welcome.
> >
> > Regards,
> > Patrick
> 
> More appropriate may be a jump on BUSY, else the action may be  
> processed when not required i.e. after a successful call.
> 
> [macro-stdext]
> exten => s,1,NoOp
> exten => s,n,Dial(SIP/${ARG2},20)
> exten => s,n,Goto(s-${DIALSTATUS},1)
> 
> exten => s-BUSY,1,  <--- DO STUFF HERE :)
> ; - Playback "The person is busy, press 1 to have them call you back  
> when available or 2 to leave them a voicemail"
> ; - Add code to catch 1 or 2 as appropriate and send to voicemail or  
> script to check channel status and handle call back.
> 
> 
> exten => s-NOANSWER,1,Macro(voicemail,U${ARG3})
> exten => s-NOANSWER,n,Hangup
> 
> exten => _s-.,1,Goto(s-NOANSWER,1)

Thanks for the pointer Nathan. I slapped something together quick 'n
dirty but this is not working. The problem is that the call file is only
generated when the originating caller stays on the phone until the
remote caller hangs up. Suggestions how to fix this much appreciated.

************************************************************************
extensions.conf (ARB = Automatic Ring Back)
************************************************************************

exten => 35003,1,Set(ARBFROMEXT=${CALLERIDNUM})
exten => 35003,n,Set(ARBFROMCHAN=${CUT(CHANNEL|-|1)})
exten => 35003,n,Set(ARBTOEXT=${EXTEN})
exten => 35003,n,NoOP(ARBFROMEXT  IS ${ARBFROMEXT})
exten => 35003,n,NoOP(ARBFROMCHAN IS ${ARBFROMCHAN})
exten => 35003,n,NoOP(ARBTOEXT    IS ${ARBTOEXT})
exten => 35003,n,Dial(ZAP/3/,15,tT)
exten => 35003,n,Goto(s-${DIALSTATUS},1)
exten => s-NOANSWER,1,Congestion
exten => s-BUSY,1,Answer
exten => s-BUSY,n,Wait(1)
exten => s-BUSY,n,Background(extension)
exten => s-BUSY,n,SayNumber(${ARBTOEXT})
exten => s-BUSY,n,Background(is-curntly-busy)
exten => s-BUSY,n,Background(press-5)
exten => s-BUSY,n,Background(or)
exten => s-BUSY,n,Background(hangup-try-again)
exten => s-BUSY,n,WaitExten(5)
exten => 5,1,DBput(ARB/${CALLERIDNUM}=ON)
exten => 5,n,Hangup
exten => t,1,Hangup
exten => i,1,Hangup
exten => h,1,DBGet(temp=ARB/${CALLERIDNUM})
exten => h,n,GotoIf($[${DBGETSTATUS} = FOUND]?found:bail)
exten => h,n(found),NoOP(h: ARB IS ON FOR ${CALLERIDNUM})
exten => h,n,DBdel(ARB/${CALLERIDNUM})
exten => h,n,Wait(5)
exten => h,n(check),ChanIsAvail(ZAP/3,s)
exten => h,n,NoOP(AVAILCHAN     IS ${AVAILCHAN})
exten => h,n,NoOP(AVAILORIGCHAN IS ${AVAILORIGCHAN})
exten => h,n,NoOP(AVAILSTATUS   IS ${AVAILSTATUS})
exten => h,n,GotoIf($[${AVAILSTATUS} = 2]?busy:callit)
exten => h,n(busy),Wait(5)
exten => h,n,Goto(check)
exten => h,n(callit),NoOP(h: ${ARBTOEXT} IS FREE. START AGI)
exten => h,n,DeadAGI(arb.agi,${ARBFROMEXT}|${ARBFROMCHAN}|${ARBTOEXT})
exten => h,n(bail),Hangup

*************************************************************************
arb.agi - using the "automatic ring back" name for this feature
*************************************************************************

#!/usr/bin/php -q
<?php
ob_implicit_flush(true);
set_time_limit(6);
//$err=fopen("php://stderr","w");
$in = fopen("php://stdin","r");
$stdlog = fopen("/var/log/asterisk/my_agi.log", "w");

function read() {
        global $in, $debug;
        $input = str_replace("\n", "", fgets($in, 4096));
        return $input;
}

function errlog($line) {
        global $err;
        echo "VERBOSE \"$line\"\n";
}

function write($line) {
        global $debug;
        echo $line."\n";
}
// parse agi headers into array
while ($env=read()) {
        $env = str_replace("\"","",$env);
        $s = split(": ",$env);
        $agi[str_replace("agi_","",$s[0])] = trim($s[1]);
                if (($env == "") || ($env == "\n")) {
                break;
        }
}

// parse the ARB variables
$arbfromext = $argv[1];
$arbfromchan = $argv[2];
$arbtoext = $argv[3];

// watch the linewrap below. Should be one line!
errlog("ARB originating ".$arbfromext." & channel ".$arbfromchan." to
".$arbtoext.".\n");
// watch the linewrap below. Should be one line!
$cf =
fopen("/var/spool/asterisk/outgoing/arb-from-".$arbfromext."-to-".$arbtoext,"w+");
fputs($cf,"Channel: ".$arbfromchan."\n");
fputs($cf,"MaxRetries: 1\n");
fputs($cf,"RetryTime: 10\n");
fputs($cf,"Context: ".$agi["context"]."\n");
fputs($cf,"Extension: ".$arbtoext."\n");

fclose($cf);
fclose($in);
fclose($stdlog);
exit;
?>

Regards,
Patrick



More information about the asterisk-users mailing list