Skip to content

Instantly share code, notes, and snippets.

@cloudvoxcode
Created August 6, 2009 21:42
Show Gist options
  • Save cloudvoxcode/163581 to your computer and use it in GitHub Desktop.
Save cloudvoxcode/163581 to your computer and use it in GitHub Desktop.
Receive phone call with Perl
#!/usr/bin/perl
use Cloudvox;
# start Asterisk Gateway Interface (AGI) server on port 4573
Cloudvox->run(port => 4573);
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