[asterisk-users] Callback/ringback

Yehavi Bourvine +972-8-9489444 YEHAVI at VMS.HUJI.AC.IL
Wed Jan 17 22:40:00 MST 2007


Enclosed bellow is the fragment from extenstions.conf which does two things:

*41 - Does the ring-back staff.
*42 - Calls back the last one who called you.

                           Regards, __Yehavi:

; regular local extensions:
; The flow is: If not available or no answer send to mailbox if exists,
; send busy if no mailbox. Same for busy.
; We try to avoid the n+101 rule whenever possible, but it is not always
; possible as HasVoiceMailbox() does only n+101 jump.
exten => _999XX,1,Set(_To=${EXTEN})	; Save the original extension dialled.
exten => _999XX,n,Set(_From=${CALLERID(num)}) ; Save the caller.

; Save the caller number at the called extension for *42 usage.
exten => _999XX,n,Set(DB(${To}/LastCaller)=${From})
; Where we called for *41
exten => _999XX,n,Set(DB(${From}/LastCalled)=${To})

; Now dial the extension.
exten => _999XX,n,Dial(SIP/${EXTEN},20,)   ; Dial the phone for 20 seconds.
; No answer or busy
exten => _999XX,n,GoTo(s-${DIALSTATUS},1)	; Jump according to the failure mode
exten => _999XX,n,Hangup()		; Just to be sure...

; No answer:
exten => s-NOANSWER,1,MailboxExists(${To}|j); Has a mailbox?
exten => s-NOANSWER,n,Busy()		; No maibox = play busy.
exten => s-NOANSWER,102,VoiceMail(u${To}) ; Has mailbox - send the call to there

; Busy:
exten => s-BUSY,1,MailboxExists(${To}|j); Has a mailbox?
exten => s-BUSY,n,Busy()		; No maibox = play busy.
exten => s-BUSY,102,VoiceMail(b${To}) ; Has mailbox - send the call to there

; Unavailable channel - act as busy:
exten => s-CHANUNAVAIL,1,Goto(s-BUSY,1);


; Called here when the call is successfull and the user hanged the phone.
; Check whether the user has a waiting callback queued on him/her
exten => h,1,NoOp(${From} ${To} ${EXTEN})
exten => h,2,Set(tmp=${DB(${From}/CallBack)}) ; Get who is waiting for us
exten => h,3,NoOp(${From} ${tmp})
exten => h,4,GotoIf($[ ${tmp}  ]?5:103)	; Anyone waiting for us?
exten => h,5,DBdel(${From}/CallBack)	; And delete it...
; Create the callfile and then move it to the spool directory to make the call.
exten => h,6,System(echo Channel:  SIP/${tmp} > /tmp/test.tmp${To})
exten => h,7,System(echo WaitTime: 20 >> /tmp/test.tmp${To})
exten => h,8,System(echo Extension: ${From} >> /tmp/test.tmp${To})
exten => h,9,System(echo CallerID: Callback \\\<${tmp}\\\> >> /tmp/test.tmp${To})
exten => h,10,System(mv /tmp/test.tmp${To} /var/spool/asterisk/outgoing/)

exten => h,103,NoOp(Nothing to call)

; *42: Get the last number who called us, say it and call it.
exten => *42,1,Set(tmp=${DB(${CALLERID(num)}/LastCaller})
exten => *42,n,SayDigits(${tmp})
exten => *42,n,Goto(${tmp},1)

; *41: Camp on the last extension dialled
exten => *41,1,Set(tmp=${DB(${CALLERID(num)}/LastCalled)})
exten => *41,n,SayDigits(${tmp})
; Save it so when the other side hangs it will see it and dial us.
exten => *41,n,Set(DB(${tmp}/CallBack)=${CALLERID(num)})
exten => *41,n,Hangup()



More information about the asterisk-users mailing list