[Asterisk-Users] A solution to "free line" notification

Barton Hodges barton at localhost.gcmcomputers.com
Wed Dec 10 22:52:43 MST 2003


Barton Hodges wrote:
> I've been messing around with a "free line" notification
> where an extension is dialed for a second when a line becomes
> available.  I can't seem to get the "h" extension to continue
> when the local party hangs up.  I've seen references to other
> people having the same problem in the list archives, and the
> solution presented was to use AGI.

I finally figured out how to get this to work.  Thanks to one of Steven
Critchfield's emails today, I found out about sample.call and
/var/spool/asterisk/outgoing which is what I needed to control the
dialing.  It seems that if you call a macro from within an "h"
extension, only one, or a few select lines get called before the macro
returns.  I messed around with different alternatives until I found one
that worked.  I would give anything for control structures and
user-defined functions within the dialplan.  A nice little for() loop
would tidy things up nicely.  Is AGI what I need to be using?  I wasn't
sure how to do things such as Dbget(), except through the Exec() call.

Here are snippits to show how it was done:

/var/lib/asterisk/agi-bin/fln.agi:

#!/bin/sh
[ $# -gt 0 ] || exit 0;
echo -e "Channel: ${1}
WaitTime: 1
Callerid: Free Line Notification <(000) 000-0000>
Context: default
Extension: s
Priority: 1" > /var/spool/asterisk/outgoing/fln.$$


/etc/asterisk/extensions.conf:

[from-inside]
include => to-internal
include => app-freeline
exten => h,1,Macro(hangup)

[check-fln]
exten => s,1,DBget(TECH=FLN/${EXT})
exten => s,2,ChanIsAvail(Zap/1&Zap/2&Zap/3&Zap/4) 
exten => s,3,DBdel(FLN/${EXT})
exten => s,4,AGI(fln.agi,${TECH}/${EXT})
exten => s,5,Goto(macro-hangup,s,${PRI})
exten => s,102,Goto(macro-hangup,s,${PRI})
exten => s,103,Goto(macro-hangup,s,${PRI})
exten => s,104,Goto(macro-hangup,s,${PRI})

[macro-hangup]
exten => s,1,SetVar(PRI=4)
exten => s,2,SetVar(EXT=111)
exten => s,3,Goto(check-fln,s,1)
exten => s,4,SetVar(PRI=7)
exten => s,5,SetVar(EXT=112)
exten => s,6,Goto(check-fln,s,1)
exten => s,7,SetVar(PRI=10)
exten => s,8,SetVar(EXT=113)
exten => s,9,Goto(check-fln,s,1)
exten => s,10,Wait(1)
exten => s,11,Hangup

[macro-goodbye-hangup]
exten => s,1,Playback(vm-goodbye) 
exten => s,2,Macro(hangup)

[app-freeline]
exten => _*98,1,Cut(CHAN=CHANNEL,-,1) 
exten => _*98,2,Cut(TECH=CHAN,/,1) 
exten => _*98,3,Cut(EXT=CHAN,/,2) 
exten => _*98,4,DBput(FLN/${EXT}=${TECH})
exten => _*98,5,Answer
exten => _*98,6,Playback(contrib/activated)
exten => _*98,7,Playback(vm-for)
exten => _*98,8,Playback(vm-extension)
exten => _*98,9,SayDigits,${CALLERIDNUM}
exten => _*98,10,Macro(goodbye-hangup)
exten => _*99,1,Cut(CHAN=CHANNEL,-,1) 
exten => _*99,2,Cut(EXT=CHAN,/,2) 
exten => _*99,3,DBdel(FLN/${EXT})
exten => _*99,4,Answer
exten => _*99,5,Playback(contrib/de-activated)
exten => _*99,6,Playback(vm-for)
exten => _*99,7,Playback(vm-extension)
exten => _*99,8,SayDigits,${CALLERIDNUM}
exten => _*99,9,Macro(goodbye-hangup)





More information about the asterisk-users mailing list