# Set device to a busy or DND state

**URL:** <https://community.asterisk.org/t/set-device-to-a-busy-or-dnd-state/44924>\
**Category:** Asterisk Support\
**Created:** [January 10, 2014, 9:58am UTC](https://community.asterisk.org/t/set-device-to-a-busy-or-dnd-state/44924 "2014-01-10T09:58:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![progressaurus](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/progressaurus/32/2439_2.png) [@progressaurus](https://community.asterisk.org/u/progressaurus)\
**Post date:** [January 10, 2014, 9:58am UTC](https://community.asterisk.org/t/set-device-to-a-busy-or-dnd-state/44924/1 "2014-01-10T09:58:01Z")

</div>

Hi there,

I would like to create some functionality from my application where a user has the ability to essentially set their phone to a ‘Do Not Disturb’ or ‘Busy’ state then back again to ‘Available’. The x-lite has a button to do this however as all the other phone funtionality is controlled via my application then I would also like this to be controlled here too.

I am using the AMI for my integration, is there a way to do this via the AMI or another way to get the desired effect?

Thanks for any help

Vicibox 5 64bit from .iso | Vicidial 2.8-416a | Build 131016-2112 | Asterisk 1.8.23.0-vici | Single Server

---

<div class="post-metadata">

**Author:** ![david55](https://avatars.discourse-cdn.com/v4/letter/d/e19adc/32.png) [@david55](https://community.asterisk.org/u/david55)\
**Post date:** [January 10, 2014, 10:45am UTC](https://community.asterisk.org/t/set-device-to-a-busy-or-dnd-state/44924/2 "2014-01-10T10:45:54Z")

</div>

Set a global channel variable or Astdb entry.

---

<div class="post-metadata">

**Author:** ![progressaurus](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/progressaurus/32/2439_2.png) [@progressaurus](https://community.asterisk.org/u/progressaurus)\
**Post date:** [January 10, 2014, 11:33am UTC](https://community.asterisk.org/t/set-device-to-a-busy-or-dnd-state/44924/3 "2014-01-10T11:33:09Z")

</div>

Thanks for that David,

I have went down the route of setting a value in the astDB to handle this:

My context for inbound is:  
[sip-incoming-calls]  
exten =\> \_X.,1,Answer  
exten =\> \_X.,n,Queue(cc-queue,t,60)  
exten =\> \_X.,n,Dial(${siptrunk}/012345678910)  
exten =\> \_X.,n,hangup

and for my DND functionality:  
[DND]  
exten =\> \*99,1,Macro(DND)  
exten =\> \*99,n,hangup

[macro-DND]  
exten =\> s,1,noop(–macro DND device=${CALLERID(name)}–)  
exten =\> s,n,GotoIf(${DB\_EXISTS(DND/"${CALLERID(name)}")}?disabled-dnd,1)  
exten =\> s,n,Set(DB(DND/"${CALLERID(name)}")=“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 =\> disabled-dnd,1,noop(–DND Deactivated–)  
exten =\> disabled-dnd,n,DBdel(DND/"${CALLERID(name)}") ; You are disabling your DND  
exten =\> disabled-dnd,n,playback(do-not-disturb)  
exten =\> disabled-dnd,n,playback(de-activated)  
exten =\> disabled-dnd,n,hangup

exten =\> h,1,hangup

When calling \*99 the activated and de-activated playback is successful. However in my inbound context where the call goes into a queue how do I check the astDB to find if the device that is being rung has the DND activated.

Thanks  
Chad

---

<div class="post-metadata">

**Author:** ![dejanst](https://avatars.discourse-cdn.com/v4/letter/d/9fc348/32.png) [@dejanst](https://community.asterisk.org/u/dejanst)\
**Post date:** [January 10, 2014, 2:43pm UTC](https://community.asterisk.org/t/set-device-to-a-busy-or-dnd-state/44924/4 "2014-01-10T14:43:24Z")

</div>

Set a channel variable and check it later:

```auto
.
exten => s,n,Set(DND_Status=${DB(.....)})
exten => s,n,GotoIf($[${DND_Status} = 0]?call:not_call)
.
```

When designing the feature, keep in mind this logic:

- each extension has a set parameter in AstDB
- if parameter value is 0 =\> feature is disabled
- if parameter value is not 0 =\> feature is enabled

---

<div class="post-metadata">

**Author:** ![progressaurus](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/progressaurus/32/2439_2.png) [@progressaurus](https://community.asterisk.org/u/progressaurus)\
**Post date:** [January 10, 2014, 3:16pm UTC](https://community.asterisk.org/t/set-device-to-a-busy-or-dnd-state/44924/5 "2014-01-10T15:16:01Z")

</div>

Thanks for your reply Dejanst,

I understand that part now about setting the variable, but in my call route the call is delivered to a queue which has for instance 10 sip devices. How do I check the channel variable to know which sip devices are on DND so the devices aren’t rung?

---

<div class="post-metadata">

**Author:** ![progressaurus](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/progressaurus/32/2439_2.png) [@progressaurus](https://community.asterisk.org/u/progressaurus)\
**Post date:** [January 10, 2014, 6:07pm UTC](https://community.asterisk.org/t/set-device-to-a-busy-or-dnd-state/44924/6 "2014-01-10T18:07:06Z")

</div>

Found a way to do it using Local channels, but Im not sure if its the best way 😄

queues-custom.conf  
[cc-queue] ;Main Call Queue  
strategy = rrmemory  
ringinuse = no  
context = sip-incoming-calls  
wrapuptime = 20  
memberdelay = 0  
timeout = 10  
retry = 1  
eventmemberstatus = no  
member =\> Local/SIP-3000@MemberConnectorQ,SIP/3000

extensions.conf  
[MemberConnectorQ]  
exten =\> \_[A-Za-z0-9].,1,Noop(Connecting to Member at ${EXTEN})  
same =\> n,Set(QueueMember=${FILTER(A-Za-z0-9-,${EXTEN})})  
same =\> n,Set(Technology=${CUT(QueueMember,-,1)})  
same =\> n,Set(Device=${CUT(QueueMember,-,2)})  
same =\> n,GotoIf(${DB\_EXISTS(DND/${Device})}?dnd,1)  
same =\> n,Dial(${Technology}/${Device})  
same =\> n,hangup()

exten =\> dnd,1,noop(==DND Deactivated==)  
exten =\> dnd,n,hangup()

The point where Im checking if the DND/${Device} in the above context exsits, Im not sure if its the best way to do this.

Thanks  
Chad
