class Twilio::TwiML::VoiceResponse
<Response> TwiML
for Voice
Public Class Methods
Twilio::TwiML::TwiML::new
# File lib/twilio-ruby/twiml/voice_response.rb 14 def initialize(**keyword_args) 15 super(**keyword_args) 16 @name = 'Response' 17 18 yield(self) if block_given? 19 end
Public Instance Methods
Create a new <Connect> element
- action
-
Action URL
- method
-
Action URL method
- keyword_args
-
additional attributes
# File lib/twilio-ruby/twiml/voice_response.rb 26 def connect(action: nil, method: nil, **keyword_args) 27 connect = Connect.new(action: action, method: method, **keyword_args) 28 29 yield(connect) if block_given? 30 append(connect) 31 end
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 theDial
- recording_track
-
To indicate which audio track should be recorded
- sequential
-
Used to determine if child
TwiML
nouns should be dialed in order, one after the other (sequential) or dial all at once (parallel). Default is false, parallel - refer_url
-
Webhook that will receive future SIP REFER requests
- refer_method
-
The
HTTP
method to use for the refer Webhook - keyword_args
-
additional attributes
# File lib/twilio-ruby/twiml/voice_response.rb 54 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, recording_track: nil, sequential: nil, refer_url: nil, refer_method: nil, **keyword_args) 55 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, recording_track: recording_track, sequential: sequential, refer_url: refer_url, refer_method: refer_method, **keyword_args) 56 57 yield(dial) if block_given? 58 append(dial) 59 end
Create a new <Echo> element
- keyword_args
-
additional attributes
# File lib/twilio-ruby/twiml/voice_response.rb 64 def echo(**keyword_args) 65 append(Echo.new(**keyword_args)) 66 end
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
# File lib/twilio-ruby/twiml/voice_response.rb 77 def enqueue(name: nil, action: nil, method: nil, wait_url: nil, wait_url_method: nil, workflow_sid: nil, **keyword_args) 78 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) 79 80 yield(enqueue) if block_given? 81 append(enqueue) 82 end
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 - debug
-
Allow debug for gather
- action_on_empty_result
-
Force webhook to the action URL event if there is no input
- speech_model
-
Specify the model that is best suited for your use case
- enhanced
-
Use enhanced speech model
- keyword_args
-
additional attributes
# File lib/twilio-ruby/twiml/voice_response.rb 105 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, debug: nil, action_on_empty_result: nil, speech_model: nil, enhanced: nil, **keyword_args) 106 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, debug: debug, action_on_empty_result: action_on_empty_result, speech_model: speech_model, enhanced: enhanced, **keyword_args) 107 108 yield(gather) if block_given? 109 append(gather) 110 end
Create a new <Hangup> element
- keyword_args
-
additional attributes
# File lib/twilio-ruby/twiml/voice_response.rb 115 def hangup(**keyword_args) 116 append(Hangup.new(**keyword_args)) 117 end
Create a new <Leave> element
- keyword_args
-
additional attributes
# File lib/twilio-ruby/twiml/voice_response.rb 122 def leave(**keyword_args) 123 append(Leave.new(**keyword_args)) 124 end
Create a new <Pause> element
- length
-
Length in seconds to pause
- keyword_args
-
additional attributes
# File lib/twilio-ruby/twiml/voice_response.rb 130 def pause(length: nil, **keyword_args) 131 append(Pause.new(length: length, **keyword_args)) 132 end
Create a new <Pay> element
- input
-
Input type
Twilio
should accept - action
-
Action URL
- bank_account_type
-
Bank account type for ach transactions. If set, payment method attribute must be provided and value should be set to ach-debit. defaults to consumer-checking
- status_callback
-
Status callback URL
- status_callback_method
-
Status callback method
- timeout
-
Time to wait to gather input
- max_attempts
-
Maximum number of allowed retries when gathering input
- security_code
-
Prompt
for security code - postal_code
-
Prompt
for postal code and it should be true/false or default postal code - min_postal_code_length
-
Prompt
for minimum postal code length - payment_connector
-
Unique name for payment connector
- payment_method
-
Payment method to be used. defaults to credit-card
- token_type
-
Type of token
- charge_amount
-
Amount to process. If value is greater than 0 then make the payment else create a payment token
- currency
-
Currency of the amount attribute
- description
-
Details regarding the payment
- valid_card_types
-
Comma separated accepted card types
- language
-
Language to use
- keyword_args
-
additional attributes
# File lib/twilio-ruby/twiml/voice_response.rb 240 def pay(input: nil, action: nil, bank_account_type: nil, status_callback: nil, status_callback_method: nil, timeout: nil, max_attempts: nil, security_code: nil, postal_code: nil, min_postal_code_length: nil, payment_connector: nil, payment_method: nil, token_type: nil, charge_amount: nil, currency: nil, description: nil, valid_card_types: nil, language: nil, **keyword_args) 241 pay = Pay.new(input: input, action: action, bank_account_type: bank_account_type, status_callback: status_callback, status_callback_method: status_callback_method, timeout: timeout, max_attempts: max_attempts, security_code: security_code, postal_code: postal_code, min_postal_code_length: min_postal_code_length, payment_connector: payment_connector, payment_method: payment_method, token_type: token_type, charge_amount: charge_amount, currency: currency, description: description, valid_card_types: valid_card_types, language: language, **keyword_args) 242 243 yield(pay) if block_given? 244 append(pay) 245 end
Create a new <Play> element
- url
-
Media
URL - loop
-
Times to loop media
- digits
-
Play
DTMF tones for digits - keyword_args
-
additional attributes
# File lib/twilio-ruby/twiml/voice_response.rb 140 def play(url: nil, loop: nil, digits: nil, **keyword_args) 141 append(Play.new(url: url, loop: loop, digits: digits, **keyword_args)) 142 end
Create a new <Prompt> element
- for_
-
Name of the payment source data element
- error_type
-
Type of error
- card_type
-
Type of the credit card
- attempt
-
Current attempt count
- keyword_args
-
additional attributes
# File lib/twilio-ruby/twiml/voice_response.rb 254 def prompt(for_: nil, error_type: nil, card_type: nil, attempt: nil, **keyword_args) 255 prompt = Prompt.new(for_: for_, error_type: error_type, card_type: card_type, attempt: attempt, **keyword_args) 256 257 yield(prompt) if block_given? 258 append(prompt) 259 end
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
# File lib/twilio-ruby/twiml/voice_response.rb 152 def queue(name, url: nil, method: nil, reservation_sid: nil, post_work_activity_sid: nil, **keyword_args) 153 append(Queue.new(name, url: url, method: method, reservation_sid: reservation_sid, post_work_activity_sid: post_work_activity_sid, **keyword_args)) 154 end
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
- recording_status_callback_event
-
Recording status callback events
- transcribe
-
Transcribe the recording
- transcribe_callback
-
Transcribe callback URL
- keyword_args
-
additional attributes
# File lib/twilio-ruby/twiml/voice_response.rb 171 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, recording_status_callback_event: nil, transcribe: nil, transcribe_callback: nil, **keyword_args) 172 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, recording_status_callback_event: recording_status_callback_event, transcribe: transcribe, transcribe_callback: transcribe_callback, **keyword_args)) 173 end
Create a new <Refer> element
- action
-
Action URL
- method
-
Action URL method
- keyword_args
-
additional attributes
# File lib/twilio-ruby/twiml/voice_response.rb 288 def refer(action: nil, method: nil, **keyword_args) 289 refer = Refer.new(action: action, method: method, **keyword_args) 290 291 yield(refer) if block_given? 292 append(refer) 293 end
Create a new <Reject> element
- reason
-
Rejection reason
- keyword_args
-
additional attributes
# File lib/twilio-ruby/twiml/voice_response.rb 188 def reject(reason: nil, **keyword_args) 189 append(Reject.new(reason: reason, **keyword_args)) 190 end
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
# File lib/twilio-ruby/twiml/voice_response.rb 199 def say(message: nil, voice: nil, loop: nil, language: nil, **keyword_args) 200 say = Say.new(message: message, voice: voice, loop: loop, language: language, **keyword_args) 201 202 yield(say) if block_given? 203 append(say) 204 end
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
# File lib/twilio-ruby/twiml/voice_response.rb 215 def sms(message, to: nil, from: nil, action: nil, method: nil, status_callback: nil, **keyword_args) 216 append(Sms.new(message, to: to, from: from, action: action, method: method, status_callback: status_callback, **keyword_args)) 217 end
Create a new <Start> element
- action
-
Action URL
- method
-
Action URL method
- keyword_args
-
additional attributes
# File lib/twilio-ruby/twiml/voice_response.rb 266 def start(action: nil, method: nil, **keyword_args) 267 start = Start.new(action: action, method: method, **keyword_args) 268 269 yield(start) if block_given? 270 append(start) 271 end
Create a new <Stop> element
- keyword_args
-
additional attributes
# File lib/twilio-ruby/twiml/voice_response.rb 276 def stop(**keyword_args) 277 stop = Stop.new(**keyword_args) 278 279 yield(stop) if block_given? 280 append(stop) 281 end