Run an AGI Script from IVR?

Hi All.
I have written an AGI script that is intended to be run from an IVR.
The idea is, someone rings in, they may go to the IVR, press 2 for support, then at that stage I want it to go to an AGI script.
Can anyone suggest how I can do this?

Thanks, Jeremy

Check out the Dialplan Injection module…

http://www.freepbx.org/support/documentation/module-documentation/third-party-unsupported-modules/dialplan-injection

Once installed, you can use a Dialplan Injection as an IVR destination (any injection you create will appear as a selectable destination in your IVR menus). So make an injection with code similar to this:

Ringing
AGI(yourscript.agi)
GotoIf($["x${IVR_CONTEXT}" = "x"]?app-blackhole,hangup,1:${IVR_CONTEXT},return,1)

The last line returns the caller to the IVR from whence he came, so he can make another selection, or hangs up if it’s an internal (non-IVR) call - you can modify it to suit your needs.

The alternaive is to put the code that calls the AGI in extensions-custom.conf. I personally prefer using a Dialplan Injection, it makes it a bit easier especially if you are using several such custom code fragments.

Ok, thanks for that. I have installed it, and will try to get back to it thru the day, and let you know how I get on.

Jeremy

hmmm…hit a small snag.
It appears that it didnt run the following SQL as part of the install process. I ran the below manually, and it now seems to create a dial plan injection item, where it didnt before.
I am running FreePBX version 2.4.xx as part of a Trixbox install…Jeremy


– Table structure for table dialplaninjection_dialplaninjections

CREATE TABLE IF NOT EXISTS dialplaninjection_dialplaninjections (
id int(11) NOT NULL auto_increment,
description varchar(100) NOT NULL default ‘’,
destination varchar(250) NOT NULL default ‘’,
exten varchar(10) default NULL,
PRIMARY KEY (id),
UNIQUE KEY description (description),
UNIQUE KEY exten (exten)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;


– Table structure for table dialplaninjection_module

CREATE TABLE IF NOT EXISTS dialplaninjection_module (
id varchar(50) NOT NULL default ‘’,
value varchar(100) NOT NULL default ‘’,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


– Dumping data for table dialplaninjection_module

INSERT IGNORE INTO dialplaninjection_module VALUES (‘modulerawname’, ‘dialplaninjection’);
INSERT IGNORE INTO dialplaninjection_module VALUES (‘moduledisplayname’, ‘Dialplan Injection’);
INSERT IGNORE INTO dialplaninjection_module VALUES (‘moduleversion’, ‘0.1.1’);

Ok, it seems to work now :slight_smile:
I have got it to almost work as I want it too !!

Jeremy

I’m not sure why you had trouble with the Dialplan Injection installation, except that it was created for an earlier version of FreePBX (and not specifically for use with Trixbox) - I don’t know why any of that would make any difference, but doesn’t matter as long as you got it working. I usually find that the difficult part is not calling the AGI, but in getting the code inside the AGI to do what I want it to do, given that I’m really not a programmer and have a lot of difficulty understanding all but the simplest code. Anyway, hope you’re able to figure out the rest of it!

Luckly I “am” a programmer in real life, which was prob. what helped figure out the issue :slight_smile: The whole AGI side of things has taken me a bit to work out, but I am getting there.

Basically, all I need to do is verify a customer code and then either hang up or move to an other IVR, and this works noww.

How ever, what WOULD be nice, would be the ability to call a specific IVR based on a response back from the AGI script.
For example, the user puts in a code, but their code has expired, it woudl be nice to be able to point them to a different IVR.
I dont know if this can do that already or not tho. Anyone know?

Jeremy

sounds like you got it done, but you might also be interested in this
http://trixbox.org/forums/trixbox-forums/open-discussion/intelligent-call-routing-and-crm-integration

http://trixbox.org/wiki/database-integrated-dial-plans

hmm…now i wonder if I have done this the right way…hehehehe

I did spot one thing in the dial plan from the document the guy wrote here http://trixbox.org/wiki/database-integrated-dial-plans was that he changes a variable in the AGI, and based on that I should be able to do what I am wanting to do…or so the theory goes.

Interestingly enough, a couple of weeks back I was in Australia at CeBit where we attended a VoIP conference where the CEO of Fonality in Australia (if I am still allowed to say that name here) (who also write Suger CRM) was talking about how they already had what the guy in the above links was wanting to do with Surger CRM, and had had for a while.
Fortunitly its Saturday here, so I have some time to have a good play with the code :slight_smile:

Jeremy

Nerd Vittles also has a number of apps that pass data back and forth from dialplans and AGI scripts. You might take a look at the TeleYapper code to get some ideas.