NAME

Twilio::TwiML::VoiceResponse - The Response element of TwiML

SYNOPSIS

use Twilio::TwiML::VoiceResponse;

my $response = Twilio::TwiML::VoiceResponse->new;
$response->say('Thanks for calling!', { voice => 'Polly.Joanna' });
my $gather = $response->gather(
  { input => [qw(dtmf speech)], action => '/menu', num_digits => 1 });
$gather->say('Press 1 for sales, or 2 for support.');
$response->redirect('/voice');

print "Content-Type: text/xml\n\n", $response;

# <?xml version="1.0" encoding="UTF-8"?>
# <Response><Say voice="Polly.Joanna">Thanks for calling!</Say><Gather action="/menu"
# input="dtmf speech" numDigits="1"><Say>Press 1 for sales, or 2 for
# support.</Say></Gather><Redirect>/voice</Redirect></Response>

DESCRIPTION

The root of the TwiML that tells Twilio what to do with a call. Return it from the webhook of a phone number, or pass it as twiml when you make a call. See Twilio::Manual for a whole webhook.

See Twilio::TwiML::TwiML for the methods every element has.

METHODS

new

my $element = Twilio::TwiML::VoiceResponse->new();

connect

my $child = $element->connect(\%attributes);

Add Connect child. Returns a Twilio::TwiML::Voice::Connect.

dial

my $child = $element->dial($number, \%attributes);

Add Dial child. Returns a Twilio::TwiML::Voice::Dial.

echo

my $child = $element->echo();

Add Echo child. Returns a Twilio::TwiML::Voice::Echo.

enqueue

my $child = $element->enqueue($name, \%attributes);

Add Enqueue child. Returns a Twilio::TwiML::Voice::Enqueue.

gather

my $child = $element->gather(\%attributes);

Add Gather child. Returns a Twilio::TwiML::Voice::Gather.

hangup

my $child = $element->hangup();

Add Hangup child. Returns a Twilio::TwiML::Voice::Hangup.

leave

my $child = $element->leave();

Add Leave child. Returns a Twilio::TwiML::Voice::Leave.

pause

my $child = $element->pause(\%attributes);

Add Pause child. Returns a Twilio::TwiML::Voice::Pause.

pay

my $child = $element->pay(\%attributes);

Add Pay child. Returns a Twilio::TwiML::Voice::Pay.

play

my $child = $element->play($url, \%attributes);

Add Play child. Returns a Twilio::TwiML::Voice::Play.

prompt

my $child = $element->prompt(\%attributes);

Add Prompt child. Returns a Twilio::TwiML::Voice::Prompt.

queue

my $child = $element->queue($name, \%attributes);

Add Queue child. Returns a Twilio::TwiML::Voice::Queue.

record

my $child = $element->record(\%attributes);

Add Record child. Returns a Twilio::TwiML::Voice::Record.

redirect

my $child = $element->redirect($url, \%attributes);

Add Redirect child. Returns a Twilio::TwiML::Voice::Redirect.

refer

my $child = $element->refer(\%attributes);

Add Refer child. Returns a Twilio::TwiML::Voice::Refer.

reject

my $child = $element->reject(\%attributes);

Add Reject child. Returns a Twilio::TwiML::Voice::Reject.

say

my $child = $element->say($message, \%attributes);

Add Say child. Returns a Twilio::TwiML::Voice::Say.

sms

my $child = $element->sms($message, \%attributes);

Add Sms child. Returns a Twilio::TwiML::Voice::Sms.

start

my $child = $element->start(\%attributes);

Add Start child. Returns a Twilio::TwiML::Voice::Start.

stop

my $child = $element->stop();

Add Stop child. Returns a Twilio::TwiML::Voice::Stop.

LICENSE

Copyright (c) 2026 Francisco Zarabozo. Released under the MIT License.