📜 ⬆️ ⬇️

Indication of the subscriber's status in the queue on the phone with BLF buttons

image Today the task is a little more difficult.
The client needs to be able to enter / exit the queue by pressing the speed dial button. Moreover, if the subscriber is in the queue, the button is green, if not, then blinks red. This can be done if the IP itself supports the phone function BLF. For the function to work, the button will need to register the number of the form * 12111 * 222, where 111 is the queue number and 222 is the subscriber number. It was tested on the Grandstream GXP series, the most different. The server is Linux with Elastix, well, you can just Asterisk 1.6+ .
One of the conditions is the lack of binding to the subscriber number. Queue numbers are fixed, and subscribers can be any. To monitor the state in Asterisk you need HINT and if it is not there, we will create it.
This will require an additional script, but for now let's start with the macro in extensions.conf. In our case, this is extensions_override_freepbx.conf, since we are dealing with Elastix.
Add the input / output handler macro to the context we need:
[app-queue-toggle] include => app-queue-toggle-custom exten => s,1(start),Answer exten => s,n,Wait(1) exten => s,n,Macro(user-callerid,) exten => s,n,Set(QUEUESTAT=LOGGEDOUT) exten => s,n,AGI(queue_devstate.agi,getqueues,${AMPUSER}) exten => s,n,AGI(qu.php, ${AMPUSER}, ${QUEUENO}) exten => s,n,NoOp(number my ${CALLERIDMY}) exten => s,n,GotoIf($["${QUEUESTAT}" = "LOGGEDOUT"]?activate) exten => s,n,GotoIf($["${QUEUESTAT}" = "LOGGEDIN"]?deactivate) exten => s,n,GotoIf($["${QUEUESTAT}" = "STATIC"]?static:end) exten => s,n(deactivate),Noop(Agent Logged out) exten => s,n,Macro(toggle-del-agent,) exten => s,n,Set(DEVICE_STATE(Custom:QueueStat${CALLBACKNUM})=RINGING) exten => s,n(logout),Playback(agent-loggedoff) exten => s,n,Macro(hangupcall,) exten => s,n(activate),Noop(Agent Logged In) exten => s,n,Macro(toggle-add-agent,) exten => s,n,Set(DEVICE_STATE(Custom:QueueStat${CALLBACKNUM})=NOT_INUSE) exten => s,n,GotoIf($["${QAGENT_UNAUTHORIZED}"="1"]?logout) exten => s,n,Playback(agent-loginok) exten => s,n,SayDigits(${CALLBACKNUM}) exten => s,n,Macro(hangupcall,) exten => s,n(static),Noop(User is a Static Agent) exten => s,n,Playback(agent-loginok) exten => s,n,Macro(hangupcall,) 

And we hang it on our number, here we also add the HINTs that will be added as needed.
 [ext-queues] include => ext-queues-custom exten => _*12111*XXX,1,Set(QUEUENO=111) exten => _*12111*XXX,n,Goto(app-queue-toggle,s,start) #include /etc/asterisk/extensions_override_hints.conf 

The hints will be stored in the external /etc/asterisk/extensions_override_hints.conf file. It will have entries of the following form:
 exten => *12111*222,hint,Custom:QS111222 

Even in the folder / var / lib / asterisk / agi-bin, you need to create a qu.php script that is called from the macro and adds hints:
 #!/usr/bin/php <?php set_time_limit(0); require('phpagi.php'); $agi = new AGI(); $number = $agi->get_variable('AMPUSER'); $queue = $agi->get_variable('QUEUENO'); $hints_file = '/etc/asterisk/extensions_override_hints.conf'; $str = 'exten => *12'.$queue['data'].'*'.$number['data'].',hint,Custom:QS'.$queue['data'].$number['data']; $strsearch = 'QS'.$queue['data'].$number['data']; $fil = file_get_contents($hints_file); if ( !preg_match('~'.$strsearch.'~ism',$fil) ) { $fp = fopen($hints_file, "a+"); fwrite($fp, $str."\r\n"); fclose($fp); $agi->verbose('Exec reload'); system('/var/lib/asterisk/agi-bin/reload.sh'); } ?> 

And we also need a script, the launch of which overloads dialplan in asterisk. After all, it is not enough to add hint, you need to “distort” the dialplan. Put it here and call it reload.sh.
 #!/bin/sh /usr/sbin/asterisk -rx 'dialplan reload' 

Give it 733 rights.

Everything, it is possible to try to press the button on phone. When register it will not burn, but after the first click should change color to green. Additional settings asterisk and php is not required, the work of elastix scripts also do not affect.

')

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


All Articles