Class: Bandwidth::Bxml::Gather

Inherits:
NestableVerb show all
Defined in:
lib/bandwidth-sdk/models/bxml/verbs/gather.rb

Instance Method Summary collapse

Methods inherited from NestableVerb

#generate_xml

Methods inherited from Verb

#generate_xml, #set_attributes

Constructor Details

#initialize(audio_verbs = [], attributes = {}) ⇒ Gather

Initializer

Parameters:

  • audio_verbs (Verb) (defaults to: []) —

    or [Array] XML element children. Defaults to an empty array. Valid nested audio verbs are: SpeakSentence, PlayAudio.

  • attributes (Hash) (defaults to: {}) —

    The attributes to add to the element. Defaults to an empty hash.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bandwidth-sdk/models/bxml/verbs/gather.rb', line 7

def initialize(audio_verbs = [], attributes = {})
  super('Gather', nil, audio_verbs, attributes)

  @attribute_map = {
    gather_url: 'gatherUrl',                                       # Optional [String]: URL to send Gather event to and request new BXML. May be a relative URL.
    gather_method: 'gatherMethod',                                 # Optional [String]: The HTTP method to use for the request to gather_url. GET or POST. Default value is POST.
    gather_fallback_url: 'gatherFallbackUrl',                      # Optional [String]: A fallback url which, if provided, will be used to retry the Gather event callback delivery in case gather_url fails to respond.
    gather_fallback_method: 'gatherFallbackMethod',                # Optional [String]: The HTTP method to use to deliver the Gather event callback to gather_fallback_url. GET or POST. Default value is POST.
    username: 'username',                                          # Optional [String]: The username to send in the HTTP request to gather_url.
    password: 'password',                                          # Optional [String]: The password to send in the HTTP request to gather_url.
    fallback_username: 'fallbackUsername',                         # Optional [String]: The username to send in the HTTP request to gather_fallback_url.
    fallback_password: 'fallbackPassword',                         # Optional [String]: The password to send in the HTTP request to gather_fallback_url.
    tag: 'tag',                                                    # Optional [String]: A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or <Tag> verb, or cleared. May be cleared by setting tag="". Max length 256 characters.
    terminating_digits: 'terminatingDigits',                       # Optional [String]: When any of these digits are pressed, it will terminate the Gather. Default value is "", which disables this feature.
    max_digits: 'maxDigits',                                       # Optional [Number]: Max number of digits to collect. Default value is 50. Range: decimal values between 1 - 50.
    inter_digit_timeout: 'interDigitTimeout',                      # Optional [Number]: Time (in seconds) allowed between digit presses before automatically terminating the Gather. Default value is 5. Range: decimal values between 1 - 60.
    first_digit_timeout: 'firstDigitTimeout',                      # Optional [Number]: Time (in seconds) to pause after any audio from nested <SpeakSentence> or <PlayAudio> verb is played (in seconds) before terminating the Gather. Default value is 5. Range: decimal values between 0 - 60.
    repeat_count: 'repeatCount',                                   # Optional [Number]: The number of times the audio prompt should be played if no digits are pressed. For example, if this value is 3, the nested audio clip will be played a maximum of three times. The delay between repetitions will be equal to first_digit_timeout. Default value is 1. repeatCount * number of verbs must not be greater than 20.
    input: 'input',                                                # Optional [String]: Specifies the input mode for the Gather verb. Accepted values are dtmf, speech, or dtmf_speech. Default value is dtmf.
    hints: 'hints',                                                # Optional [String]: Words or phrases that help improve speech recognition, useful for phrases with many words. Possible and effective only if input is speech or dtmf_speech.
    language: 'language',                                          # Optional [String]: Language code for speech recognition. See the BXML documentation for the list of supported locales. Possible and effective only if input is speech or dtmf_speech.
    partial_result_callback: 'partialResultCallback',              # Optional [String]: URL to send Partial Result event to. May be a relative URL. Possible and effective only if input is speech or dtmf_speech.
    partial_result_callback_method: 'partialResultCallbackMethod', # Optional [String]: The HTTP method to use for the request to partial_result_callback. GET or POST. Default value is POST.
    profanity_filter: 'profanityFilter',                           # Optional [Boolean]: Enables or disables filtering of profane words. Default value is true. Possible and effective only if input is speech or dtmf_speech.
    speech_model: 'speechModel',                                   # Optional [String]: Specifies the speech recognition model to use: default, numbers_and_commands, phone_call, experimental_conversations, experimental_utterances, googlev2_long, googlev2_short, googlev2_telephony, or googlev2_telephony_short.
    speech_timeout: 'speechTimeout',                               # Optional [Number]: Time (in seconds) to wait for speech input before timing out. Accepted values are any positive integer. Default value is 5.
  }
end

Instance Method Details

#add_audio_verbs(audio_verbs) ⇒ Object

Add audio verb or verbs to the nested verbs array

Parameters:

  • audio_verbs (SpeakSentence) —

    or [PlayAudio] or [Array<SpeakSentence || PlayAudio>] Verb or verbs to add to the array.



45
46
47
# File 'lib/bandwidth-sdk/models/bxml/verbs/gather.rb', line 45

def add_audio_verbs(audio_verbs)
  @nested_verbs.push(*audio_verbs)
end

#to_bxml ⇒ String

Return BXML representation of this response

Returns:

  • (String) —

    The XML response in string format.



38
39
40
41
# File 'lib/bandwidth-sdk/models/bxml/verbs/gather.rb', line 38

def to_bxml
  bxml = Ox.dump(generate_xml)
  bxml.gsub(SPEAK_SENTENCE_REGEX) { |text| text.gsub(SSML_REGEX, '<\1>') }
end