Running AGI script in Queue Application - Playing a file whe

Asterisk always have something to learn . Yesterday one of my customers had a request to assign a number to his queue members and when the caller connects to one them he should hear the queue member assigned number . I knew I should work on MEMBERINTEFACE and MEMBERNAME variables but It can not be done in dialplan because it should run when the queue application is running . The solution is that we can run AGI script in Queue application in asterisk and this is how we can configure asteirsk to use theses variables and a simple agi script .

Queue(queuename,[options,[URL,[announceoverride,[timeout,[AGI,[macro,[gosub,[rule,[position]]]]]]]]])

  • First of all if you want to use MEMBERINTEFACE and MEMBERNAME variables you should set the setinterfacevar to yes in queues.conf or if you configured realtime asterisk you should set the filed to 1 in queues_member_table :

update queue_table set setinterfacevar = ‘1’ where name = ‘queuename’ ;

  • Now you can run an agi script in queue application and using the variables in your agi script .

exten => 1, NoOP("Test agi to play a file when caller connects queue member " )
same => n,Queue(queuename,t,1000, agentnum.php)

  • here Im using PHPAGI library to write a simple script to show how can you access the queue member interface and name in agi script .

#!/usr/bin/php -q

<?php require('phpagi.php'); $agi = new AGI(); $member=$agi->get_variable("MEMBERINTERFACE"); $member_name = $agi-> get_variable("MEMBERNAME"); $clid = $agi->request['agi_callerid']; error_reporting(E_ALL); // only in development environment set_time_limit(30); require('phpagi.php'); $agi = new AGI(); $clid = $agi->request['agi_callerid']; $member=$agi->get_variable("MEMBERINTERFACE"); $member_name = $agi-> get_variable("MEMBERNAME"); $agi->verbose("Member is $member[data]"); $agi->verbose("Member is name is $member_name[data]"); $agi->verbose("Calling number is $clid" ) ?>

omid-mohajerani.blogspot.com/