Class: Twilio::TwiML::VoiceResponse

Inherits:
TwiML
  • Object
show all
Defined in:
lib/twilio-ruby/twiml/voice_response.rb

Overview

<Response> TwiML for Voice

Instance Attribute Summary

Attributes inherited from TwiML

#name

Instance Method Summary collapse

Methods inherited from TwiML

#append, to_lower_camel_case, #to_s, #xml

Constructor Details

#initialize(**keyword_args) {|_self| ... } ⇒ VoiceResponse

Returns a new instance of VoiceResponse.

Yields:

  • (_self)

Yield Parameters:



12
13
14
15
16
17
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 12

def initialize(**keyword_args)
  super(**keyword_args)
  @name = 'Response'

  yield(self) if block_given?
end

Instance Method Details

#dial(number: nil, action: nil, method: nil, timeout: nil, hangup_on_star: nil, time_limit: nil, caller_id: nil, record: nil, trim: nil, recording_status_callback: nil, recording_status_callback_method: nil, recording_status_callback_event: nil, answer_on_bridge: nil, ring_tone: nil, **keyword_args) {|dial| ... } ⇒ Object

Create a new <Dial> element

number

Phone number to dial

action

Action URL

method

Action URL method

timeout

Time to wait for answer

hangup_on_star

Hangup call on star press

time_limit

Max time length

caller_id

Caller ID to display

record

Record the call

trim

Trim the recording

recording_status_callback

Recording status callback URL

recording_status_callback_method

Recording status callback URL method

recording_status_callback_event

Recording status callback events

answer_on_bridge

Preserve the ringing behavior of the inbound call until the Dialed call picks up

ring_tone

Ringtone allows you to override the ringback tone that Twilio will play back to the caller while executing the Dial

keyword_args

additional attributes

Yields:



36
37
38
39
40
41
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 36

def dial(number: nil, action: nil, method: nil, timeout: nil, hangup_on_star: nil, time_limit: nil, caller_id: nil, record: nil, trim: nil, recording_status_callback: nil, recording_status_callback_method: nil, recording_status_callback_event: nil, answer_on_bridge: nil, ring_tone: nil, **keyword_args)
  dial = Dial.new(number: number, action: action, method: method, timeout: timeout, hangup_on_star: hangup_on_star, time_limit: time_limit, caller_id: caller_id, record: record, trim: trim, recording_status_callback: recording_status_callback, recording_status_callback_method: recording_status_callback_method, recording_status_callback_event: recording_status_callback_event, answer_on_bridge: answer_on_bridge, ring_tone: ring_tone, **keyword_args)

  yield(dial) if block_given?
  append(dial)
end

#echo(**keyword_args) ⇒ Object

Create a new <Echo> element

keyword_args

additional attributes



46
47
48
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 46

def echo(**keyword_args)
  append(Echo.new(**keyword_args))
end

#enqueue(name: nil, action: nil, method: nil, wait_url: nil, wait_url_method: nil, workflow_sid: nil, **keyword_args) {|enqueue| ... } ⇒ Object

Create a new <Enqueue> element

name

Friendly name

action

Action URL

method

Action URL method

wait_url

Wait URL

wait_url_method

Wait URL method

workflow_sid

TaskRouter Workflow SID

keyword_args

additional attributes

Yields:



59
60
61
62
63
64
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 59

def enqueue(name: nil, action: nil, method: nil, wait_url: nil, wait_url_method: nil, workflow_sid: nil, **keyword_args)
  enqueue = Enqueue.new(name: name, action: action, method: method, wait_url: wait_url, wait_url_method: wait_url_method, workflow_sid: workflow_sid, **keyword_args)

  yield(enqueue) if block_given?
  append(enqueue)
end

#gather(input: nil, action: nil, method: nil, timeout: nil, speech_timeout: nil, max_speech_time: nil, profanity_filter: nil, finish_on_key: nil, num_digits: nil, partial_result_callback: nil, partial_result_callback_method: nil, language: nil, hints: nil, barge_in: nil, **keyword_args) {|gather| ... } ⇒ Object

Create a new <Gather> element

input

Input type Twilio should accept

action

Action URL

method

Action URL method

timeout

Time to wait to gather input

speech_timeout

Time to wait to gather speech input and it should be either auto or a positive integer.

max_speech_time

Max allowed time for speech input

profanity_filter

Profanity Filter on speech

finish_on_key

Finish gather on key

num_digits

Number of digits to collect

partial_result_callback

Partial result callback URL

partial_result_callback_method

Partial result callback URL method

language

Language to use

hints

Speech recognition hints

barge_in

Stop playing media upon speech

keyword_args

additional attributes

Yields:



83
84
85
86
87
88
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 83

def gather(input: nil, action: nil, method: nil, timeout: nil, speech_timeout: nil, max_speech_time: nil, profanity_filter: nil, finish_on_key: nil, num_digits: nil, partial_result_callback: nil, partial_result_callback_method: nil, language: nil, hints: nil, barge_in: nil, **keyword_args)
  gather = Gather.new(input: input, action: action, method: method, timeout: timeout, speech_timeout: speech_timeout, max_speech_time: max_speech_time, profanity_filter: profanity_filter, finish_on_key: finish_on_key, num_digits: num_digits, partial_result_callback: partial_result_callback, partial_result_callback_method: partial_result_callback_method, language: language, hints: hints, barge_in: barge_in, **keyword_args)

  yield(gather) if block_given?
  append(gather)
end

#hangup(**keyword_args) ⇒ Object

Create a new <Hangup> element

keyword_args

additional attributes



93
94
95
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 93

def hangup(**keyword_args)
  append(Hangup.new(**keyword_args))
end

#leave(**keyword_args) ⇒ Object

Create a new <Leave> element

keyword_args

additional attributes



100
101
102
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 100

def leave(**keyword_args)
  append(Leave.new(**keyword_args))
end

#pause(length: nil, **keyword_args) ⇒ Object

Create a new <Pause> element

length

Length in seconds to pause

keyword_args

additional attributes



108
109
110
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 108

def pause(length: nil, **keyword_args)
  append(Pause.new(length: length, **keyword_args))
end

#play(url: nil, loop: nil, digits: nil, **keyword_args) ⇒ Object

Create a new <Play> element

url

Media URL

loop

Times to loop media

digits

Play DTMF tones for digits

keyword_args

additional attributes



118
119
120
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 118

def play(url: nil, loop: nil, digits: nil, **keyword_args)
  append(Play.new(url: url, loop: loop, digits: digits, **keyword_args))
end

#queue(name, url: nil, method: nil, reservation_sid: nil, post_work_activity_sid: nil, **keyword_args) ⇒ Object

Create a new <Queue> element

name

Queue name

url

Action URL

method

Action URL method

reservation_sid

TaskRouter Reservation SID

post_work_activity_sid

TaskRouter Activity SID

keyword_args

additional attributes



130
131
132
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 130

def queue(name, url: nil, method: nil, reservation_sid: nil, post_work_activity_sid: nil, **keyword_args)
  append(Queue.new(name, url: url, method: method, reservation_sid: reservation_sid, post_work_activity_sid: post_work_activity_sid, **keyword_args))
end

#record(action: nil, method: nil, timeout: nil, finish_on_key: nil, max_length: nil, play_beep: nil, trim: nil, recording_status_callback: nil, recording_status_callback_method: nil, transcribe: nil, transcribe_callback: nil, **keyword_args) ⇒ Object

Create a new <Record> element

action

Action URL

method

Action URL method

timeout

Timeout to begin recording

finish_on_key

Finish recording on key

max_length

Max time to record in seconds

play_beep

Play beep

trim

Trim the recording

recording_status_callback

Status callback URL

recording_status_callback_method

Status callback URL method

transcribe

Transcribe the recording

transcribe_callback

Transcribe callback URL

keyword_args

additional attributes



148
149
150
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 148

def record(action: nil, method: nil, timeout: nil, finish_on_key: nil, max_length: nil, play_beep: nil, trim: nil, recording_status_callback: nil, recording_status_callback_method: nil, transcribe: nil, transcribe_callback: nil, **keyword_args)
  append(Record.new(action: action, method: method, timeout: timeout, finish_on_key: finish_on_key, max_length: max_length, play_beep: play_beep, trim: trim, recording_status_callback: recording_status_callback, recording_status_callback_method: recording_status_callback_method, transcribe: transcribe, transcribe_callback: transcribe_callback, **keyword_args))
end

#redirect(url, method: nil, **keyword_args) ⇒ Object

Create a new <Redirect> element

url

Redirect URL

method

Redirect URL method

keyword_args

additional attributes



157
158
159
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 157

def redirect(url, method: nil, **keyword_args)
  append(Redirect.new(url, method: method, **keyword_args))
end

#reject(reason: nil, **keyword_args) ⇒ Object

Create a new <Reject> element

reason

Rejection reason

keyword_args

additional attributes



165
166
167
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 165

def reject(reason: nil, **keyword_args)
  append(Reject.new(reason: reason, **keyword_args))
end

#say(message, voice: nil, loop: nil, language: nil, **keyword_args) ⇒ Object

Create a new <Say> element

message

Message to say

voice

Voice to use

loop

Times to loop message

language

Message langauge

keyword_args

additional attributes



176
177
178
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 176

def say(message, voice: nil, loop: nil, language: nil, **keyword_args)
  append(Say.new(message, voice: voice, loop: loop, language: language, **keyword_args))
end

#sms(message, to: nil, from: nil, action: nil, method: nil, status_callback: nil, **keyword_args) ⇒ Object

Create a new <Sms> element

message

Message body

to

Number to send message to

from

Number to send message from

action

Action URL

method

Action URL method

status_callback

Status callback URL

keyword_args

additional attributes



189
190
191
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 189

def sms(message, to: nil, from: nil, action: nil, method: nil, status_callback: nil, **keyword_args)
  append(Sms.new(message, to: to, from: from, action: action, method: method, status_callback: status_callback, **keyword_args))
end