bilal ghayyad
2012-Mar-10 20:27 UTC
[asterisk-users] AGI and retreiving data, how to use this data in extensions.conf
Hi All; I know that I can use the AGI to call (run) a script (php or python or any other kind of scripts), but the question is: If I have information that I need to build a decision in the extensions.conf based on it, and these informations can be obtained using this script, so how I will read these informations? What is the method to read it from the database and store it in a variable that I can use it in the extensions.conf to do proper call routing? How? Regards Bilal
Alex Balashov
2012-Mar-10 20:48 UTC
[asterisk-users] AGI and retreiving data, how to use this data in extensions.conf
Easiest thing is to have your AGI script set channel variables, which can be read in the dial plan. -- This message was painstakingly thumbed out on my mobile, so apologies for brevity and errors. Alex Balashov - Principal Evariste Systems LLC 235 E Ponce de Leon Ave Suite 106 Atlanta, GA 30030 Tel: +1-678-954-0670 Fax: +1-404-961-1892 Web: http://www.evaristesys.com/, http://www.alexbalashov.com On Mar 10, 2012, at 3:27 PM, bilal ghayyad <bilmar_gh at yahoo.com> wrote:> Hi All; > > I know that I can use the AGI to call (run) a script (php or python or any other kind of scripts), but the question is: > > If I have information that I need to build a decision in the extensions.conf based on it, and these informations can be obtained using this script, so how I will read these informations? What is the method to read it from the database and store it in a variable that I can use it in the extensions.conf to do proper call routing? How? > > > Regards > Bilal > > -- > _____________________________________________________________________ > -- 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
Eric Wieling
2012-Mar-10 20:51 UTC
[asterisk-users] AGI and retreiving data, how to use this data in extensions.conf
You would set a dialplan variable from inside your AGI. In PHPAGI it might be something this: $agi->set_variable("CUST_ID", $cust_id); Then in your dialplan after your script runs you can use the variable like any other. You can also get dialplan variables AND functions: $tmp = $agi->get_var("VMCOUNT(1234 at accounting)"); $vmcount = $tmp["data"]; -----Original Message----- From: asterisk-users-bounces at lists.digium.com [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of bilal ghayyad Sent: Saturday, March 10, 2012 3:27 PM To: asterisk-users at lists.digium.com Subject: [asterisk-users] AGI and retreiving data, how to use this data in extensions.conf Hi All; I know that I can use the AGI to call (run) a script (php or python or any other kind of scripts), but the question is: If I have information that I need to build a decision in the extensions.conf based on it, and these informations can be obtained using this script, so how I will read these informations? What is the method to read it from the database and store it in a variable that I can use it in the extensions.conf to do proper call routing? How? Regards Bilal -- _____________________________________________________________________ -- 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
Steve Edwards
2012-Mar-10 22:46 UTC
[asterisk-users] AGI and retreiving data, how to use this data in extensions.conf
On Sat, 10 Mar 2012, bilal ghayyad wrote:> If I have information that I need to build a decision in the > extensions.conf based on it, and these informations can be obtained > using this script, so how I will read these informations? What is the > method to read it from the database and store it in a variable that I > can use it in the extensions.conf to do proper call routing? How?We must be mis-communicating something. This is almost exactly the same question you asked a couple of days ago. Let's walk through what an example of what I think you are asking and see if it answers your questions. I have a system where calls are answered. The key piece of information at the start of the call is 'what number did the caller dial?' This is frequently (depending on what part of the world you are in) called the DID (Direct Inward Dial) or DNIS (Dialed Number Identification Service). For me, and the industries I work in, it's DNIS. When a call is received, Asterisk saves the DNIS in the EXTEN channel variable and sends the call to the context (as defined in sip.conf), the exten ${EXTEN}, and the priority 1. In my dialplan, I save the ${EXTEN} channel variable in a new channel variable named DNIS so it will be obvious to 'the next guy' and it won't change as I bounce around from context to context in my dial plan. I invoke an AGI in the dialplan using: agi(lookup-dnis,${DEBUG-MODE}) Where DEBUG-MODE is a global variable set in the [globals] section of extensions.conf to either be '--debug' or '--null.' (My AGIs always use the 'getopt_long()' function to parse the command line.) This AGI reads the DNIS channel variable using (via a library) the AGI command 'get variable' and save it in a variable curiously named 'dnis' in my AGI compliant application. My AGI uses the dnis to retrieve a row from my CLIENTS, DNISES, RECIPES and STEPS tables using (via a library) the MySQL function 'mysql_query("select ... from ... where ...").' The retrieved row contains a bunch (up to about a hundred) of columns, most of which my AGI sets as channel variables. Now the cruft from the database is available to the rest of my dialplan and my AGI exits. Back in my dialplan, I use those channel variables like these AEL snippets: set(LANGUAGE()=${INITIAL-LANGUAGE}); set(RECORDING-PATH=/tmp/${CLIENT-ID}/${CALL-ID}/); system(mkdir --parents ${RECORDING-PATH}/tmp/); if ("COMPLIANT" = "${PROMPT-RECORDING-MODE}") { MONITOR_EXEC="/scripts/compliant-mixer.sh"; MONITOR_EXEC_ARGS="COMPLIANT OUT"; }; // note the 'nested expansion' in the next channel variable switch (${STEP-${IDX}-TYPE}) { case AGENT-ID: verbose(1,AGENT-ID); agi(agent-id,${DEBUG-MODE},${TEST-MODE},${VERBOSE-MODE}); break; case BRANCH: verbose(1,BRANCH); agi(branch,${DEBUG-MODE},${TEST-MODE},${VERBOSE-MODE}); IDX=0$[ ${IDX} - 1 ]; break; At the end of the call (in the 'h' extension), I invoke another AGI ('finish-call') which reads various channel variables and writes them into a 'CDR-ish' table which is used to create reports and billing statements. Does this 'cover the bases?' -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000
Steve Edwards
2012-Mar-10 23:06 UTC
[asterisk-users] AGI and retreiving data, how to use this data in extensions.conf
On Sat, 10 Mar 2012, Steve Edwards wrote:> The retrieved row contains a bunch (up to about a hundred) of columns, mosts/row/rows/ -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000