[asterisk-users] queue command in asterisk 1.4 with macro-argument
Jim Dickenson
dickenson at cfmc.com
Wed Jun 30 10:55:43 CDT 2010
Here is a simple AGI using cagi that creates a user event when a call is connected with a queue member:
#include <stdio.h>
#include <stdarg.h>
#include "cagi.h"
int main (int argc, char *argv[]) {
AGI_TOOLS agi;
AGI_CMD_RESULT res;
int rtn;
char channel_name[200], uniqueid[200], Interface[200], Event[1000];
rtn = AGITool_Init(&agi);
// rtn = AGITool_verbose(&agi, &res, AGITool_ListGetVal(agi.agi_vars,
// "agi_request"), 0);
// sprintf(Event, "Do verbose= %d", rtn);
// AGITool_verbose(&agi, &res, Event, 0);
rtn = AGITool_get_variable2(&agi, &res, "CHANNEL",
channel_name, sizeof(channel_name));
// sprintf(Event, "Get CHANNEL = %d", rtn);
// AGITool_verbose(&agi, &res, Event, 0);
rtn = AGITool_get_variable2(&agi, &res, "UNIQUEID",
uniqueid, sizeof(uniqueid));
// sprintf(Event, "Get UNIQUEID = %d", rtn);
// AGITool_verbose(&agi, &res, Event, 0);
rtn = AGITool_get_variable2(&agi, &res, "MEMBERINTERFACE",
Interface, sizeof(Interface));
// sprintf(Event, "Get MEMBERINTERFACE = %d", rtn);
// AGITool_verbose(&agi, &res, Event, 0);
sprintf(Event, "DidQueue|\"%s & %s & %s"", uniqueid, channel_name, Interface);
rtn = AGITool_exec(&agi, &res, "UserEvent", Event);
// sprintf(Event, "Do UserEvent = %d", rtn);
// AGITool_verbose(&agi, &res, Event, 0);
AGITool_Destroy(&agi);
return 0;
} /* main */
--
Jim Dickenson
mailto:dickenson at cfmc.com
CfMC
http://www.cfmc.com/
On Jun 30, 2010, at 8:31 AM, Jonas Kellens wrote:
> Taking my first steps into AGI then :
>
>
> [root at asterisk agi-bin]# cat sample.agi
> #!/usr/bin/php -q
> <?php
> $MYSQLSERVER2="localhost";
> $MYSQLUSER2="user";
> $MYSQLPASSWD2="passwd";
>
> set_time_limit(30);
> require('phpagi/phpagi.php');
> $agi = new AGI();
>
> $db=mysql_connect("$MYSQLSERVER2", "$MYSQLUSER2", "$MYSQLPASSWD2");
> mysql_select_db(Asterisk, $db);
>
> $QUERY="SELECT vmcontext FROM AstDB WHERE ID='40'";
> $agi->verbose("query is: $QUERY", 3);
> $result=mysql_query($QUERY);
> $VMCONTEXT=mysql_fetch_array($result);
> $agi->verbose("VMCONTEXT is: $VMCONTEXT", 3);
> $vmcontext=$VMCONTEXT['vmcontext'];
>
> $exten = $agi->request['agi_extension']; //Dialed extension
> // the result is stored in $exten
> $agi->verbose("variable exten : $exten", 3);
> $agi->verbose("variable vmcontext : $vmcontext", 3);
> //
> ?>
>
>
> [Jun 30 17:26:04] -- Executing [123 at test:3] AGI("SIP/test-00000054", "sample.agi") in new stack
> [Jun 30 17:26:04] -- Launched AGI Script /var/lib/asterisk/agi-bin/sample.agi
> [Jun 30 17:26:04] -- sample.agi: query is: SELECT vmcontext FROM AstDB WHERE klantID='40'
> [Jun 30 17:26:04] -- sample.agi: VMCONTEXT is:
> [Jun 30 17:26:04] -- sample.agi: variable exten : 123
> [Jun 30 17:26:04] -- sample.agi: variable vmcontext :
> [Jun 30 17:26:04] -- AGI Script sample.agi completed, returning 0
>
>
> Does AGI not interpret my query correctly ? As there is no output for $vmcontext...
>
>
>
> Jonas.
>
>
> On 06/30/2010 04:54 PM, Jim Dickenson wrote:
>>
>> Yes it gets called when the call is connected to a queue member.
>>
>> In version 1.4.x you can execute an AGI instead of a sub or macro.
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> New to Asterisk? Join us for a live introductory webinar every Thurs:
> http://www.asterisk.org/hello
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20100630/17855ba7/attachment.htm
More information about the asterisk-users
mailing list