I think I need AGI for this to work?

Say I sell tires.
Some people get better rates on the tires that call me then others.

When they call in, the telephone system will know thier number via CID, or they will input a 5 digit customer number or something.
It will then grab thier information from a database (dont have one yet so this can be whatever) and pop it up on the computer screen.

Can you guys give me some tips and pointers on where to start at on this?
Like would the dB be stored on the Asterisk server, is thier something like this already developed that I would mod, etc…Ive never worked with the AGI so please keep that in mind.

Thank you,

Matthew

Time to learn AGI’s. If you know php it should not be an issue.

cool so it sounds like this is going to be a PHP job?

Ive worked with some php so that helps at least.

What if when someone called in it asked them to enter thier customer number. After they entered it and presssed #, it would ring the person they were calling, when that person answerd the phone it would read the number the entered, then it would connect them. That seems like simple dialplan work correct?

Once you get the hang of PHP and agi’s in asterisk it is not that hard to do.

You can get the data from the user and then play it to the person that picked up the call and then bridge the call. I would use a macro with the M option.

This should work for you:
${EXTEN} is the value that they enterd
${REP_TO_CALL} would be where you want to call (e.g. SIP/101&SIP/102)

Exten => s,1,Playback(please enter number)

Exten => _X.,1,Macro(call_rep,${EXTEN},${REP_TO_CALL})

[macro-call_rep]
exten => s,1,Wait(0.2)
exten => s,2,Playback(pls-wait-connect-call)
exten => s,3,Dial(${ARG2}|30|mtM(screen^${ARG1}))

[macro-call_rep2]
exten => s,1,Wait(0.2)
exten => s,2,Playback(number for caller is)
exten => s,3,Saydigits(${ARG1})
exten => s,4,Noop("")

ahh man I cant believe you wrote this for me thanks!
The problem is I just now read it, not sure why I hadn’t seen it before…
I wrote something basicly identical to that except with one argument/macro.

Since my last post in this thread, I installed apache/sql/php on my laptop and I created a dB. Ive got a php file wrote with a form(text box and submit button) that I can ADD new rows (or modify/delete rows/data for that matter)

I think now if i pass the digits that they enter (thier account number) to the php script, i can then run a query of that account number and echo the needed results up on the screen.
Cool! Its amazing how much you can learn in 4 hours on google lol.

Questions:
1: do i need to have the apache/sql/php on the asterisk server or can it just be on a windows box?
2: i think the big part i dont understand is, when they enter the digits, and it sends it to the php script, how am i going to make it pop up IE or whatever on thier screen with thier account information? The submit button usually does this, is the asterisk AGI like a submit button I assume? I dont see how that will work on the clients computer…

any guidance here please? thanks!

  1. You can use any machine for it. It does not need to be locally.
  2. I never created something to display on a reps phone so I can not say for sure. Maybe you can have something connected to the AMI. When a specific rep gets a cal maybe send a “trigger” to a program running on their desktop that opens up with their info. Or work with the AMI and if user 123 gets the call on user 123’s desktop have IE open and load the information (have the browser on auto refresh till there is data to out put).

well i spent all night reading about asterisk agi implementing with php.
and i will say, that is confusing to me still.

I looked up this AMI briefly, that seems a lot simpler from the little I just read (on the wiki’s)
Ill dig deeper into this weekend and see if I can make something work :smiley: Ill post back.

Thanks Dovid

ok ive been reading and reading and reading.

In my extensions.conf I can set globalvar(NUMBERVAR = 1234).
Then in firefox i can go to:
192.168.3.44/rawman?action=GetV … =NUMBERVAR

and i can view that NUMBERVAR in rawman format (text)
cool, but i have to look up the channel in the CLI to do that, (SIP/100-082214a0) so that really isnt helpful to me.

I got a apache/php/mysql server running on a different computer then the asterisk. On that i got my php that is integrated with the mysql. If i can get the NUMBERVAR variable over to my php script I can do all sorts of things.

im stuck please help me ive read everything ajam, phpagi, agi, api, ami, whatever it is ive probably read it and most of it is confusing to me. I dont know linux that great so i want to keep the apache/php/mysql on windows…

I’m also stuck with something like this. How do I pass DTMF codes from Asterisk to a PHP script. I’m quite fluent in PHP so any DB lookups and data manipulation is fine for me but being able to see what DTMF codes were entered by the user is what I’m struggling with.

Gathering from Google I think I need to use the ‘get data’ function but nowhere seems to show me where I use this and also how I pass the values from that into a PHP script.

Any help appreciated.

What exactly are you tried to accomplish?

Ive probably looked at basicly all scenarios of integrating asterisk with external applications I can probably give you some advice.
Im currently messing with OrderlyCalls, its Java (not javascript), I think this is the way to go if wanting to interact with an external application.
Then again what do I know I have figured it out yet lol.

As I’m learning how Asterisk works my self-set task was to make a call to myself and allow me to enter a DTMF code and then insert that code into a database. But I wanted to pass the DTMF code to a PHP script and allow that to handle the inserting into a database. PHP is the only language I’m fluent in so Java is out of the question for me, sorry.

ok is the database and php going to be on the asterisk server?
what type of database?

You will first need to get the input digits from the caller and and store it as a variable. You can see how to do this in one of my last 4-6 posts in here.

You will of course then be passing that variable (which will be a channel variable most likely) to your php script.

exten => 400,n,AGI(my-agi-script.php|12345)

the 12345 here is the variable you will want to pass. So you can delete 12345 and put in ${YOURvariableNAME}

It will be the first $argv in your PHP script that is passed.

Sounds like you dont need any PHP help from thier, good because im still new at php :smiley:

If you have any questions I will explain in more detail. If your dB and php is on another server then I can help on that also. You would use FastAGI in that scenario.

You are basicly doing what i was trying to do, except when someone called in, and recorded a number, i wanted to take that number, run a querry on a mySQL database then on the persons computer pop up that querry on thier screen…i haven’t figured out how to do it yet, but it seems OrderlyCalls can do it…

phpagi.sourceforge.net/

is a phpclass for asterisk agi so many of these task can be called with function calls
I think you are looking for this:

//promt the user to enter some data and get a result
$option1ar = $agi->get_data(‘someaudiofile’, 3000, 1);

//the result is ??? now you have your DTMF IN A PHP VARIABLE
$option1 = $option1ar[‘result’];

// you can keep going and create some ifs
if ($option1 == 1 ) {
somefuntion();
}
elseif ($option1 ==2) {
someotherfunc();
}
else {
die();
}

basically for something simple like this the phpagi class makes it EASY to do
and please note I have OMITTED the setup of $agi this is assuming you read the phpagi documentation.

[quote=“ste.richards”]I’m also stuck with something like this. How do I pass DTMF codes from Asterisk to a PHP script. I’m quite fluent in PHP so any DB lookups and data manipulation is fine for me but being able to see what DTMF codes were entered by the user is what I’m struggling with.

Gathering from Google I think I need to use the ‘get data’ function but nowhere seems to show me where I use this and also how I pass the values from that into a PHP script.

Any help appreciated.[/quote]