Day Night Service Toggle
Hi,
I need dialplan to set INCOMING call forwarding during lunch break to my secretary.
I want that I can set call forwarding by dialing an extension number to turn it ON or OFF.
I am using asterisk 11.
Thanks
Abdullah Faheem
3 thoughts on - Day Night Service Toggle
Hello Control,
There are probably lots of ways to do this, and it would be worth checking to see whether your handset can be programmed to do the forwarding, which is simpler than setting up a dialplan to handle it.
I pass incoming calls to a mobile phone based on a toggle. There are three parts to this:
[1] I have a Global Variable (MDIVERT) that holds the current Divert status.
[2] I have an extension (*70) that toggles the value of the Global variable
[3] I have a GotoIf in my incoming call handler that selects different dial strings depending on whether the is set or not.
I added a two voice prompts to announce the status of MDIVERT. Dialling *70 the first time sets the variable and dialling *70 again unsets it.
[1] Create the Global Variable
[globals]
MDIVERT=0
[2] Toggle the variable.
exten => *70,1,Set(GLOBAL(MDIVERT)=${IF($[ ${MDIVERT} = 1]?0:1)})
exten => *70,n,GotoIf($[ $[ “${MDIVERT}” = “0” ] ]?notset)
exten => *70,n,playback(divertactive)
exten => *70,n,Hangup()
exten => *70,n(notset),playback(divertinactive)
exten => *70,n,Hangup()
[3] GotoIf in call handler
exten => 100,1,GotoIf($[“${MDIVERT}” = “1”]?divert) ; check variable exten => 100,n,Dial(SIP/ManagerPhone,30,ctkx) ;Call your phone exten => 100,n,Hangup()
exten => 100,n(divert),Dial(SecretaryPhone,30,ctkx) ; call Secretary exten => 100,n,Hangup()
I have cut out a lot from the dialplan to give you an idea, but I am sure that others will chip in with their ideas and point out the failings in my approach 🙂
J
What you need to do is, set a global variable from within your dialplan, to indicate whether you are at your desk (meaning calls to your number should go to your phone) or on lunch (meaning calls to your number should go somewhere else).
And note that this really should be done by dialling separate numbers for “in”
and “out”, because toggle actions are annoying as hell in practice — it’s easier to remember two different numbers, than to remember what state you are currently in.
If 101 is you and 102 is the person who fields your calls while you are on lunch, you need something like this;
; extension 101
exten => 101,1,GotoIf($[${ON_LUNCH}] ? on_lunch : at_desk)
exten => 101,n(at_desk),Dial(SIP/101)
exten => 101,n,Hangup()
exten => 101,n(on_lunch),Dial(SIP/102)
exten => 101,n,Hangup()
; These extensions should be in some context which is only callable from 101
; extension 771 sets “on lunch”
exten => 771,1,Set(GLOBAL(ON_LUNCH)=1)
exten => 771,n,Playback(ajs-set_on_lunch)
exten => 771,n,Hangup()
; extension 770 sets “at desk”
exten => 770,1,Set(GLOBAL(ON_LUNCH)=)
exten => 770,n,Playback(ajs-set_at_desk)
exten => 770,n,Hangup()
According to NANPA’s ‘Vertical Service Codes, Code Definitions’
(http://www.nanpa.com/number_resource_info/vsc_definitions.html), *72 and
*73 are for call forwarding activation and deactivation (respectively).
Of course, the OP could use execiftime() instead and just make sure to go to lunch and return at the exact same time every day. The dialplan coding is easier and no pesky codes to remember.