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.

; 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.

; 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


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.


Monday, April 11, 2011

Asternic Stats Outbound Tracking with FreePBX

We at Astiostech use Asternic ( quite extensively for basic call centres that require a simple interface for wallboards, reports and recordings.
Asternic also provides some capabilities to monitor outbound callcenters where agents make random calls to introduce new services or businesses.
In this guide, i will attempt to setup outbound call center setup using Asternic and at the same time, show you how to enable recordings that play straight off the Asternic web UI.
This guide assumes the use of Asternic 1.8, FreePBX 2.x and Asterisk 1.6 on Debian systems. I also assume you’ve got all else working with Asternic like, the ioncube loaders, the license and the website is showing you like below;
If yes, great, login with admin and the default password admin.


1) Firstly, you must get a valid licensed and a 1.8 version of Asternic. Write to and Nicolas will help you get those.
2) The way Asternic identifies if a particular someone is part of the outbound campaign is by looking for the accountcode value in SIP user as shown below in the FreePBX user configuration. In deviceuser mode, this would be the device, not user.
Here, i am creating an account code called C1 which is my outbound campaign 1. If you put things in perspective of an inbound this would then be a queue name. So all defined as C1 in their account code will then be agents of the queue C1. Simple as that right?
3) Next is to make some dialplan changes in FreePBX. There’s a file available from Asternic’s install source (/usr/src/asternic.source.dir/FreePBX/extensions_custom_asternic_outbound_freepbx.conf). Copy this file to /etc/asterisk. Now make sure the asterisk user owns this file since it was newly added.
Now edit it, and modify like below below.
IMPORTANT, THERE’S A SMALL OUTDATED LINE YOU NEED TO MODIFY. EDIT THE extensions_custom_asternic_outbound_freepbx.conf LIKE SHOWN BELOW; there’s one part which calls the mixmonitor dialplan, change the | pipes to , commas. Asterisk 1.4 and above will not accept pipes anymore.
exten => _X.,n,MixMonitor(${QDIALER_QUEUE}-${UNIQUEID}.wav|b|/usr/local/parselog/ ${UNIQUEID} ${QDIALER_QUEUE}-${UNIQUEID}.wav)
change to
exten => _X.,n,MixMonitor(${QDIALER_QUEUE}-${UNIQUEID}.wav,b,/usr/local/parselog/ ${UNIQUEID} ${QDIALER_QUEUE}-${UNIQUEID}.wav)
4) Edit /etc/asterisk/extensions_customs.conf and include the above file.
At the very top of extensions_customs.conf, add the line
#include extensions_custom_asternic_outbound_freepbx.conf
Now, if you have followed the INSTALL guide inside the binary archive. It will tell you to place a parselog into /usr/local/parselog/
Inside this directory, there’s an important perl file called which converts the WAV file to MP3 so that it can be played using the Asternic GUI (we will show you howto with that later). Make sure you edit this file.
edit /usr/local/parselog/
In there, make sure you
1) edit the database connection information, like the username and password particularly
2) edit the asterisk spool location (normally /var/spool/asterisk/monitor).
3) edit the destination dir (create one like /var/spool/asterisk/monitor-mp3)
4) Then go to the end of that file to the lame execution part (to convert WAV to MP3). Make sure the path to lame is correct.
Permission. Now pay attention to this!. Make sure you set the permissions correctly.
chown –R asterisk:asterisk /var/spool/asterisk/monitor
chown –R asterisk:asterisk /var/spool/asterisk/monitor-mp3
chown asterisk:asterisk /usr/local/bin/lame

Now, reload the dialplan, #asterisk –rx “dialplan reload”.
That should do the trick. Make sure you define the account code for the extension/device which need tracking and make that outbound call. Remember, these codes invoke dialout trunk prehook dialplan in FreePBX so internal calls won’t be tracked and if you have sip trunks and what not, make sure you set the correct context to those trunks. After making a couple of calls, you should see this;
Where C1 was my accountcode and Agent is my Outbound CID. I made some changes in the dialplan however to reflect the user/extension and not the Outbound CID. (email me if you need the codes for that)
As seen above, you can see the details of the calls being made by those in C1 “queue” or accountcode.


Now, as part of Asternic’s offering, you can rightfully with the above steps done properly, be able to see the recordings on the webUI. The only thing you need to do is add a value in the SETUP tab and look for the recordings_path parameter and set it to the destination directory as defined up there.
By using the above extra file called extensions_custom_asternic_outbound_freepbx.conf…. file by Asternic, all outbound calls with the accountcode defined will be recorded, of course, you can turn that off by commenting out the mixmonitor dialplan function but i am sure you would want to have that function for training and QA purposes right? Unlike the inbound Queues module in FreePBX, you can choose to record or not to record from the WebUI.
So, if all turns up well, you can see your recordings and play or download it straight from the Web! You need flash to play back by the way and use Firefox for best results.

At Astiostech, we do lots of customization of Asternic and call centre based solutions like Aheeva, Majuda that would suite just about any CallCenter types or sizes! Do write or calls us.
Or call us + 60 3 86892800

Sanjay W
From the engineering desk of Astiostech.