Created
August 6, 2009 21:42
-
-
Save cloudvoxcode/163581 to your computer and use it in GitHub Desktop.
Receive phone call with Perl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use Cloudvox; | |
# start Asterisk Gateway Interface (AGI) server on port 4573 | |
Cloudvox->run(port => 4573); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Cloudvox; | |
# Cloudvox - answer and control a phone call with Perl | |
# Place and receive phone calls via open API: http://cloudvox.com/ | |
# Learn about call scripting, Asterisk/AGI, voice apps: http://help.cloudvox.com/ | |
use Asterisk::FastAGI; | |
use base 'Asterisk::FastAGI'; | |
# Example incoming call handler | |
# Answer call, prompt for digits, play them or speak error. | |
sub testapp_handler { | |
my $self = shift; | |
$self->agi->exec("Swift", "\"Thank you for calling Cloudvox. Enter a 6 digit number.\""); | |
$self->agi->exec("Read", 'pin||6|skip|2|10'); | |
$pin = $self->agi->get_variable("pin"); | |
$self->agi->exec("Swift", "\"You entered .\""); | |
if (length($pin) > 0) { | |
$self->agi->exec("SayDigits", $pin); | |
else { | |
$self->agi->exec("Swift", "Nothing at all!"); | |
} | |
} | |
return true; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment