Setting DND (Do Not Disturb) in FOP2 ProgrammaticallyTweet
Change agents or extensions DND status in FOP2 by using plain Asterisk events
FOP2 (from Flash Operator Panel) is one of the most used graphical interfaces to the Asterisk PBX. By using it we can see in realtime what is going on with the queues and extensions (or agents). In this article we're going to see how we can integrate our systems with FOP2 so we can change the status of the extensions without using the graphical interface.
FOP2 Version required so DND can be set via Asterisk PBX Events
As a side note, you might want to use the latest FOP2 version (2.31 at this time). Each FOP2 release fixes bugs in the previous versions and also takes into account new bugs/fixes in each Asterisk release.
Using the UserEvent action in Asterisk PBX to signal FOP2 about the DND change
FOP2 will pickup what you send in a Custom UserEvent with some specific values, and we can use this to our own advantage.
We can send our own custom events by using the Asterisk action UserEvent, and the Asterisk Manager Interface connection to the Asterisk PBX with these values:
- UserEvent: "FOP2ASTDB"
- Family: "fop2state"
- Value: "Do not Disturb" (and we can also set this to a blank value to clear the DND status).
- Channel: The SIP peer where you want to set DND.
In the following code, the NAMI client is being instantiated and used to connect to Asterisk. Afterwards, the UserEvent action is being sent with the right values to setup DND (Do not Disturb) status in the SIP/1000 peer.
The same code can be used to clear the DND status if we leave the Value property as an empty string.
Control the FOP2 DND status in the agents or extensions from your own code
This opens up a lot of interesting possibilities for your own applications, since now you can control this in any way you like. For example, an operator would be able to change this via a web application, or perhaps an AGI application, like an IVR could change an extension status when it picks up a call.