Asterisk tips campon

Campon


Repeatedly retry a busy extension after 30 sec with music-on-hold in between until that extension answers. See also bug 509 for the basic idea behind this.

exten => 765,1,SetVar(CALLEDEXTEN=${EXTEN})
exten => 765,2,Dial(SIP/20,20,m)
exten => 765,3,Goto(campon,camp,1)
exten => 765,103,Goto(campon,camp,1)

[campon]
exten => camp,1,Answer
exten => camp,2,Wait(1)
exten => camp,3,Background(campon)
exten => camp,4,Background(silence/3)
exten => camp,5,WaitMusicOnHold(30)
exten => camp,6,Goto(default,${CALLEDEXTEN},1)

exten => 1,1,Wait(1)
exten => 1,2,VoiceMail(b${CALLEDEXTEN})
exten => 1,3,Hangup

Campon V2


This is a little more involved mini queue, the motivation behind this, is two fold:

1.) Small busy office where people aren’t disciplined to login/out of their phones, and one primary person to answer all calls unless they are not near their phone.
2.) After hunting 2 (or more, you can extend it) ext it will pass the call off to cell phones. In this case the call isn’t bridged to the cell unless the user acknowledges the call this prevents calls going to two voicemail systems.

When a call comes in it will be passed to the first ext, if the ext isn’t around/doesn’t answer then it will go to the next ext, in this case the first “ext� is actually two simultaneous exts. If the first one is on another call, then the caller will camp on it until the line is free. For instance if you have a receptionist then she will get all calls if she is in the office, if not then they will passed to the next person.

Of course this will only work if you correctly set the group for outgoing calls as well.

exten => s,1,Macro(superqueue,${BOB}&${BOBLAP},${CRYSTAL},${BOBCELL},${CRYSTALCELL})

[macro-superqueue]
exten => s,1,Background(please-hold-connect) ; Please hold while we connect your call.
exten => s,2,Set(ROUTEBACK=5)
exten => s,3,Set(HOLDTIME=30) ; Set the first hold time to 30 seconds.
exten => s,4,Set(GROUP()=${ARG1}) ; Set the call group to the first ext being dialed.
exten => s,5,Set(GROUPNAME=${ARG1})
exten => s,6,Set(GROUPCOUNT=${GROUP_COUNT(${ARG1})}) ; Set the group count for that extension.
exten => s,7,GotoIf($[${GROUPCOUNT} > 1]?camp,1) ; If the ext is already in use then go to the camp routine.
exten => s,8,Dial(${ARG1},20,m) ; If not then dial the first ext.
exten => s,9,Set(ROUTEBACK=10)
exten => s,10,Set(GROUP()=${ARG2}) ; If no answer then do the same for the second ext.
exten => s,11,Set(GROUPNAME=${ARG2})
exten => s,12,Set(GROUPCOUNT=${GROUP_COUNT(${ARG2})})
exten => s,13,GotoIf($[${GROUPCOUNT} > 1]?camp,1) ; If this ext is in use then campon it.
exten => s,14,Dial(${ARG3}|40|mgM(screen),m) ; Call the first cell phone with the screen macro, only bridge the call if the cell accepts.
exten => s,15,Dial(${ARG4}|40|mgM(screen),m) ; Call next cell, same thing
exten => s,16,Voicemail(u2000) ; If unavailable, send to voicemail w/ unavail announce
exten => a,1,VoicemailMain(2000) ; If they press *, send the user into VoicemailMain
exten => camp,1,Wait(1)
exten => camp,2,Set(WAITTIME = 0)
exten => camp,3,Background(campon) ; Thankyou for your patience, if you would like to leave a voicemessage press *, otherwise the next avalible person will assist you.
exten => camp,4,Background(silence/3) ; Wait for some input
exten => camp,5,WaitMusicOnHold(1) ; Wait on hold for some time
exten => camp,6,Set(WAITTIME=[$WAITTIME + 1])
exten => camp,7,Set(GROUPCOUNT=${GROUP_COUNT(${GROUPNAME})}) ; Recheck groupcount
exten => camp,8,GotoIf($[${GROUPCOUNT} < 2 1]?s,7) ; If the line is free go there
exten => camp,9,GotoIf($[${WAITTIME}< ${HOLDTIME}]?camp,5:camp,10) ; After HOLDTIME then cycle around again.
exten => camp,10,Set(HOLDTIME=200) ; Since we only want them waiting around for 30 secs the first time before we ask them if they still want to wait, after that they will get 200 seconds of music
exten => camp,11,Goto(s,${ROUTEBACK}) ; Go back to the camped ext and start all over

[macro-screen]
exten => s,1,Wait(0.2) ; Wait just a giffy
exten => s,2,Playback(you-have-incoming) ; Tell ext that they have an imcoming call, and press 1 to accept the call 2 to reject it.
exten => s,3,Read(ACCEPT|screen-callee|1) ; Check to see if they press 1
exten => s,4,GotoIf($[${ACCEPT} = 1 ]?7:6) ; If they press 1 then bridge the call with a tiny wait.
exten => s,6,SetVar(MACRO_RESULT=CONTINUE) ; If they didn't press 1 then keep on trying
exten => s,7,Wait(0.1) ; just wait a giffy

Campon for busy outgoing.


Automatic redial
From Cyber-cottage.co.uk
Otherwise known as campon.

It can be usefull sometimes to have number redialed till free, As can be done by a "mobile phone".

To this end I have created a simple addition to the dial plan to do this and play the correct tones when a call fails with a reason, This works with SIP IAX and ISDN trunks.

This is a new conf file called timeout.conf

;This file controls the action on timeout and invalid call handling
;
;
[timeout]
exten => s,1,Goto(s-${DIALSTATUS},1)  ; This gets the dial status
;
exten => s-NOANSWER,1,Playtones(congestion)
exten => s-NOANSWER,n,wait(10)
exten => s-NOANSWER,n,Hangup()
; 
exten => s-CHANUNAVAIL,1,Playtones(unobtainable)
exten => s-CHANUNAVAIL,n,wait(10)
exten => s-CHANUNAVAIL,n,Hangup()
; 
; If a destination is busy the call may press 5 and the call will be  queued
exten => s-BUSY,1,Playtones(busy)
exten => s-BUSY,n,Set(TIMEOUT(digit)=1)
;exten => s-BUSY,n,Set(TIMEOUT(response)=5)
exten => s-BUSY,n,WaitExten(5)
exten => s-BUSY,n,Set(redialtime=30)
exten => s-BUSY,n,Goto(s-CAMPON,1) ; If users press 5 the call is  requeuded
exten => s-BUSY,n,Hangup()
; 
exten => s-CAMPON,1,NooP(${redial})   ;This is the number dialed
exten => s-CAMPON,n,NooP(${cont})     ;This is the Context of the call
exten => s-CAMPON,n,NooP(${redialtime})
exten => s-CAMPON,n,waitmusiconhold(${redialtime})
exten => s-CAMPON,n,Dial(Local/${redial}@${cont})
;
exten => s-CONGESTION,1,Playtones(congestion)
exten => s-CONGESTION,n,wait(10)
exten => s-CONGESTION,n,Hangup()
;
exten => 5,1,Noop(${EXTEN}
exten => 5,n,Set(redialtime=15)
exten => 5,n,Goto(s-CAMPON,1) ; If users press 5 the call is requeuded
;
exten => _5.,1,Noop(${EXTEN}
exten => _5.,n,Set(redialtime=${MATH(0${EXTEN:1}+10)})
exten => _5.,n,Goto(s-CAMPON,1) ; If users press 5 the call is  requeuded
;
exten => i,1,Playtones(switching)
exten => i,n,wait(10)
exten => i,n,Hangup()
;
exten => t,1,Playtones(switching)
exten => t,n,wait(10)
exten => t,n,Hangup()

It is called from the extensions.conf in the following manner.

;Long distance context accessed through trunk
exten => _90~np~[1-2]~/np~XXXXXXXXX,1,Dial(${TRUNK1}/${EXTEN:${TRUNKMSD}})
exten => _90~np~[1-2]~/np~XXXXXXXXX,n,set(redial=${EXTEN})
exten => _90~np~[1-2]~/np~XXXXXXXXX,n,set(cont=${CONTEXT})
exten => _90~np~[1-2]~/np~XXXXXXXXX,n,Goto(timeout,s,1)


So you now dial out as normal and if you get busy tone you can either hold on and it will redial every 30 seconds or press 5 and it will redial every 15 seconds or press 5xx where xx is any number of seconds from 1 upwards and will redial 10seconds plus the number of seconds.

What will then happen is you will sit back and listen to MOH and it will redial at the defined time and you can wait or press 5 etc


See also



Go back to Asterisk tips and tricks

Campon


Repeatedly retry a busy extension after 30 sec with music-on-hold in between until that extension answers. See also bug 509 for the basic idea behind this.

exten => 765,1,SetVar(CALLEDEXTEN=${EXTEN})
exten => 765,2,Dial(SIP/20,20,m)
exten => 765,3,Goto(campon,camp,1)
exten => 765,103,Goto(campon,camp,1)

[campon]
exten => camp,1,Answer
exten => camp,2,Wait(1)
exten => camp,3,Background(campon)
exten => camp,4,Background(silence/3)
exten => camp,5,WaitMusicOnHold(30)
exten => camp,6,Goto(default,${CALLEDEXTEN},1)

exten => 1,1,Wait(1)
exten => 1,2,VoiceMail(b${CALLEDEXTEN})
exten => 1,3,Hangup

Campon V2


This is a little more involved mini queue, the motivation behind this, is two fold:

1.) Small busy office where people aren’t disciplined to login/out of their phones, and one primary person to answer all calls unless they are not near their phone.
2.) After hunting 2 (or more, you can extend it) ext it will pass the call off to cell phones. In this case the call isn’t bridged to the cell unless the user acknowledges the call this prevents calls going to two voicemail systems.

When a call comes in it will be passed to the first ext, if the ext isn’t around/doesn’t answer then it will go to the next ext, in this case the first “ext� is actually two simultaneous exts. If the first one is on another call, then the caller will camp on it until the line is free. For instance if you have a receptionist then she will get all calls if she is in the office, if not then they will passed to the next person.

Of course this will only work if you correctly set the group for outgoing calls as well.

exten => s,1,Macro(superqueue,${BOB}&${BOBLAP},${CRYSTAL},${BOBCELL},${CRYSTALCELL})

[macro-superqueue]
exten => s,1,Background(please-hold-connect) ; Please hold while we connect your call.
exten => s,2,Set(ROUTEBACK=5)
exten => s,3,Set(HOLDTIME=30) ; Set the first hold time to 30 seconds.
exten => s,4,Set(GROUP()=${ARG1}) ; Set the call group to the first ext being dialed.
exten => s,5,Set(GROUPNAME=${ARG1})
exten => s,6,Set(GROUPCOUNT=${GROUP_COUNT(${ARG1})}) ; Set the group count for that extension.
exten => s,7,GotoIf($[${GROUPCOUNT} > 1]?camp,1) ; If the ext is already in use then go to the camp routine.
exten => s,8,Dial(${ARG1},20,m) ; If not then dial the first ext.
exten => s,9,Set(ROUTEBACK=10)
exten => s,10,Set(GROUP()=${ARG2}) ; If no answer then do the same for the second ext.
exten => s,11,Set(GROUPNAME=${ARG2})
exten => s,12,Set(GROUPCOUNT=${GROUP_COUNT(${ARG2})})
exten => s,13,GotoIf($[${GROUPCOUNT} > 1]?camp,1) ; If this ext is in use then campon it.
exten => s,14,Dial(${ARG3}|40|mgM(screen),m) ; Call the first cell phone with the screen macro, only bridge the call if the cell accepts.
exten => s,15,Dial(${ARG4}|40|mgM(screen),m) ; Call next cell, same thing
exten => s,16,Voicemail(u2000) ; If unavailable, send to voicemail w/ unavail announce
exten => a,1,VoicemailMain(2000) ; If they press *, send the user into VoicemailMain
exten => camp,1,Wait(1)
exten => camp,2,Set(WAITTIME = 0)
exten => camp,3,Background(campon) ; Thankyou for your patience, if you would like to leave a voicemessage press *, otherwise the next avalible person will assist you.
exten => camp,4,Background(silence/3) ; Wait for some input
exten => camp,5,WaitMusicOnHold(1) ; Wait on hold for some time
exten => camp,6,Set(WAITTIME=[$WAITTIME + 1])
exten => camp,7,Set(GROUPCOUNT=${GROUP_COUNT(${GROUPNAME})}) ; Recheck groupcount
exten => camp,8,GotoIf($[${GROUPCOUNT} < 2 1]?s,7) ; If the line is free go there
exten => camp,9,GotoIf($[${WAITTIME}< ${HOLDTIME}]?camp,5:camp,10) ; After HOLDTIME then cycle around again.
exten => camp,10,Set(HOLDTIME=200) ; Since we only want them waiting around for 30 secs the first time before we ask them if they still want to wait, after that they will get 200 seconds of music
exten => camp,11,Goto(s,${ROUTEBACK}) ; Go back to the camped ext and start all over

[macro-screen]
exten => s,1,Wait(0.2) ; Wait just a giffy
exten => s,2,Playback(you-have-incoming) ; Tell ext that they have an imcoming call, and press 1 to accept the call 2 to reject it.
exten => s,3,Read(ACCEPT|screen-callee|1) ; Check to see if they press 1
exten => s,4,GotoIf($[${ACCEPT} = 1 ]?7:6) ; If they press 1 then bridge the call with a tiny wait.
exten => s,6,SetVar(MACRO_RESULT=CONTINUE) ; If they didn't press 1 then keep on trying
exten => s,7,Wait(0.1) ; just wait a giffy

Campon for busy outgoing.


Automatic redial
From Cyber-cottage.co.uk
Otherwise known as campon.

It can be usefull sometimes to have number redialed till free, As can be done by a "mobile phone".

To this end I have created a simple addition to the dial plan to do this and play the correct tones when a call fails with a reason, This works with SIP IAX and ISDN trunks.

This is a new conf file called timeout.conf

;This file controls the action on timeout and invalid call handling
;
;
[timeout]
exten => s,1,Goto(s-${DIALSTATUS},1)  ; This gets the dial status
;
exten => s-NOANSWER,1,Playtones(congestion)
exten => s-NOANSWER,n,wait(10)
exten => s-NOANSWER,n,Hangup()
; 
exten => s-CHANUNAVAIL,1,Playtones(unobtainable)
exten => s-CHANUNAVAIL,n,wait(10)
exten => s-CHANUNAVAIL,n,Hangup()
; 
; If a destination is busy the call may press 5 and the call will be  queued
exten => s-BUSY,1,Playtones(busy)
exten => s-BUSY,n,Set(TIMEOUT(digit)=1)
;exten => s-BUSY,n,Set(TIMEOUT(response)=5)
exten => s-BUSY,n,WaitExten(5)
exten => s-BUSY,n,Set(redialtime=30)
exten => s-BUSY,n,Goto(s-CAMPON,1) ; If users press 5 the call is  requeuded
exten => s-BUSY,n,Hangup()
; 
exten => s-CAMPON,1,NooP(${redial})   ;This is the number dialed
exten => s-CAMPON,n,NooP(${cont})     ;This is the Context of the call
exten => s-CAMPON,n,NooP(${redialtime})
exten => s-CAMPON,n,waitmusiconhold(${redialtime})
exten => s-CAMPON,n,Dial(Local/${redial}@${cont})
;
exten => s-CONGESTION,1,Playtones(congestion)
exten => s-CONGESTION,n,wait(10)
exten => s-CONGESTION,n,Hangup()
;
exten => 5,1,Noop(${EXTEN}
exten => 5,n,Set(redialtime=15)
exten => 5,n,Goto(s-CAMPON,1) ; If users press 5 the call is requeuded
;
exten => _5.,1,Noop(${EXTEN}
exten => _5.,n,Set(redialtime=${MATH(0${EXTEN:1}+10)})
exten => _5.,n,Goto(s-CAMPON,1) ; If users press 5 the call is  requeuded
;
exten => i,1,Playtones(switching)
exten => i,n,wait(10)
exten => i,n,Hangup()
;
exten => t,1,Playtones(switching)
exten => t,n,wait(10)
exten => t,n,Hangup()

It is called from the extensions.conf in the following manner.

;Long distance context accessed through trunk
exten => _90~np~[1-2]~/np~XXXXXXXXX,1,Dial(${TRUNK1}/${EXTEN:${TRUNKMSD}})
exten => _90~np~[1-2]~/np~XXXXXXXXX,n,set(redial=${EXTEN})
exten => _90~np~[1-2]~/np~XXXXXXXXX,n,set(cont=${CONTEXT})
exten => _90~np~[1-2]~/np~XXXXXXXXX,n,Goto(timeout,s,1)


So you now dial out as normal and if you get busy tone you can either hold on and it will redial every 30 seconds or press 5 and it will redial every 15 seconds or press 5xx where xx is any number of seconds from 1 upwards and will redial 10seconds plus the number of seconds.

What will then happen is you will sit back and listen to MOH and it will redial at the defined time and you can wait or press 5 etc


See also



Go back to Asterisk tips and tricks

Created by: JustRumours, Last modification: Thu 04 of Nov, 2010 (05:14 UTC) by admin
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+