Set device to a busy or DND state

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 | Single Server

Set a global channel variable or Astdb entry.

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:
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:
exten => *99,1,Macro(DND)
exten => *99,n,hangup

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.


Set a channel variable and check it later:

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

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?

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

[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

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.