📜 ⬆️ ⬇️

Evaluation of operators at Asterisk

Good day% habrauser%

A couple of days ago I was approached by the head of the online store department. Like all large Internet stores, they have their own Call Center, built on the basis of Elastix. He was faced with the task of making an operator assessment at Elastix.

Task:


It is required to add an additional module for Asterisk (elastix):
')
The hotline requires a voice menu with statistics collection.
Question: "Did the experts of the Hotline help you?"
Answer options: No - the button "0" and Yes - the button "1"

Decision



Everything went to ensure that after talking with the operator the client got into the IVR where he could vote, but I was pulled further and I solved this problem like this:

1) Cooking mysql db:
By default, asterisk writes CDRs to the asteriskcdrdb database, for our additional statistics we will add a new table there.

DROP TABLE IF EXISTS `opinion`; CREATE TABLE IF NOT EXISTS `opinion` ( `id` int(11) NOT NULL auto_increment, `callerid` varchar(15) NOT NULL default '', `exten` varchar(15) NOT NULL default '', `queues` varchar(7) NOT NULL, `opinion` char(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; 


2) Cooking Macro
Add to /etc/asterisk/extensions_custom.conf:

 [macro-press-1] exten => s,1,MYSQL(Connect connid localhost _ _ asteriskcdrdb) exten => s,n,MYSQL(Query resultid ${connid} INSERT INTO opinion (`id`, `callerid`, `exten`, `queues`, `opinion`) VALUES (NULL, ${FROMEXTEN}, ${CDR(dst)}, ${CDR(src)}, 1)) exten => s,n,MYSQL(Clear ${resultid}) exten => s,n,MYSQL(Disconnect ${connid}) [macro-press-0] exten => s,1,MYSQL(Connect connid localhost _ _ asteriskcdrdb) exten => s,n,MYSQL(Query resultid ${connid} INSERT INTO opinion (`id`, `callerid`, `exten`, `queues`, `opinion`) VALUES (NULL, ${FROMEXTEN}, ${CDR(dst)}, ${CDR(src)}, 0)) exten => s,n,MYSQL(Clear ${resultid}) exten => s,n,MYSQL(Disconnect ${connid}) 


The user and password for the asteriskcdrdb database are usually in the /etc/asterisk/cdr_mysql.conf file

3) Add Feature Application
In features_applicationmap_custom.conf we add the numbers we need and bind to the macro

 press1 => 1,peer/caller,Macro,press-1 press0 => 0,peer/caller,Macro,press-0 


In order for the feature application to work, you need to add it to the global variable in the dialpal.
in /etc/asterisk/extensions_override_freepbx.conf add

 [globals] DYNAMIC_FEATURES = apprecord#press0#press1 


The apprecord is usually already used in Freepbx too.

Result



At the time of conversation with the operator, the client has the opportunity to evaluate it by pressing 0 or 1

Success rating log:
  -- Feature Found: press1 exten: press1 -- Executing [s@macro-press-1:1] MYSQL("Local/299@from-queue-56b8;1", "Connect connid localhost root 123 asteriskcdrdb") in new stack -- Executing [s@macro-press-1:2] MYSQL("Local/299@from-queue-56b8;1", "Query resultid 1 INSERT INTO opinion (`id`, `callerid`, `exten`, `queues`, `opinion`) VALUES (NULL, +74993462198, 299, 1234, 1)") in new stack 


see what is in the database

 mysql> SELECT * FROM opinion; +----+-------------+-------+--------+---------+ | id | callerid | exten | queues | opinion | +----+-------------+-------+--------+---------+ | 8 | 74993462198 | 299 | 1234 | 1 | | 9 | 74993462198 | 299 | 1234 | 1 | +----+-------------+-------+--------+---------+ 2 rows in set (0.00 sec) 


UPDATE:



It is possible to screw the IVR for evaluation even after the operator has hung up:

Queue settings need to be done in the WEB interface, if the FreePbx version allows Members to specify LOCAL / 999 @ opinion-ivr / n, then you can skip the first item, if not, you don’t need to add Members to the web, add them to queues_post_custom.conf

 member=Local/299@opinion-ivr/n member=Local/999@opinion-ivr/n 


In extensions_custom.conf

 [opinion-ivr] exten => _.,1,NoOp(Statrt IVR) exten => _.,n,DIAL(SIP/${EXTEN},,trg) ; g       exten => _.,n,Goto(opinion,,1) [opinion] exten => _X.,1,NoOp(Statrt IVR) exten => _X.,n,Background(Plese_press_0_or_1,m) ;      exten => _X.,n,Set(TIMEOUT(absolute)=2) exten => 0,1,MYSQL(Connect connid localhost root 123 asteriskcdrdb) exten => 0,n,MYSQL(Query resultid ${connid} INSERT INTO opinion (`id`, `callerid`, `exten`, `queues`, `opinion`) VALUES (NULL, ${FROMEXTEN}, ${DIALEDPEERNUMBER}, ${NODEST}, 0)) exten => 0,n,MYSQL(Disconnect ${connid}) exten => 1,1,MYSQL(Connect connid localhost root 123 asteriskcdrdb) exten => 1,n,MYSQL(Query resultid ${connid} INSERT INTO opinion (`id`, `callerid`, `exten`, `queues`, `opinion`) VALUES (NULL, ${FROMEXTEN}, ${DIALEDPEERNUMBER}, ${NODEST}, 1)) exten => 1,n,MYSQL(Disconnect ${connid}) 


All positive ratings !!!

Source: https://habr.com/ru/post/147122/


All Articles