Phpagi how to use in freepbx 2.10

Hello.
Freepbx 2.10 installed (it was downloaded linux distributive with freepbx).
Found simple sample of a script - http://www.elastix.org/component/kunena/117-asterisk-a-programming/38062-a-very-simple-phpagi-example.html

But can’t find info about how to use it in freepbx. Generaly information is about how to use it in plane asterisk.

I have the following settings in my freepbx - http://awesomescreenshot.com/03e15lgnb8

As I understood, I ought to put agi-script to “basedir” from settings above. Then I should to call it somehow. I suppose that I need to create Extension, but when I create it here - http://awesomescreenshot.com/0bd15lh6fa - there is no any mentions of agi.

Help me to move from one’s place, please.

PHPAGI module in FreePBX is to configure the location of AGI interfaces that FreeP BX uses internally.

If you wish to have your own AGI script interact with the dial plan you to to use the custom applications or custom destination module as best suits your needs.

Thanks for answer.

So, if I put some script to the configured location I can somehow make FreePBX to use in internally or I can use only already existing scripts in the loacation?

Goal:
What do I need? Want to get caller’s number -> work with billing system by this number -> depending on conditions wether to do or not so something (send to specific IVR menu, read some text [text2speech], etc.)

What way is the most suitable for me?

What exactly I need to understand? Little model.
I want to make script, that take “0” or “1” from a db (PHP, of course), then sends me to a specific IVR or read (text2speech) “Hello world”.

I have script. What next do I have to do? How and from where I can call a script in folder (basedir)?

I already answered your question, you don’t use the PHPAGI module, you hook into your own code with custom destination/application.

Custom code goes in extensions_custom.conf Asterisk dial plan extensions are very well explained as is how to hook the FreePBX dial plan, in our wiki.

Could you give me a link, please.
Found nothing here - http://wiki.freepbx.org/ :frowning:

Looks like this has not made it over to the new wiki yet, sorry about that:

http://www.freepbx.org/configuration_files

That is audacious, you need to study and learn how to do it yourself.

So…
I need to do injection to dial plan of asterisk, and then restart it?

Sorry for my audacity, but could you tell me step-by-step what to do. I just need to connect threads.

  1. Script, which has one var $x = 1, and condition if ($x==1){play number “123”}else {go to extension “ext”}.
  2. where to put it and how to call it.

I’m trying ).
I found nothing about the thing I need in the link above. (

The link simply shows you where to put your code. You need to learn how to program in Asterisk extension language to evaluate the variables as you intend.

Found something…
I use “etc/asterisk/extensions_custom.conf”. Added there a new context:

[sample1]
exten => s,1,Answer()
exten => s,n,Playback(Greet)
exten => s,n,Hangup()

“Greet” is a name of record I’ve created in “Admin -> System recordings”. Then I registered this context in FreePBX (Admin -> custom destinations) under the name “sample,s,1”, description - “testing of agi 1”. Then set “testing of agi 1” as a destination in my inbound route. Not working (

How can I restart feePBX from its interface?

Sorry. Mistake is mine. Wrong name - sample,s,1

How can I restart feePBX from its interface?

So, using “etc/asterisk/extensions_custom.conf” can I do what I need?

Next. I should put my script to “/var/lib/asterisk/agi-bin/”, then I need to add “exten => s,n,AGI(testphp.php)” in my context (which is above). Am I wright?
Where do I need to put php agi class form here - http://phpagi.sourceforge.net/? How can I figure out what version do I need?

I don’t know what you mean restart FreePBX? FreePBX itself does not have services running.

If you are asking how to do a gracefull load of Asterisk so it reads your changes use the Asterisk CLI and command ‘dialplan reload’ you can do that with any module ‘sip reload’ for example.

I found out how agi works.
Next problem - text2wave doesn’t seems to be working.

[2013-04-18 15:48:07] WARNING[6755]: file.c:698 ast_openstream_full: File /var/spool/asterisk//tmp//text2wav_8b1a9953c4611296a827abf8c47804d7 does not exist in any format
– <SIP/xxx>AGI Script xxx.agi completed, returning 0

Script is very simple.

require_once “phpagi.php”;
require_once(‘phpagi-asmanager.php’);

$agi = new AGI();

set_time_limit(60);
ob_implicit_flush(false);
error_reporting(1);

$agi->answer();
$agi->say_digits(“345”);
$agi->text2wav(“Hello”);