Friday, April 15, 2011

Asterisk | FreePBX boss secretary module (updated)

In some of our migrations to Asterisk, users keep asking about this feature where the secretary can pickup calls from the boss using a function key in their phones that support them.

Here’s the challenge, the secretary asked us to setup in such a way that they can press this button and pickup their boss’s call. So, that was simple, in Asterisk core its just **<exten> e.g. **1003 and it will pickup 1003 and just program that in the feature code.

The problem was, they want to dial the boss using the same key. So, when you hit **1003 obviously it will not work cause that’s a pickup code being sent.

So here’s the solutions.

How it works? It does a check to see if the device state of the boss is RINGING, if yes, cool, we will pickup if not, we will do a dial. Simple Smile. Here’s the dialplan for Asterisk 1.6.2, see note below if using Asterisk 1.4 with ported DEVSTATE module. Also note that this dialplan is designed for four digits extension scheme. Modify yours accordingly, esp XXXX part …

Note the pickupchan module worked on asterisk 1.6.2. This is to pickup channels originating from other context (such as from-did-direct). Use the appropriate technology such as SIP/ IAX/ or SKINNY/ for instance to pickup that particular extension’s telephone technology.

Put this code up in /etc/asterisk/extensions_custom.conf.

[app-boss-sec]  
; Dialplan
;
exten => _*XXXX*,1,NoOp(Starting boss sec module)
exten => _*XXXX*,n,Macro(user-callerid,)
exten => _*XXXX*,n,Set(mydev=${DB(AMPUSER/${EXTEN:1:4}/device)})
exten => _*XXXX*,n,NoOp(mydev is = ${mydev})
exten => _*XXXX*,n,NoOp(SIP/${mydev} has state ${DEVICE_STATE(SIP/${mydev})})
exten => _*XXXX*,n,Set(MYDEVICESTATE=${DEVICE_STATE(SIP/${mydev})})
exten => _*XXXX*,n,NoOp(SIP/${mydev} has state ${MYDEVICESTATE})
;
exten => _*XXXX*,n,Gotoif($[${MYDEVICESTATE} = RINGING ]?pickup)
;
exten => _*XXXX*,n,NoOp(Just call)
exten => _*XXXX*,n,Goto(from-internal,${EXTEN:1:4},1)
exten => _*XXXX*,n,Hangup
;
; We do normal directed pickup
exten => _*XXXX*,n(pickup),NoOp(Pickup)
exten => _*XXXX*,n,Pickup(${EXTEN:1:4})
;
; Incase directed pickup don’t work, we do pickup group type pickup
; Make sure they are in the same pickup group..but of course

exten => _*XXXX*,n,PickupChan(SIP/${EXTEN:1:4})
exten => _*XXXX*,n,Hangup

In extensions_custom.conf, you must include this in your [from-internal-custom]. If you don’t have that context, create it like this. Remember to register the relevant BLFs so that the lights are blinking correctly. In this example, there are two bosses we will “monitor” 1003 and 1004.

[from-internal-custom]
; Register BLFs
exten => *1003*,hint,SIP/1003
exten => *1004*,hint,SIP/1004

include => app-boss-sec

Now, reload asterisk dialplan #asterisk –rx “dialplan reload”.

After reloading, check the hints if they are correctly registered. You should see Watchers 1 or as many as you’ve configured on the secretary's phone. To check,

#asterisk -rx "core show hints" | grep 1003

image

Now on your secretary’s phone, setup the function key (and if you have BLF, use BLF as the function) and enter the extension as *1003*. Now when boss’s 1003 rings, the BLF will blink, if he’s busy will indicate busy light and if he’s not will indicate free light (LED colours and style may vary from phone to phone). If the boss’s phone is ringing, the secretary picks up and if is not ringing state, it will simply do a dial to his extension.

If using Asterisk 1.4 change DEVICE_STATE in the dialplan above to DEVSTATE. Transferring calls are also fine when invoking *<exten>* through the function key or manually dialling.

Do try and let us know.

 

No comments: