Asterisk Queue

From open-voip.org

Jump to: navigation, search

Let's add Queue to our PBX, we will do it directly in RealTime. The following lessons (at least) should be reviewed before this lesson: Asterisk Simple Realtime example

We will create a queue and assign extension 1000 and 2000 to answer the calls. the third call and the calls that come after will wait on the queue.


Contents

Configuring extconfig.conf

first need to change the extconfig.conf to supprot RealTime Queue, need to add these two lines:

queues => mysql,general,queue_table queue_members => mysql,general,queue_member_table

extconfig.conf will be look like this:

 [settings]
 sippeers => mysql,general,sip_buddies
 extensions => mysql,general,extensions
 voicemail => mysql,general,voicemail_users
 queues => mysql,general,queue_table 
 queue_members => mysql,general,queue_member_table


Create the MYSQL realtime tables

Queue should have two tables:

  • The queues definition `queue_table`
  • Assign Members to queue `queue_member_table`

Create the tables:

 CREATE TABLE `queue_table` (
 `name` varchar(128) NOT NULL,
 `musiconhold` varchar(128) default NULL,
 `announce` varchar(128) default NULL,
 `context` varchar(128) default NULL,
 `timeout` int(11) default NULL,
 `monitor_join` tinyint(1) default NULL,
 `monitor_format` varchar(128) default NULL,
 `queue_youarenext` varchar(128) default NULL,
 `queue_thereare` varchar(128) default NULL,
 `queue_callswaiting` varchar(128) default NULL,
 `queue_holdtime` varchar(128) default NULL,
 `queue_minutes` varchar(128) default NULL,
 `queue_seconds` varchar(128) default NULL,
 `queue_lessthan` varchar(128) default NULL,
 `queue_thankyou` varchar(128) default NULL,
 `queue_reporthold` varchar(128) default NULL,
 `announce_frequency` int(11) default NULL,
 `announce_round_seconds` int(11) default NULL,
 `announce_holdtime` varchar(128) default NULL,
 `retry` int(11) default NULL,
 `wrapuptime` int(11) default NULL,
 `maxlen` int(11) default NULL,
 `servicelevel` int(11) default NULL,
 `strategy` varchar(128) default NULL,
 `joinempty` varchar(128) default NULL,
 `leavewhenempty` varchar(128) default NULL,
 `eventmemberstatus` tinyint(1) default NULL,
 `eventwhencalled` tinyint(1) default NULL,
 `reportholdtime` tinyint(1) default NULL,
 `memberdelay` int(11) default NULL,
 `weight` int(11) default NULL,
 `timeoutrestart` tinyint(1) default NULL,
 `periodic_announce` varchar(50) default NULL,
 `periodic_announce_frequency` int(11) default NULL,
 `ringinuse` tinyint(1) default NULL,
 `setinterfacevar` tinyint(1) default NULL,
 PRIMARY KEY  (`name`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 CREATE TABLE `queue_member_table` (
 `uniqueid` int(10) unsigned NOT NULL auto_increment,
 `membername` varchar(40) default NULL,
 `queue_name` varchar(128) default NULL,
 `interface` varchar(128) default NULL,
 `penalty` int(11) default NULL,
 `paused` int(11) default NULL,
 PRIMARY KEY  (`uniqueid`),
 UNIQUE KEY `queue_interface` (`queue_name`,`interface`)
 ) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;


Inserting the new Queue and members

insert the new queue "my_queue" and the two extensions 1000 and 2000 as members:

 INSERT INTO `queue_table` 
 (`name`,`context`) 
 VALUES 
 ('my_queue','from-sip');
 INSERT INTO `queue_member_table`
 (`uniqueid`,`membername`,`queue_name`,`interface`,`penalty`,`paused`) 
 VALUES 
 (1,'SIP/1000@from-sip','my_queue','SIP/1000',NULL,0);
 ;
 INSERT INTO `queue_member_table`
 (`uniqueid`,`membername`,`queue_name`,`interface`,`penalty`,`paused`)
 VALUES 
 (2,'SIP/2000@from-sip','my_queue','SIP/2000',NULL,0);


Extension.conf

Change dial-plan in extensions.conf so 12127777777 will call the queue: File:queue_extensions.GIF

Queue command options:

 Queue(queuename[,options[,URL][,announceoverride][,timeout][,AGI][,macro][,gosub][,rule]):
 The option string may contain zero or more of the following characters:
     'c' -- continue in the dialplan if the callee hangs up.
     'd' -- data-quality (modem) call (minimum delay).
     'h' -- allow callee to hang up by hitting '*', or whatver disconnect sequence
            that is defined in the featuremap section in features.conf.
     'H' -- allow caller to hang up by hitting '*', or whatever disconnect sequence
            that is defined in the featuremap section in features.conf.
     'n' -- no retries on the timeout; will exit this application and 
            go to the next step.
     'i' -- ignore call forward requests from queue members and do nothing
            when they are requested.
     'r' -- ring instead of playing MOH. Periodic Announcements are still made, if applicable.
     't' -- allow the called user transfer the calling user by pressing '#' or
            whatever blindxfer sequence defined in the featuremap section in
            features.conf
     'T' -- to allow the calling user to transfer the call by pressing '#' or
            whatever blindxfer sequence defined in the featuremap section in
            features.conf
     'w' -- allow the called user to write the conversation to disk via Monitor
            by pressing the automon sequence defined in the featuremap section in
            features.conf
     'W' -- allow the calling user to write the conversation to disk via Monitor
            by pressing the automon sequence defined in the featuremap section in
            features.conf
     'k' -- Allow the called party to enable parking of the call by sending
            the DTMF sequence defined for call parking in features.conf.
     'K' -- Allow the calling party to enable parking of the call by sending
            the DTMF sequence defined for call parking in features.conf.
     'x' -- allow the called user to write the conversation to disk via MixMonitor
            by pressing the automixmon sequence defined in the featuremap section in
            features.conf
     'X' -- allow the calling user to write the conversation to disk via MixMonitor
            by pressing the automixmon sequence defined in the featuremap section in
            features.conf

Queue CLI commands

 localhost*CLI> queue show my_queue 
 my_queue     has 0 calls (max unlimited) in 'ringall' strategy (5s holdtime), W:0, C:1, A:1, 
 SL:0.0% within 0s
 Members: 
 SIP/2000@from-sip (SIP/2000) (realtime) (Unavailable) has taken 1 calls (last was 78 secs ago)
 No Callers

To lean more about all the queue options, (queues.conf or queue_table in realtime) read the queues.conf file

Personal tools