8

Asterisk has Asterisk Manager Interface (AMI) and Asterisk Gateway Interface (AGI), using which one can trigger PHP scripts at certain events from Asterisk. Using the same PHP scripts can also instruct Asterisk what to do next to a call/conference. Are there parallels to AMI and AGI in FreeSWITCH?

jeff musk
  • 1,032
  • 1
  • 10
  • 31
  • possible duplicate of [Asterisk vs FreeSwitch, are there parallels to AMI & AGI in FreeSWITCH](http://stackoverflow.com/questions/8662270/asterisk-vs-freeswitch-are-there-parallels-to-ami-agi-in-freeswitch) – jprofitt Dec 29 '11 at 00:33
  • @jprofitt because part of the previous question requested comparison between the scenarios where you would use Asterisk vs FreeSWITCH it got down voted, and closed. So now I posted this other half which has nothing to do with the comparison. – jeff musk Dec 29 '11 at 00:39

4 Answers4

10

These are good questions. I just wanted to add a few things to what @dkwiebe said (which is correct, BTW).

The AMI equivalent in FreeSWITCH is the event socket. (Technically it's not the "Event Socket Library" or ESL, which is an abstraction layer for writing programs that use the event socket. I just wanted to make that distinction.) In fact, the FreeSWITCH equivalent of "asterisk -r" is actually an ESL-based program called "fs_cli" - short for FreeSWITCH Command Line Interface. The fs_cli program is a great example of what you can accomplish with ESL.

Also, there is no reason that you cannot use an ESL program to do many of the things that can be done with AGI scripts. The ESL "connection object" can "lock on" to a single call leg and control it. There are examples on the wiki and the forthcoming FreeSWITCH Cookbook will have some recipes on the subject. (Full disclosure: I am a co-author of the FreeSWITCH Cookbook.)

Another ESL-related method of controlling calls like AGI is with the fs_ivrd daemon. It's less commonly used than ESL but is a nice option for AGI-like scripting. See this wiki page for more details.

Lastly, I would like to mention that Lua is a great choice for doing scripting/logic/etc. in call control. It is simple, light, and easy to learn. In the lab we've seen a few thousand concurrent Lua-controlled calls on an 8-core machine. Lua works even in some very demanding environments.

Feel free to join #freeswitch on irc.freenode.net to discuss your questions with the FreeSWITCH community.

Stephen
  • 1,737
  • 2
  • 26
  • 37
  • Thank you for such informative answers. In AGI I can write code in PHP and do not need to learn anything new for implementing logic. So the first question, using PHP scripts would still be an option instead of Lua? Second, if PHP is used instead of Lua how much overhead will it pose on the system? – jeff musk Jan 02 '12 at 19:23
4

There's a page on the FreeSWITCH wiki addressing most of these "Asterisk to FreeSWITCH" questions: Rosetta Stone.

hdiogenes
  • 729
  • 7
  • 15
3

AGI are for scripts used durring a call (i.e. called from dialplan durrign dialplan execution). Scripts that listen to the AMI and wait for events are standalone. While that latter, can, technically, do the former's job as well, you are much better off keeping them separate.

Mbrevda
  • 2,888
  • 2
  • 27
  • 35
  • I understand that part. I've been lately listening that FreeSWITCH is a better choice, and more reliable than Asterisk. Since I am using AMI and AGI currently, I wonder if there are parallels in FreeSWITCH for these two things. – jeff musk Dec 30 '11 at 06:27
  • For the distinction between AMI and AGI, I've never heard the use case for each split like that. Can you expand your answer, or cite a source? (Still learning Asterisk.) – Thufir Apr 02 '15 at 00:59
  • Agi's by their nature are kicked off by asterisk, during a call. There is no other way to initiate an agi script. On the other hand, you can start any script/process and have it connect to the AMI and take react to to events. Source: Core FreePBX developer for over half a decade. – Mbrevda Apr 02 '15 at 10:53
2

@dkwiebe has given the answer on serverfault- https://serverfault.com/a/345513/105376

For the AMI you're looking for the Event Socket Library. There are a few examples available on the mod_event_socket page.

AGI is a little different. You can do things similar in FreeSWITCH but they would recommend using lua. I've personally used the FreeSWITCH mod_perl with good results.

Community
  • 1
  • 1
jeff musk
  • 1,032
  • 1
  • 10
  • 31