SARK V4.0.0 blfdivert
Introduction
Sometimes it is useful to have a visual indicator that a divert is in effect for a call group or DDI pathway. This is similar to the open/closed BLF in V4.0.0, but you can apply it to any pathway. It works using custom hints and a small custom app to set/unset the pathways.
N.B. These notes are for SARK system pre V6. SARK V6 has automated this function. When you create a call group you have the option to enter a "Divert Target". The dial.BLF for this funtiocn is **{callgroup number}. So, for example, if you have a callgroup 454 then enabling/disabling it's divert would be **454
Example
We begin by defining a custom hint in sark_customer_hints.conf
; ; This file is provided as part of the SARK/SAIL Asterisk workbench rpm ; It is not a generated file so you may freely change it. It will not be ; overwritten if/when you upgrade SARK/SAIL ; exten => **900,hint,Custom:divert
This hint will monitor the state of a custom device **900. The device can be any unique string you like, but it will need to be "diallable" characters (0-9*#) if you ever want to dial it manually from a phone.
Next, we will create a custom app to change the state of the device and also to route calls according to the current state. Create a custom app (call it whatever you like) and give it a span of "internal". Copy this code into it
exten => s,1,Set(state=${DB(STAT/DIVSTAT)}) exten => s,n,GoToIf($["${state}" = "AUTO"]?normal:divert) exten => s,n(normal),GoTo(internal-presets,1002,1) exten => s,n(divert),GoTo(internal-presets,1003,1) exten => **900,1,Set(state=${DB(STAT/DIVSTAT)}) exten => **900,n,GoToIf($["${state}" = "AUTO"]?closeup:openup) exten => **900,n(closeup),Set(DB(STAT/DIVSTAT)=DIVERT) exten => **900,n,Set(DEVICE_STATE(Custom:divert)=BUSY) exten => **900,n,Playback(activated) exten => **900,n,Hangup exten => **900,n(openup),Set(DB(STAT/DIVSTAT)=AUTO) exten => **900,n,Set(DEVICE_STATE(Custom:divert)=NOT_INUSE) exten => **900,n,Playback(de-activated) exten => **900,n,Hangup
The app is made up of two parts;
- a router, which routes the call based upon the state of the custom device (the "s" extensions)
- a flip/flop (**900), which changes the state of the device.
In our example, calls will be routed to one of two call groups (called 1002 and 1003) depending upon the current device state. In the example, 1002 just rings a bunch of phones, but 1003 will send the call off-site to an external handling service. You could of course, change this to route to whatever you like; an IVR, a queue, whatever.
The flip/flop just sets the state of the custom device each time it is called (using **900 in our case).
Now simply set one or more BLF keys on your phones to a BLF value of **900, point the inbound route for your DDI to the custom app and you're done.
Note - some may ask why we tie an asterisk database value (STAT/DIVSTAT) to the custom device. This is so that diverts will survive a system restart. If we did not do this then a system restart would set the divert back to its idle state, which may not be what you intended, although the code would be somewhat simpler without it as shown here...
exten => s,1,GoToIf($["${DEVICE_STATE(Custom:divert)}" = "NOT_INUSE"]?normal:divert) exten => s,n(normal),GoTo(internal-presets,1002,1) exten => s,n(divert),GoTo(internal-presets,1003,1) exten => **900,1,GoToIf($["${DEVICE_STATE(Custom:divert)}" = "NOT_INUSE"]?closeup:openup) exten => **900,n(closeup),Set(DEVICE_STATE(Custom:divert)=BUSY) exten => **900,n,Playback(activated) exten => **900,n,Hangup exten => **900,n(openup),Set(DEVICE_STATE(Custom:divert)=NOT_INUSE) exten => **900,n,Playback(de-activated) exten => **900,n,Hangup