Thursday, June 7, 2012

FreePBX/Asterisk Override DND (or Do Not Disturb)

There are cases where you want to make urgent calls and override the DND set by the user on their phones. These scenarios include
1) Hotel style wake up call (download the hotel wake up module for freePBX)
2) Emergency internal calling
NOTE:
This dialplan only works with Asterisk/FreePBX level DND setting (i.e. setting the DND value in ASTDB). It will not work for phone level DND setting)
Use Asterisk 1.8 or higher only
What it does;
1) It unsets the DND value
2) Makes the call
3) Sets back the DND Value
The Dialplan, put these in /etc/asterisk/extensions_custom.conf (for freepbx) or extensions.conf in vanilla installs
[dnd-override]
exten => _X.,1,NoOp(This context overrides DND)
same => n,Set(IFDNDENABLED=${DB(DND/${EXTEN})})
same => n,ExecIf($["${IFDNDENABLED}"="YES"]?Noop(Deleting: DND/${EXTEN} ${DB_DELETE(DND/${EXTEN})}))
same => n,Goto(from-internal,${EXTEN},1)
same => n,Hangup()
;
exten => h,1,NoOp(Adding back DND status if that existed for user ${CONNECTEDLINE(num)})
exten => h,n,ExecIf($["${IFDNDENABLED}"="YES"]?Set(DB(DND/${CONNECTEDLINE(num)})=YES))
exten => h,n,Hangup

Since this context is handling the hangup, therefore we can invoke the h extension to write back the DND value after the channel gets hanged up. If you use any of those hotel calling modules, simply call this dialplan above to invoke DND override.
You can use this context in many different ways, such as the one shown below, where we “authenticate” a request for DND override first, then ask for the extension to dial.
[macro-dnd-override]
exten => s,1,NoOp(DND Override Call)
exten => s,n,Authenticate(12345,a) ;; 12345 is the password here
exten => s,n,Read(DNDOVERRIDECALLNUM,please-enter-your-extension-then-press-pound,,,4)
exten => s,n,Goto(dnd-override,${DNDOVERRIDECALLNUM},1)
exten => s,n,Hangup

You can invoke the macro inside FreePBX by enabling it via Custom Destination, then create a Feature Code via Misc. Applications. Then you can invoke by any dialing you’ve configured there.
Post a Comment