[asterisk-users] Callback on busy

Michele Pinassi michele.pinassi at unisi.it
Fri Jan 27 08:30:48 CST 2017

Hi all,

i'm using Asterisk as a media box for a VoIP network based on OpenSIPS.
When an user phone is busy, call was forwarded to an asterisk ext:

; ===========================================
; Voicemail on NOT AVAILABLE
; ===========================================
exten => _VMR_.,1,Noop("from-voip: ${CALLERID(num)} ${EXTEN}")
exten => _VMR_.,n,Set(DID=${EXTEN:4})
exten => _VMR_.,n,Answer()
exten => _VMR_.,n,Wait(1)
exten => _VMR_.,n,GotoIf(${VM_INFO(${DID},exists)}?avail:unavail)
exten => _VMR_.,n(avail),Voicemail(${DID},u)
exten => _VMR_.,n,Hangup()
exten => _VMR_.,n(unavail),Playback(vm-theperson)
exten => _VMR_.,n,SayDigits(${DID});
exten => _VMR_.,n,Playback(vm-isunavail)
exten => _VMR_.,n,Read(digit,vm-tocallback,1,,1,5)
exten => _VMR_.,n,Gotoif($["${digit}" = "2"]?:skip,1,5)
exten => _VMR_.,n,Noop("Add callback for ${DID} from ${CALLERID(num)}")
exten => _VMR_.,n,AGI(callback,${DID},${CALLERID(num)})
exten => _VMR_.,n,Playback(goodbye)
exten => _VMR_.(skip),n,Hangup()

when a vocal message asks to press "2" to add a callback when called
users return free, using an AGI script that create a .call file:

#!/usr/bin/php -q


$called = $argv[1];
$caller = $argv[2];

$cf =
fputs($cf,"Channel: LOCAL/CB_$called\n");
fputs($cf,"Context: default\n");
fputs($cf,"Extension: $caller\n");
fputs($cf,"CallerID: CallBack $caller <$caller>\n");
fputs($cf,"MaxRetries: 100\n");
fputs($cf,"RetryTime: 30\n");
fputs($cf,"Archive: Yes\n");
fputs($cf,"SetVar: CALLER=$caller\n");
fputs($cf,"SetVar: CALLED=$called\n");


periodically, Asterisk try to call CALLED user using CB_ routine:

; ===========================================
; Callback
; ===========================================
exten => _CB_.,1,Set(FROM=${CALLER})
exten => _CB_.,n,Set(TO=${CALLED})
exten => _CB_.,n,Noop("callback: from ${FROM} to ${TO}")
exten => _CB_.,n,Set(CALLERID(all)="CB ${FROM} <${FROM}>")
exten => _CB_.,n,Dial(SIP/voip-trunk/${TO},10) ; Check if called is
available and, if answer, transfer to caller (TODO)...
exten => _CB_.,n,Hangup()

But, as you can see, Callback routine wasn't done because i'm unable to
figure out how i can do that. I need that Asterisk call CALLED user and,
when answered, start calling CALLER.

It's possibile ?

Thanks, Michele

Michele Pinassi

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20170127/d4db219b/attachment.pgp>

More information about the asterisk-users mailing list