Upgrade 3CX to v18 and get it hosted free!

Asterisk power hunt

Author image

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

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

[hunt]
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

[macro-hunt]
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

[macro-huntcall]
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


Article Reviews

Write a Review

Your email address will not be published. Required fields are marked *

Required Field. Minimum 5 characters.

Required Field. Minimum 5 characters, maximum 50.

Required field.There is an error with this field.

Required Field.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

There are no reviews for this article. Be the first one to write a review.
Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.