I would implement it in a different way.<br>As you seem to be a seasoned player just a hint here.<br>How about adding local channels as queue members and executing agi in local channel context before actual dial()?<br>Only limitation is, AGI will get executed for each dial irrespective of whether an extension rings or not. But at least you can identify which extension is being dialed. <br>
See &#39;Using Local Channels&#39; on <a href="http://ofps.oreilly.com/titles/9780596517342/asterisk-ACD.html">http://ofps.oreilly.com/titles/9780596517342/asterisk-ACD.html</a><br><br>--Satish Barot<br><br><div class="gmail_quote">
On Wed, Apr 11, 2012 at 2:45 AM, Todd Routhier <span dir="ltr">&lt;<a href="mailto:fonemasta@gmail.com">fonemasta@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks again Danny, Perl was the first thing I tinkered with back in the 90&#39;s but haven&#39;t messed with it for years.<div><br></div><div>Looking over what you sent, I get about 90% of what&#39;s going on there. With a little searching and brushing up on my Perl, I think I will be able to make this work.</div>

<div><br></div><div>This is a good solution and, if I can get this to work, I won&#39;t even need the AGI. I can basically just hit what I need using CURL within the Perl script (I think).</div><div><br></div><div>All the AGI was going to do for me is hit a URL with some parameters out on the Internet. So, pretty sure I can do all that within the Perl Script and leave AGI out of it completely.</div>
<span class="HOEnZb"><font color="#888888">
<div><br></div></font></span><div><span class="HOEnZb"><font color="#888888">--Todd</font></span><div><div class="h5"><br><br><div class="gmail_quote">On Tue, Apr 10, 2012 at 4:02 PM, Danny Nicholas <span dir="ltr">&lt;<a href="mailto:danny@debsinc.com" target="_blank">danny@debsinc.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div link="blue" vlink="purple" lang="EN-US"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Were this my task, I would do a PERL/C daemon to run the AGI.  This is how I do it in PERL<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">   my $astman = new Asterisk::Manager;<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">    $astman-&gt;user(&#39;user&#39;);<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">               $astman-&gt;secret(&#39;secret&#39;);<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">               my $man_addr=&#39;127.0.0.1&#39;;<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">&lt;this section is for if your asterisk isn’t on 127.0.0.1&gt;<u></u><u></u></span></p><p class="MsoNormal">

<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">               my $man_ok=1;<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">               open (my $man_in, &quot;/etc/asterisk/manager.conf&quot;) or $man_ok=undef;<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">               if ($man_ok) {<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">                  while (&lt;$man_in&gt;) {<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">                     if ($_ =~ /^bindaddr/) {<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">                        (undef,$man_addr) = split /\=/, $_;<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">                        }<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">                     }<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">                  close $man_in;<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">                  }<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">               $man_addr =~ s/\s//g;<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">&lt;untaint&gt;<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">               ( $man_addr )=( $man_addr =~ /(.*)/ );<u></u><u></u></span></p><p class="MsoNormal">
<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">&lt;end of reassign section&gt;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">               $astman-&gt;host($man_addr);<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">               $astman-&gt;connect || die &quot;Could not connect to &quot; . $astman-&gt;host . &quot;!\n&quot;;<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">               my %resp = $astman-&gt;sendcommand(  Action =&gt; &#39;Originate&#39;,<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">                                                           Channel =&gt; $extval,<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">                                                           Variable =&gt; &quot;ARG1=$fileval&quot;,<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">                                                           Exten =&gt; $extval,<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">                                                           Context =&gt; &#39;playit&#39;,<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">                                                           priority =&gt; 1,<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">                                                           Number =&gt; 5551212<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">                                                           );<u></u><u></u></span></p><p class="MsoNormal">

<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">&lt;loop through %resp and find desired value; launch AGI&gt;<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">               sleep 2;<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">               %resp = $astman-&gt;sendcommand(  Action =&gt; &#39;Logoff&#39;);<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> <a href="mailto:asterisk-users-bounces@lists.digium.com" target="_blank">asterisk-users-bounces@lists.digium.com</a> [mailto:<a href="mailto:asterisk-users-bounces@lists.digium.com" target="_blank">asterisk-users-bounces@lists.digium.com</a>] <b>On Behalf Of </b>Todd Routhier<br>

<b>Sent:</b> Tuesday, April 10, 2012 3:55 PM</span></p><div><br><b>To:</b> Asterisk Users Mailing List - Non-Commercial Discussion<br></div><b>Subject:</b> Re: [asterisk-users] Run AGI while agent ringing instead of only when connected<u></u><u></u><p>

</p><div><div><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Yes Sir.. Studied it pretty hard, did I miss a solution? Trust me, been at this for a number of years off and on, I never post unless I have dug hard, searching all the Asterisk resources I know of.<u></u><u></u></p>

<div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">This is where I got most of my info but the solutions mentioned on that page require the call to be &quot;Connected&quot; to the agent before the AGI fires. Once the agent is connected, I can get all sorts of info from Channel Vars. Still, once the agent is connected, it&#39;s sort of too late, I need the AGI to fire will the agent is ringing.<u></u><u></u></p>

</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal" style="margin-bottom:12.0pt">Thanks for your help so far.<u></u><u></u></p><div><p class="MsoNormal">On Tue, Apr 10, 2012 at 3:42 PM, Danny Nicholas &lt;<a href="mailto:danny@debsinc.com" target="_blank">danny@debsinc.com</a>&gt; wrote:<u></u><u></u></p>

<div><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">You have read this thread? <a href="http://www.voip-info.org/wiki/view/Asterisk+cmd+Queue" target="_blank">http://www.voip-info.org/wiki/view/Asterisk+cmd+Queue</a>                </span><u></u><u></u></p>

<div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> <a href="mailto:asterisk-users-bounces@lists.digium.com" target="_blank">asterisk-users-bounces@lists.digium.com</a> [mailto:<a href="mailto:asterisk-users-bounces@lists.digium.com" target="_blank">asterisk-users-bounces@lists.digium.com</a>] <b>On Behalf Of </b>Todd Routhier<br>

<b>Sent:</b> Tuesday, April 10, 2012 3:15 PM<br><b>To:</b> Asterisk Users Mailing List - Non-Commercial Discussion<br><b>Subject:</b> [asterisk-users] Run AGI while agent ringing instead of only when connected</span><u></u><u></u></p>

<p class="MsoNormal"> <u></u><u></u></p></div><p class="MsoNormal">What I am trying to accomplish is to run an AGI script each time an agent&#39;s line starts ringing. I currently have the AGI firing when the agent answers the call using the Queue command, something like queue(MyQueue,,,,,MyAgi.php). Works great but I need the AGI to run when the agent&#39;s phone starts ringing.<u></u><u></u></p>

<div><div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">Strangely, I can&#39;t find anything real useful on this after searching Google, this list, various Asterisk forums etc.<u></u><u></u></p>

</div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">Is this supported? If not, is there some other maybe not so supported way to accomplish this?<u></u><u></u></p></div><div><p class="MsoNormal">

 <u></u><u></u></p></div><div><p class="MsoNormal">I get how I can just fire an AGI from the dial plan but once I leave control to the queue, I can&#39;t really do that, I don&#39;t think.<u></u><u></u></p></div><div><p class="MsoNormal">

 <u></u><u></u></p></div><div><p class="MsoNormal">Thanks in advance for any help!<u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">--Todd<u></u><u></u></p></div><div><p class="MsoNormal">

 <u></u><u></u></p></div></div></div></div></div><p class="MsoNormal"><br>--<br>_____________________________________________________________________<br>-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank">http://www.api-digital.com</a> --<br>

New to Asterisk? Join us for a live introductory webinar every Thurs:<br>              <a href="http://www.asterisk.org/hello" target="_blank">http://www.asterisk.org/hello</a><br><br>asterisk-users mailing list<br>To UNSUBSCRIBE or update options visit:<br>

  <a href="http://lists.digium.com/mailman/listinfo/asterisk-users" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-users</a><u></u><u></u></p></div><p class="MsoNormal"><u></u> <u></u></p></div></div></div>

</div></div><br>--<br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank">http://www.api-digital.com</a> --<br>
New to Asterisk? Join us for a live introductory webinar every Thurs:<br>
               <a href="http://www.asterisk.org/hello" target="_blank">http://www.asterisk.org/hello</a><br>
<br>
asterisk-users mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
   <a href="http://lists.digium.com/mailman/listinfo/asterisk-users" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-users</a><br></blockquote></div><br></div></div></div>
<br>--<br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank">http://www.api-digital.com</a> --<br>
New to Asterisk? Join us for a live introductory webinar every Thurs:<br>
               <a href="http://www.asterisk.org/hello" target="_blank">http://www.asterisk.org/hello</a><br>
<br>
asterisk-users mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
   <a href="http://lists.digium.com/mailman/listinfo/asterisk-users" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-users</a><br></blockquote></div><br>