Do Not Disturb

From Etel

Jump to: navigation, search

Contents

Do Not Disturb

  • Do Not Disturb - DND


Problem

Implement a "feature code" on your PBX dialplan that enables your users to just dial a specific number to set their status: Do Not Disturb Activated or De-Activated.

Solution

I would split this solution in 2 parts:

  • Creating an Extension that users dial to Set DND-ON or DND-OFF
    • To simplify your dialplan and as a best practice I define a Macro-DND, this macro just checks your DND status and switch to the opposite one, ON or OFF.
  • Tell your Asterisk Server to check, every time there is a call to a local extension, if DND is ON or OFF
    • I would recomend you to develop this idea inside your main macro used to dial to every local extension, but here i just post the idea.
sip.conf
[MoutaPT]
type=friend
secret=12345
qualify=no
port=5060
nat=no
host=dynamic
dtmfmode=rfc2833
context=from-internal
canreinvite=no
callerid="MoutaPT"<2000> ; CallerID(name) and CallerID(number) that will be used later on in our dialplan
Extensions.conf
  • This Macro Checks wether or not Exists an entry for your callerid number on AstDB:
    • Do not disturb is enabled when: There is an entry on AstDB with your CallerID(num)
    • Do not disturb is disabled when: There is no entry on AstDB with your CallerID(num)
[macro-DND]
exten => s,1,GotoIf(${DB_EXISTS(DND/${CALLERID(num)})}?disable-dnd|1) 
exten => s,n,Set(DB(DND/${CALLERID(num)})=1) ;There was no entry on AstDB, so We active your DND
exten => s,n,playback(do-not-disturb)
exten => s,n,playback(activated)
exten => s,n,hangup

exten => disable-dnd,1,DBdel(DND/${CALLERID(num)}) ; You are disabling your DND
exten => disable-dnd,n,playback(do-not-disturb) 
exten => disable-dnd,n,playback(de-activated)
exten => disable-dnd,n,hangup

exten => h,1,hangup

  • Now in your dialplan you can provide DND service for example on extension *99:
[internal-services]

exten => *99,1,Macro(DND)

exten => *99,n,hangup


  • Every time there is call to an extension on your PBX you need to check whether or not DND is ON:
    • Considering your internal extensions are SIP with pattern 2XXX and all have voicemail
[from-internal]
exten => _2XXX,1,GotoIf(${DB_EXISTS(DND/${EXTEN})}?DND-ON,1);If DND entry exists on AstDB it means DND is ON
exten => _2XXX,n,Dial(SIP/${EXTEN},20,t) ; DND is OFF, start dialing
exten => _2XXX,n,Goto(s-${DIALSTATUS},1)

exten=> s-BUSY,1,Voicemail(b${EXTEN}@default)
exten=> s-BUSY,n,hangup

;Any Other Status
exten =>_s-.,1,Voicemail(u${EXTEN}@default)
exten =>_s-.,n,hangup

exten => DND-ON,1,Goto(_s-.,1) ;In this example if DND is ON it will present you Unavailable VoiceMail Message

exten => h,1,hangup

Discussion

An easy and useful approach, at least for me, is to use AstDb -Asterisk database, version 1 of the Berkley DB - to keep the status of every extension.

So keeping the DND status of very user on AstDB, will allow us to check it faster and easily on every call that is placed on our Asterisk server.

Using:

asterisk -rx "database put DND CallerID(num) "any value"

asterisk -rx "database del DND CallerID(num)"

will allow you to develop a web app with PHP or other technology to let your users manage their extension status.


  • To enable more features and explain all this in a simple way i would consider to setup a Macro to be called whenever a local extension is dialed, do you agree? How should we call this "big" Macro responsable to check DND and CFW and other stuff...?

See Also:

Metadata

  • By: Marco Mouta
  • Outline reference (User Services - Do Not Disturb); [1]
Personal tools