Asterisk Queue Callback
This feature allows a caller holding in your queue to press '1' and enter a phone number to be called back at when their slot in line comes up next. Note: This requires Asterisk 1.2
To accomplish this, I created a SQL table that contains a list of all callers in the queue. When the caller gets put in the queue, an entry is added to the SQL table, and when they hang up it is removed. However, as you can see from the dialplan below, if they press '1' while waiting in the queue, it prompts them to enter in a phone number and then hangs up without removing the entry from the SQL table. I have written a perl daemon that runs in the background and periodically looks at the caller holding the longest in the queue and whether or not they have requested a callback. If they have, the daemon drops a .call file and deletes the entry from the table. The .call file calls the customer back at their predetermined phone number and puts them back in the queue after first setting QUEUE_PRIO to 10 (default callers are set to 0) which puts the caller at the front of the line for the next available rep.
NOTE: what this actually does is wait a fixed number of seconds (20 in the example) and then call the caller and put them at the front of the queue. It does NOT preserve the caller's place in line. In fact, it is quite possible for a caller to cut in front of others just by selecting this callback option.
It works well in our small setup, but I'm not sure on how well it would scale. Either way, I couldn't find any answers to accomplish this other than the broken ICD or a commercial offering that was prohibitively expensive.
Anyhow... on to it.. Create the SQL table shown below, and in my example dialplan, you would send calls to the 'support-queue' context. Callers that opt for a callback would get dropped into the 'callback' context (where their QUEUE_PRIO gets raised to 10). Run the perl daemon on your asterisk machine so it can monitor the SQL table and drop the .call files as needed.
Note: This is just for starters. MAKE SURE you add some logic into it to prevent malicious callers from requesting callbacks to 911, 411, the local police, my house, etc.
-- tf. <tyler_AT_unixgod_DOT_net>
SQL Table Structure
If using the dialplan below, put the following table into a database called 'acd'.
CREATE TABLE `bit_callers` (
`uniqueid` varchar(15) NOT NULL default '',
`callback` int(3) NOT NULL default '0',
`callbacknum` varchar(15) NOT NULL default '',
PRIMARY KEY (`uniqueid`),
KEY `callback` (`callback`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Dialplan Additions
[support-queue]
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,MYSQL(Connect connid 127.0.0.1 acd acdpass acd)
exten => s,n,MYSQL(Query r ${connid} INSERT\ INTO\ callers\ set\ uniqueid=${UNIQUEID})
exten => s,n,MYSQL(Disconnect ${connid})
exten => s,n,Queue(support|t)
exten => 1,1,Read(CALLBACKNUM|beep|10) ; This is where you request the CallBack Number from your customer. Put your own prompts or whatever here.
exten => 1,n,MYSQL(Connect connid 127.0.0.1 acd acdpass acd)
exten => 1,n,MYSQL(Query r ${connid} UPDATE\ callers\ SET\ callback=1\,callbacknum=${CALLBACKNUM} WHERE\ uniqueid\=${UNIQUEID})
exten => 1,n,MYSQL(Disconnect ${connid})
exten => 1,n,Playback(goodbye)
exten => 1,n,Hangup
exten => h,1,MYSQL(Connect connid 127.0.0. ...