Class: Twilio::TwiML::VoiceResponse
- Defined in:
- lib/twilio-ruby/twiml/voice_response.rb
Overview
Instance Attribute Summary
Attributes inherited from TwiML
Instance Method Summary collapse
-
#connect(action: nil, method: nil, **keyword_args) {|connect| ... } ⇒ Object
- Create a new
element action - Action URL method
- Action URL method keyword_args
additional attributes.
- Create a new
-
#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_configuration_id: 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, events: nil, **keyword_args) {|dial| ... } ⇒ Object
- Create a new
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_configuration_id
- Configuration for the recording 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 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).
- Create a new
-
#echo(**keyword_args) ⇒ Object
- Create a new
element keyword_args additional attributes.
- Create a new
-
#enqueue(name: nil, action: nil, max_queue_size: nil, method: nil, wait_url: nil, wait_url_method: nil, workflow_sid: nil, **keyword_args) {|enqueue| ... } ⇒ Object
- Create a new
element name - Friendly name action
- Action URL max_queue_size
- Maximum size of queue method
- Action URL method wait_url
- Wait URL wait_url_method
- Wait URL method workflow_sid
- TaskRouter Workflow SID keyword_args
additional attributes.
- Create a new
-
#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) {|gather| ... } ⇒ Object
- Create a new
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.
- Create a new
-
#hangup(**keyword_args) {|hangup| ... } ⇒ Object
- Create a new
element keyword_args additional attributes.
- Create a new
-
#initialize(**keyword_args) {|_self| ... } ⇒ VoiceResponse
constructor
A new instance of VoiceResponse.
-
#leave(**keyword_args) ⇒ Object
- Create a new
element keyword_args additional attributes.
- Create a new
-
#pause(length: nil, **keyword_args) ⇒ Object
- Create a new
element length - Length in seconds to pause keyword_args
additional attributes.
- Create a new
-
#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) {|pay| ... } ⇒ Object
- Create a new
element input - Input type Twilio should accept action
- Action URL bank_account_type
Bank account type for ach transactions.
- Create a new
-
#play(url: nil, loop: nil, digits: nil, **keyword_args) ⇒ Object
- Create a new
element url - Media URL loop
- Times to loop media digits
- Play DTMF tones for digits keyword_args
additional attributes.
- Create a new
-
#prompt(for_: nil, error_type: nil, card_type: nil, attempt: nil, require_matching_inputs: nil, **keyword_args) {|prompt| ... } ⇒ Object
- Create a new
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 require_matching_inputs
Require customer to input requested information twice and verify matching.
- Create a new
-
#queue(name, url: nil, method: nil, reservation_sid: nil, post_work_activity_sid: nil, **keyword_args) ⇒ Object
- Create a new
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.
- Create a new
-
#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, recording_configuration_id: nil, **keyword_args) ⇒ Object
- Create a new
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 recording_configuration_id
- Configuration for the recording keyword_args
additional attributes.
- Create a new
-
#redirect(url, method: nil, **keyword_args) ⇒ Object
- Create a new
element url - Redirect URL method
- Redirect URL method keyword_args
additional attributes.
- Create a new
-
#refer(action: nil, method: nil, **keyword_args) {|refer| ... } ⇒ Object
- Create a new
element action - Action URL method
- Action URL method keyword_args
additional attributes.
- Create a new
-
#reject(reason: nil, **keyword_args) {|reject| ... } ⇒ Object
- Create a new
element reason - Rejection reason keyword_args
additional attributes.
- Create a new
-
#say(message: nil, voice: nil, loop: nil, language: nil, **keyword_args) {|say| ... } ⇒ Object
- Create a new
element message - Message to say voice
- Voice to use loop
- Times to loop message language
- Message language keyword_args
additional attributes.
- Create a new
-
#sms(message, to: nil, from: nil, action: nil, method: nil, status_callback: nil, **keyword_args) ⇒ Object
- Create a new
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.
- Create a new
-
#start(action: nil, method: nil, **keyword_args) {|start| ... } ⇒ Object
- Create a new
element action - Action URL method
- Action URL method keyword_args
additional attributes.
- Create a new
-
#stop(**keyword_args) {|stop| ... } ⇒ Object
- Create a new
element keyword_args additional attributes.
- Create a new
Methods inherited from TwiML
#add_child, #add_text, #append, #comment, to_lower_camel_case, #to_s, #xml
Constructor Details
#initialize(**keyword_args) {|_self| ... } ⇒ VoiceResponse
Returns a new instance of VoiceResponse.
14 15 16 17 18 19 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 14 def initialize(**keyword_args) super(**keyword_args) @name = 'Response' yield(self) if block_given? end |
Instance Method Details
#connect(action: nil, method: nil, **keyword_args) {|connect| ... } ⇒ Object
Create a new
- action
Action URL
- method
Action URL method
- keyword_args
additional attributes
26 27 28 29 30 31 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 26 def connect(action: nil, method: nil, **keyword_args) connect = Connect.new(action: action, method: method, **keyword_args) yield(connect) if block_given? append(connect) end |
#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_configuration_id: 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, events: nil, **keyword_args) {|dial| ... } ⇒ Object
Create a new
- 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_configuration_id
Configuration for the recording
- 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
- 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
- events
Subscription to events
- keyword_args
additional attributes
56 57 58 59 60 61 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 56 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_configuration_id: 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, events: 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_configuration_id: recording_configuration_id, 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, events: events, **keyword_args) yield(dial) if block_given? append(dial) end |
#echo(**keyword_args) ⇒ Object
Create a new
- keyword_args
additional attributes
66 67 68 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 66 def echo(**keyword_args) append(Echo.new(**keyword_args)) end |
#enqueue(name: nil, action: nil, max_queue_size: nil, method: nil, wait_url: nil, wait_url_method: nil, workflow_sid: nil, **keyword_args) {|enqueue| ... } ⇒ Object
Create a new
- name
Friendly name
- action
Action URL
- max_queue_size
Maximum size of queue
- method
Action URL method
- wait_url
Wait URL
- wait_url_method
Wait URL method
- workflow_sid
TaskRouter Workflow SID
- keyword_args
additional attributes
80 81 82 83 84 85 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 80 def enqueue(name: nil, action: nil, max_queue_size: nil, method: nil, wait_url: nil, wait_url_method: nil, workflow_sid: nil, **keyword_args) enqueue = Enqueue.new(name: name, action: action, max_queue_size: max_queue_size, 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, debug: nil, action_on_empty_result: nil, speech_model: nil, enhanced: nil, **keyword_args) {|gather| ... } ⇒ Object
Create a new
- 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
108 109 110 111 112 113 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 108 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) 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: , debug: debug, action_on_empty_result: action_on_empty_result, speech_model: speech_model, enhanced: enhanced, **keyword_args) yield(gather) if block_given? append(gather) end |
#hangup(**keyword_args) {|hangup| ... } ⇒ Object
Create a new
- keyword_args
additional attributes
118 119 120 121 122 123 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 118 def hangup(**keyword_args) hangup = Hangup.new(**keyword_args) yield(hangup) if block_given? append(hangup) end |
#leave(**keyword_args) ⇒ Object
Create a new
- keyword_args
additional attributes
128 129 130 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 128 def leave(**keyword_args) append(Leave.new(**keyword_args)) end |
#pause(length: nil, **keyword_args) ⇒ Object
Create a new
- length
Length in seconds to pause
- keyword_args
additional attributes
136 137 138 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 136 def pause(length: nil, **keyword_args) append(Pause.new(length: length, **keyword_args)) end |
#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) {|pay| ... } ⇒ Object
Create a new
- 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
250 251 252 253 254 255 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 250 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) 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) yield(pay) if block_given? append(pay) end |
#play(url: nil, loop: nil, digits: nil, **keyword_args) ⇒ Object
Create a new
- url
Media URL
- loop
Times to loop media
- digits
Play DTMF tones for digits
- keyword_args
additional attributes
146 147 148 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 146 def play(url: nil, loop: nil, digits: nil, **keyword_args) append(Play.new(url: url, loop: loop, digits: digits, **keyword_args)) end |
#prompt(for_: nil, error_type: nil, card_type: nil, attempt: nil, require_matching_inputs: nil, **keyword_args) {|prompt| ... } ⇒ Object
Create a new
- for_
Name of the payment source data element
- error_type
Type of error
- card_type
Type of the credit card
- attempt
Current attempt count
- require_matching_inputs
Require customer to input requested information twice and verify matching.
- keyword_args
additional attributes
265 266 267 268 269 270 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 265 def prompt(for_: nil, error_type: nil, card_type: nil, attempt: nil, require_matching_inputs: nil, **keyword_args) prompt = Prompt.new(for_: for_, error_type: error_type, card_type: card_type, attempt: attempt, require_matching_inputs: require_matching_inputs, **keyword_args) yield(prompt) if block_given? append(prompt) end |
#queue(name, url: nil, method: nil, reservation_sid: nil, post_work_activity_sid: nil, **keyword_args) ⇒ Object
Create a new
- 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
158 159 160 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 158 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, recording_status_callback_event: nil, transcribe: nil, transcribe_callback: nil, recording_configuration_id: nil, **keyword_args) ⇒ Object
Create a new
- 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
- recording_configuration_id
Configuration for the recording
- keyword_args
additional attributes
178 179 180 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 178 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, recording_configuration_id: 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, recording_status_callback_event: recording_status_callback_event, transcribe: transcribe, transcribe_callback: transcribe_callback, recording_configuration_id: recording_configuration_id, **keyword_args)) end |
#redirect(url, method: nil, **keyword_args) ⇒ Object
Create a new
- url
Redirect URL
- method
Redirect URL method
- keyword_args
additional attributes
187 188 189 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 187 def redirect(url, method: nil, **keyword_args) append(Redirect.new(url, method: method, **keyword_args)) end |
#refer(action: nil, method: nil, **keyword_args) {|refer| ... } ⇒ Object
Create a new
- action
Action URL
- method
Action URL method
- keyword_args
additional attributes
299 300 301 302 303 304 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 299 def refer(action: nil, method: nil, **keyword_args) refer = Refer.new(action: action, method: method, **keyword_args) yield(refer) if block_given? append(refer) end |
#reject(reason: nil, **keyword_args) {|reject| ... } ⇒ Object
Create a new
- reason
Rejection reason
- keyword_args
additional attributes
195 196 197 198 199 200 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 195 def reject(reason: nil, **keyword_args) reject = Reject.new(reason: reason, **keyword_args) yield(reject) if block_given? append(reject) end |
#say(message: nil, voice: nil, loop: nil, language: nil, **keyword_args) {|say| ... } ⇒ Object
Create a new
- message
Message to say
- voice
Voice to use
- loop
Times to loop message
- language
Message language
- keyword_args
additional attributes
209 210 211 212 213 214 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 209 def say(message: nil, voice: nil, loop: nil, language: nil, **keyword_args) say = Say.new(message: , voice: voice, loop: loop, language: language, **keyword_args) yield(say) if block_given? append(say) end |
#sms(message, to: nil, from: nil, action: nil, method: nil, status_callback: nil, **keyword_args) ⇒ Object
Create a new
- 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
225 226 227 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 225 def sms(, to: nil, from: nil, action: nil, method: nil, status_callback: nil, **keyword_args) append(Sms.new(, to: to, from: from, action: action, method: method, status_callback: status_callback, **keyword_args)) end |
#start(action: nil, method: nil, **keyword_args) {|start| ... } ⇒ Object
Create a new
- action
Action URL
- method
Action URL method
- keyword_args
additional attributes
277 278 279 280 281 282 |
# File 'lib/twilio-ruby/twiml/voice_response.rb', line 277 def start(action: nil, method: nil, **keyword_args) start = Start.new(action: action, method: method, **keyword_args) yield(start) if block_given? append(start) end |