Capturing DNIS for AGI

The end result is:
I’m wanting a webpage popup for the number dialed (of incoming calls). This is for a Call Center so agents have instructions on how to answer the phone.

Specifically, I’m looking at how the popups work with Sugar/vTiger, and wanting to modify it so the CallerID being relayed is actually the DNIS.

Here’s an example of what I see coming in:

AGI Tx >> agi_request: ident.agi
AGI Tx >> agi_channel: Local/[email protected],2
AGI Tx >> agi_language: en
AGI Tx >> agi_type: Local
AGI Tx >> agi_uniqueid: 1208534049.1638
AGI Tx >> agi_callerid: 5551234567
AGI Tx >> agi_calleridname: MYCALLERIDTEXT
AGI Tx >> agi_callingpres: 0
AGI Tx >> agi_callingani2: 0
AGI Tx >> agi_callington: 0
AGI Tx >> agi_callingtns: 0
AGI Tx >> agi_dnid: unknown
AGI Tx >> agi_rdnis: unknown
AGI Tx >> agi_context: from-internal
AGI Tx >> agi_extension: 240
AGI Tx >> agi_priority: 2
AGI Tx >> agi_enhanced: 0.0
AGI Tx >> agi_accountcode:

Now… I can imagine this a couple different ways.

1.) Set the accountcode to DNIS in dialplan - how?
2.) Get agi_dnid/agi_rdnis defined (as in, not unknown)

Any and all help is much appreciated!

  • J

FreePBX sets the inbound did to FROM_DID so you can just pull that out of the channel.

Can you explain how or know of any example on how to pull that out of the channel into an AGI script?
(I’ve gone through agi-bin and searched for FROM_DID and AGI in the forums, but all I get are a bunch of CLI outputs)

As far as I know in FreePBX, accountcode is tied to extensions… is it possible to set that input on the inbound route, or would we be undermining its use? (We also use Guru’s Queuestats for reporting)

Right now, this is what I’m sitting on (in vTiger, ident.agi):

#!/usr/bin/perl -w

use LWP::Simple;
use Asterisk::AGI;

$AGI = new Asterisk::AGI;
my %input = $AGI->ReadParse();  #Read in the initial data

my $id = $input{"callerid"};
my $ex = $input{"extension"};

$id =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
$ex =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;

my $url = 'http://localhost/crm/asterisk/call_ident.php?callerid=' . $id . '&extension=' . $ex;
use LWP::Simple;
my $content = get $url;

I really appreciate the help,

  • J

look in dialparties.agi, there’s a function in there that pulls out channel variables and several examples of various channel variables that are being accessed.

That was very helpful… thanx so much for your help.

I’ll say that the agi for vTiger is written in perl, while dialparties.agi is written in php (better imho)… so that took me a second to digest, but it set me on the right track! I’ve still got a whole lot of adding/modifying to the plugin to do (lots of work), but I’ve tested it succesful… now pulls up contacts based on dnis (nod cid), w00t!

For those interested, this is what got it going:


And this is what you’ll see in CLI (so you know it’s working):

AGI Tx >> 200 result=1 (5551234567)

Thanx again!

  • J