[asterisk-users] Roaming callback?
Gerald Harshany
ger at jerryh.us
Tue Apr 29 00:43:24 CDT 2008
Hi Jaap,
Here is a portion of my coding. Hope I didn't 'break' anything in moving
sections around.
I tried to leave only what is material to answering your question.
One caveat - I did add the CALL FILE functionality on my V1.6.0 (branch
SVN)
asterisk box; so, maybe they changed some 'underlying' code that would be
different from V1.4.x. But, go ahead and try it. The obvious syntax change
I've noted in the comments below.
[voicepulse-in]; this is an incoming PSTN call from the VOIP provider
; VoicePulse Connect, which from their servers
; in either SIP or IAX protocol.
; .........................................................
; This section catches calls coming in through VoicePulse.
; The EXTEN here is only of interest if I subscribe to multiple
; PSTN-SIP/IAX lines from VoicePulse CONNECT.
; .........................................................
exten => _XX.,1,Set(GLOBAL(VP_CALLERIDNUM)=${CALLERID(num)})
exten => _XX.,n,Set(GLOBAL(VP_CALLERIDNAME)=${CALLERID(name)})
exten => _XX.,n,Set(GLOBAL(VP_TRUNKINNUM)=${EXTEN})
exten => _XX.,n,Set(ALLOWJERRY_ALL=2)
. ; all I do here is verify that I have a known/approved user dialing in
. ; or invalid user
.
exten => _XX.,n,Log(
NOTICE|CALLINLOG vp-in id=${CALLERID(num)} nam=${CALLERID(name)})
exten => _XX.,n(dobckgrd),NoOp()
exten => _XX.,n,GoTo(process-digit-vpin,s,1)
[process-digit-vpin]
; prompt and wait for digits to be entered
exten => s,1,Answer()
exten => s,n,Macro(sayhi,${CALLERID(num)})
exten => s,n,Background(pls-entr-num-uwish2-call,m)
exten => s,n,WaitExten()
;check if we are making a local call
;
exten => *,1,Playback(star)
.
. ; set up for calls to local phone extensions
.
exten => *,n,GoTo(call-local,s,1)
;check for long distance & INTERNAT call-US-canada
;users always enter 10digit number for ld
;
exten => _NXXNXXXXXX,1,NoOp()
exten => _NXXNXXXXXX,n,Set(newnumber=${EXTEN})
.
. ; just some housekeeping
.
;exten => _NXXNXXXXXX,n,GoTo(dial-long-dist)
exten => _0X.,1,NoOp()
.
. ; just some housekeeping
.
exten => _0X.,n,GoTo(call-asia,s,1)
; RINGBACK SECTION-
;
exten => _1*,1,NoOp() ; this is local call with ringback
.
.
exten => _1NXXNXXXXXX,1,NoOp() ; this is Long Distance call with ringback
exten => _1NXXNXXXXXX,n,Set(GLOBAL(CallERringbackID)=${CALLERID(num)})
exten => _1NXXNXXXXXX,n,Set(GLOBAL(CallERringbackNAME)=${CALLERID(name)})
; the next variable is the number to call
exten => _1NXXNXXXXXX,n,Set(GLOBAL(CallEEringbackID)=${EXTEN:1})
;exten => _1NXXNXXXXXX,n,Playback(jp-hup-and-will-call-back-10sec)
;exten => _1NXXNXXXXXX,n,Wait(2)
exten => _1NXXNXXXXXX,n,GoTo(process-ringbacknum,s,1)
exten => _10X.*,1,NoOp() ; this is International call with ringback
.
.
exten => i,1,Playback(vm-goodbye)
exten => i,n,Hangup()
exten => t,1,Playback(connection-timed-out)
exten => t,n,Hangup()
; FOR RINGBACK- CallerID=CallERringbackID- CalleeID=CallEEringbackID
;
[process-ringbacknum]
exten => s,1,Verbose(SSS- entered context process-ringbacknum)
; get a NEW UNIQUE path+file name, such as "/tmp/ringback17.call"
;
exten => s,n,Macro(AdvCallFileNum)
exten => s,n,Set(_CurCallfileName=${GLOBAL(CUR_CALLFILE_NAME)})
; NOTE-need to find out where caller is, and where he wants to call
; as some outgoing lines are cheaper for international calls
; also, determine if channels are available, etc.
;
.
. ; logic for accomplishing the above NOTE - is site-dependent
.
. ; NOTE-2- the follow exten is my 'development' call with 'constants',
. ; so you will want to use variables for the paramters
. ; Also, believe GOSUB with parameters was new in asterisk V1.6.0,
. ; so, in an earlier version you can easily make the adjustment
.
exten => s,n,GoSub(write-callfile,s,1("Zap/3/1407474xxxx","20","1","1",
"doringback","s","1","Jerry 4074747xxxx","DialNumber=407474xxxx",
"whatever documentation for write callfile",${CurCallfileName}))
exten => s,n,Hangup() ;done with setup, so hangup the caller
[write-callfile] ; GOSUB for writing a CALL FILE
;you may wish to check return status from the system calls
;
exten => s,1,Verbose(WCWC-reached context write-callfile)
exten => s,n,Set(FromPathFile=${ARG11})
exten => s,n,TrySystem(echo "Channel: ${ARG1} \n" > ${FromPathFile})
exten => s,n,TrySystem(echo "WaitTime: ${ARG2} \n" >> ${FromPathFile})
exten => s,n,TrySystem(echo "RetryTime: ${ARG3} \n" >> ${FromPathFile})
exten => s,n,TrySystem(echo "MaxRetries: ${ARG4} \n" >> ${FromPathFile})
exten => s,n,TrySystem(echo "Context: ${ARG5} \n" >> ${FromPathFile})
exten => s,n,TrySystem(echo "Extension: ${ARG6} \n" >> ${FromPathFile})
exten => s,n,TrySystem(echo "Priority: ${ARG7} \n" >> ${FromPathFile})
exten => s,n,TrySystem(echo "CallerID: ${ARG8} \n" >> ${FromPathFile})
exten => s,n,TrySystem(echo "SetVar: ${ARG9} \n" >> ${FromPathFile})
exten => s,n,TrySystem(echo "Account: ${ARG10} \n" >> ${FromPathFile})
exten => s,n,Set(DestPathFile=${FromPathFile})
exten => s,n,Set(DestPathFile=${CALLFILE_PATH}${DestPathFile:4})
exten => s,n,System(nohup "${AGI_BIN_PATH}"/agi-exec-bckgd-for-move.sh
"${FromPathFile}" "${DestPathFile}" 1>/dev/null 2>&1 &);one long line
exten => s,n,Return()
[doringback] ; in a NEW CHANNEL NOW-the call-file created channel Zap/3
exten => s,1,Verbose(== in context doringback ready to dial ring back
caller)
; THE Zap/2 CALL WILL OCCUR (USUALLY) BEFORE THE CALL-FILE CALL
;
exten => s,n,Dial(Zap/2,20,r)
; check DIALSTATUS etc
exten => s,n,Hangup()
Hope this helps,
Gerald Harshany
>> -------- Original Message --------
>> Subject: [SPAM] Re: [asterisk-users] Roaming callback?
>> From: SIP <sip at arcdiv.com>
>> Date: Mon, April 28, 2008 1:25 pm
>> To: Asterisk Users Mailing List - Non-Commercial Discussion
>> <asterisk-users at lists.digium.com>
>> Cc: Jerry Harshany <ger at JerryH.us>
>> Jaap Winius wrote:
>> > Quoting Jerry Harshany <ger at JerryH.us>:
>> >
>> >
>> >> There is an additional alternative for a ringback to a caller, which
>> >> is to use the Call File capability as noted in Van Meggelen's
>> >> "Future of Telephone"; 2nd ed, p306.
>> >>
>> >
>> > As it says in the book, call files allow calls to be created through
>> > the Linux shell. If you've used this to create a roaming callback
>> > service, then you must have created something that allows users to
>> > submit a phone number to be called back on, after which a .call file
>> > is created and moved to the /var/spool/asterisk/outgoing/ directory.
>> >
>> >
>> >> sleep 8s
>> >> mv "$1" "$2"
>> >> exit 0
>> >>
>> >
>> > This looks like the step that moves the newly created call file to the
>> > aforementioned directory.
>> >
>> >
>> >> In my case, when the caller calls in to 'asterisk', he is prompted
>> >> for the number he wishes to call. The caller can be at a US or
>> >> international number, and he can call any US or international
>> >> number, WITH or WITHOUT ringback. In other words the caller
>> >> designates whether this is a direct connect call, or a ringback (and
>> >> then bridge the called number). I have the complete flexibility of
>> >> my dial plan extensions to do as I wish with the phone numbers.
>> >>
>> >
>> > This is what I'm really interested in! How did you manage this? Would
>> > you be willing to share how you did this?
>> >
>> >
>> I would imagine if it's a callback, it creates a callfile. If it's not,
>> it just connects the call as it would normally. We have a similar thing
>> for our business customers built using a reasonably simple agi script to
>> do verification of the caller/account and creation of the call files. A
>> rather simple Dial command can handle the direct connection after
>> verification, and a rather simple call file can handle the callback. The
>> hardest part was getting the DTMF reading to work well. ;)
>> N.
More information about the asterisk-users
mailing list