Calling an External Script from the Dialplan
From Etel
Contents |
[edit]
Calling an External Script from the Dialplan
[edit]
Problem
You want to call an external script from the dialplan to process a call using a third party library and scripting language.
[edit]
Solution
Adding these lines to your extension.conf in /etc/asterisk:
[oreilly] exten => _X.,1,AGI(hello_world.php)
And this script to /var/lib/asterisk/agi-bin/:
#!/usr/local/bin/php -q
<?php
set_time_limit(0);
require('phpagi.php');
$agi = new AGI();
$agi->answer();
// Play the tt-monkeys file from /var/lib/asterisk/sounds
$agi->stream_file('tt-monkeys');
$agi->hangup();
?>
Would result in this being executed by Asterisk and the audio 'tt-monkeys' being played from /var/lib/asterisk/sounds/:
-- Executing [123@oreilly:1] AGI("SIP/3000-01828e00", "hello_world.php") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/hello_world.php
-- Playing 'tt-monkeys' (escape_digits=) (sample_offset 0)
-- Spawn extension (oreilly, 123, 1) exited non-zero on 'SIP/3000-01828e00'
[edit]
Discussion
Coming soon...
[edit]
See Also:
- Asterisk AGI - http://www.voip-info.org/wiki-Asterisk+AGI
- PHPAGI - http://phpagi.sourceforge.net/ (used for this recipe)
- Other third party libraries
- Adhearsion (Ruby) - http://www.adhearsion.com
- Asterisk.Net - http://www.gotdotnet.com/codegallery/codegallery.aspx?id=7948963b-7a3b-4303-9118-da800f4f84c3
- Asterisk-Java - http://www.asteriskjava.org/latest/
- Perl - http://asterisk.gnuinter.net/
- Python - http://py-asterisk.berlios.de/py-asterisk.php
[edit]
Metadata
- By: Jason Goecke
