There is asterisk, a group of operators (3-5 people) with a large load (average waiting time> 2 minutes)
The task is for subscribers with a certain geography to give the opportunity not to wait until the operator is free, and by pressing 0 hear “Thank you for the call. We will definitely call you back ”, disconnect and calmly wait for a call from the operator, well or
in the common people by smart Callback
Create tables
CREATE TABLE asterisk.callback (
id int (11) NOT NULL AUTO_INCREMENT,
dt timestamp DEFAULT CURRENT_TIMESTAMP,
cid varchar (32) DEFAULT NULL,
dst varchar (32) DEFAULT NULL,
status smallint (6) NOT NULL DEFAULT 0,
tot_calls int (11) NOT NULL DEFAULT 0,
last_call timestamp DEFAULT '0000-00-00 00:00:00',
compl_dt timestamp DEFAULT '0000-00-00 00:00:00',
uniqueid varchar (32) DEFAULT NULL,
queue varchar (255) DEFAULT NULL,
PRIMARY KEY (ID)
)
ENGINE = INNODB
CREATE TABLE asterisk.callback_log (
id int (11) NOT NULL AUTO_INCREMENT,
callback_id int (11) NOT NULL,
dt timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
status varchar (32) DEFAULT NULL,
params varchar (2048) DEFAULT NULL,
PRIMARY KEY (id),
CONSTRAINT callback_log_fk1 FOREIGN KEY (callback_id)
REFERENCES asterisk.callback (id) ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE = INNODB
Editing extensions.conf
exten => 88142590067, s, 1
same => n, GotoIf ($ ["$ {CALLERID (num): 0: 4}" = "8814"]? extra); if the number is local, then allow CALLBACK
.... you can insert more checks here ...
same => n, Goto (call)
same => n (extra), NoOp (Allow callback for $ {CALLERID (num)})
same => n, Set (ALLOW_CALLBACK = 1)
same => n, Set (CALLBACK_QUEUE = operators)
same => n, Background (vse / press0-to-callback)
same => n (call), NoOp (Ask for operators. GROUP_COUNT = $ {GROUP_COUNT (operators)})
same => n, queue (operators, tThH)
same => n, Hangup
include => main_menu_press
[main_menu_press]
exten => 0.1, NoOp ('-------------------- $ {CALLERID (num)} PRESS BUTTON $ {EXTEN}. ALLOW_CALLBACK = $ {ALLOW_CALLBACK} ')
same => n, GotoIf ($ [$ {ALLOW_CALLBACK} = 1]? callback, s, 1: i, 1)
[callback]
exten => s, 1, NoOp (CALLBACK)
same => n, Playback (thank-you-for-calling & vse / my-vam-perezvonim)
same => n, Hangup
exten => h, 1, agi (callback.php, gen, 0, $ {CALLBACK_QUEUE})
[do-callback]
exten => _X., 1, NoOp (Try to dial to queue ($ {CALLBACK_QUEUE}) and callback to $ {CALLBACK_NUM})
same => n, Set (__ DST = "?")
same => n, Set (CALLERID (num) = $ {CALLBACK_NUM})
same => n (call), queue ($ {CALLBACK_QUEUE}, tT)
same => n, NoOp (CALLBACK QUEUESTATUS = $ {QUEUESTATUS})
[macro-queue-answ]; We get here when the operator answered.
exten => s, 1, NoOp (Queue member answered uniq = $ {UNIQUEID} cid = $ {CALLERID (num)} chan = $ {CHANNEL} callback_id = $ {CALLBACK_ID} callback_num = $ {CALLBACK_NU
same => n, GotoIf ($ ["$ {CALLBACK_ID} x" = "x"]? skip)
same => n, Set (DST = $ {CHANNEL})
same => n, Set (CALLERID (num) = 067)
same => n, Playback (priv-trying); Play operator "Wait for connection"
same => n, agi (callback.php, queue-answering, $ {CALLBACK_ID}, $ {CHANNEL}, $ {UNIQUEID})
same => n, Dial (Local / $ {CALLBACK_NUM} @from_office_new)
same => n, NoOp ([macro-queue-answ] dial timeout)
same => n (skip), NoOp ()
exten => h, 1, NoOp ([macro-queue-answing] dial hangup)
same => n, GotoIf ($ ["$ {CALLBACK_ID} x" = "x"]? end)
same => n, NoOp (dialstatus = $ {DIALSTATUS} hangupcause = $ {HANGUPCAUSE} queuestatus = $ {QUEUESTATUS})
same => n, NoOp (my_dialstatus = $ {MY_DIALSTATUS} my_hangupcause = $ {MY_HANGUPCAUSE})
same => n, agi (callback.php, hangup-queue-answing, $ {CALLBACK_ID}, $ {CHANNEL}, $ {UNIQUEID})
same => n (end), NoOp
[callback-complete]
exten => s, 1, NoOp (Callback complete. CALLBACK_ID = $ {CALLBACK_ID}, uniq = $ {UNIQUEID}, dst = $ {DST} chan = $ {CHANNEL})
same => n, NoOp (dialstatus = $ {DIALSTATUS} hangupcause = $ {HANGUPCAUSE} queuestatus = $ {QUEUESTATUS})
same => n, NoOp (my_dialstatus = $ {MY_DIALSTATUS} my_hangupcause = $ {MY_HANGUPCAUSE})
Queues.conf file
[operators]
ringinuse = no
strategy = rrmemory
music = default
member => SIP / 321
member => SIP / 322
member => SIP / 323
member => SIP / 324
member => SIP / 325
member => Agent / 1
member => Agent / 2
member => Agent / 3
member => Agent / 4
member => Agent / 5
context = main_menu_press
timeout = 0
announce-position = yes
announce-frequency = 60
periodic-announce-frequency = 30
queue-youarenext = queue-youarenext
membermacro = queue-answ
Well, actually the scripts (PHP detected)
config.php
<?php ob_implicit_flush(true); set_time_limit(6); date_default_timezone_set('Europe/Moscow'); mysql_connect("localhost","asterisk","***") or die('Mysql connect error'); mysql_select_db("asterisk");
callback.php
And we put one more callback-regen.php file for the regeneration of call files in crowns every 5 minutes between 8 a.m. and 8 p.m.
With each attempt, the time of the repeated call is increased by 5 minutes. After 10 attempts to mock the operator, stop