Asterisk power hunt

I have designed a script to allow you to define a fairly flexible hunt groups, with up to 10 stages, it will allow you to keep phones ringing at each stage of the hunt group and not show an extrordinary number of missed calls. This may be extended in future to handle busy extensions better etc and maybe give better feedback, leave a comment if you have any suggestions.

It's a recursive dialplan script that spawns a lot of threads, but thus may break your system in a nasty infinite loop, so be careful testing it.

The example settings below, ring SIP/100 immediately for up to sixty seconds, if after 10 seconds it has not been answered, SIP101 will ring in addition for up to 20 seconds, if after 15 seconds (from the beginning, or 5 seconds after SIP/101 has started ringing) there has still been no answer SIP102 will begin to ring. After a minute the call should be forwarded to an extension that can handle voicemail for reception..

Have fun,
Mark Bryars

exten => 123,1,Macro(hunt,0,reception);
exten => 123,2,Congestion

exten => _0.,1,Macro(hunt,0,${EXTEN:4});

exten => _1.,1,Macro(hunt,${EXTEN:1:1},${EXTEN:2});
exten => _1.,2,Congestion

exten => _2.,1,Macro(huntcall,${EXTEN:1:1},${EXTEN:2});
exten => _2.,2,Congestion

exten => s,1,Noop(Hunt ${ARG2} lev ${ARG1});
exten => s,n,GotoIf($[${ISNULL(${ARG1})} | ${ISNULL(${ARG2})}]?200);
exten => s,n,GotoIf($[${ISNULL(${DB(hunt/${ARG2}/${ARG1}/device)})}]?200); no more
exten => s,n,Dial(Local/2${ARG1}${ARG2}@hunt&Local/1$[${ARG1} + 1]${ARG2}@hunt);
exten => s,n,MacroExit

exten => s,200,NoOp([macro-hunt] Reached End or Error: ARG1:"${ARG1}" ARG2:"${ARG2}" WAITTIME:"${DB(hunt/${ARG2}/${ARG1}/waittime)}" RINGTIME:"${DB(hunt/${ARG2}/${ARG1}/ringtime)}" DEVICE:"${DB(hunt/${ARG2}/${ARG1}/device)}")
exten => s,201,MacroExit

exten => s,1,Wait(${DB(hunt/${ARG2}/${ARG1}/waittime)})
; I use this for group control things - exten => s,n,Set(OUTBOUND_GROUP=${DB(hunt/${ARG2}/${ARG1}/group)})
exten => s,n,Dial(${DB(hunt/${ARG2}/${ARG1}/device)},${DB(hunt/${ARG2}/${ARG1}/ringtime)})
exten => s,n,MacroExit

database put hunt reception/0/waittime 0
database put hunt reception/0/ringtime 60
database put hunt reception/0/device SIP/100

database put hunt reception/1/waittime 10
database put hunt reception/1/ringtime 20
database put hunt reception/1/device SIP/101

database put hunt reception/2/waittime 15
database put hunt reception/2/ringtime 20
database put hunt reception/2/device SIP/102

database put hunt reception/3/waittime 60
database put hunt reception/3/ringtime 5
database put hunt reception/3/device Local/voicemailexten

Created by: darkskiez, Last modification: Fri 02 of Feb, 2007 (09:08 UTC)
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+