Skip to content

Instantly share code, notes, and snippets.

@radralph
Last active April 21, 2017 00:29
Show Gist options
  • Select an option

  • Save radralph/368becd7774e73378b45ba18b5b841d9 to your computer and use it in GitHub Desktop.

Select an option

Save radralph/368becd7774e73378b45ba18b5b841d9 to your computer and use it in GitHub Desktop.
def say_as(value,type)
ssml_start="<?xml version='1.0'?><speak>"
ssml_end="</say-as></speak>"
ssml ="<say-as interpret-as='vxml:#{type}'>#{value}"
complete_string = ssml_start + ssml + ssml_end
say complete_string
end
wait(1500)
say "Hi! how may we help you today?"
ask "If you would like to settle or pay for your current bill, please say payment", {
:choices => "payment,balance",
:recognizer => "en-PH",
:timeout => 20,
:bargein => false,
:mode => "speech",
:onChoice => lambda { |event| @answer = event.value},
:onBadChoice => lambda { |event| say "Sorry, we did not recognize your speech"},
:onTimeout => lambda { |event| say "Sorry, we did not receive your input"}}
#say @answer
if @answer.eql? "payment"
ask "You chose payment, to pay you sing your credit card, please say card, for bank deposit, please say deposit, to pay online, please say online", {
:choices => "card, deposit, online",
:recognizer => "en-PH",
:timeout => 20,
:bargein => false,
:mode => "speech",
:onChoice => lambda { |event| @answer = event.value },
:onBadChoice => lambda { |event| say "Sorry, we did not recognize your speech"},
:onTimeout => lambda { |event| say "Sorry, we did not receive your input"}}
else
hangup
end
if @answer.eql? "card"
#-Start
ask "You have chosen to pay using your credit card to pay your remaining balance of 3,200 pesos, please say your 4 digit credit card number", {
:choices => "[4 DIGITS]",
:recognizer => "en-PH",
:timeout => 20,
:bargein => false,
:mode => "speech",
:onChoice => lambda { |event| @cc = event.value},
:onBadChoice => lambda { |event| say "Sorry, we did not recognize your speech"},
:onTimeout => lambda { |event| say "Sorry, we did not receive your input"}}
say "To confirm, your credit card number is "
say_as(@cc,'digits')
ask "Is this correct? please reply by saying yes, or no ",{
:choices => "yes, no",
:recognizer => "en-PH",
:timeout => 20,
:bargein => false,
:mode => "speech",
:onChoice => lambda { |event| @answer = event.value},
:onBadChoice => lambda { |event| say "Sorry, we did not recognize your speech"},
:onTimeout => lambda { |event| say "Sorry, we did not receive your input"}}
if @answer.eql? "yes"
say "Thank you for confirming, we will now process your payment. Thank you for you sing our service."
hangup
else
ask "Please re-try saying your credit card number",{
:choices => "[4 DIGITS]",
:recognizer => "en-PH",
:timeout => 20,
:bargein => false,
:mode => "speech",
:onChoice => lambda { |event| @cc = event.value},
:onBadChoice => lambda { |event| say "Sorry, we did not recognize your speech"},
:onTimeout => lambda { |event| say "Sorry, we did not receive your input"}}
end
say "To confirm, your credit card number is "
say_as(@cc,'digits')
ask "Is this correct? please reply by saying yes, or no ",{
:choices => "yes, no",
:recognizer => "en-PH",
:timeout => 20,
:bargein => false,
:mode => "speech",
:onChoice => lambda { |event| @answer = event.value},
:onBadChoice => lambda { |event| say "Sorry, we did not recognize your speech"},
:onTimeout => lambda { |event| say "Sorry, we did not receive your input"}}
if @answer.eql? "yes"
say "Thank you for confirming, we will now process your payment. Thank you for you sing our service."
hangup
else
say "You have exceeded your maximum attempt, please dial in again. goodbye"
hangup
end
#-END
elsif @answer.eql? "online"
say "you have chosen online payment to settle your remaining balance amounting to, 3,200 pesos"
say "please listen to the following instructions to make an online payment"
elsif @answer.eql? "deposit"
say "you have chosen bank deposit to settle your remaining balance amounting to, 3,200 pesos"
say "please listen to the following instructions to make a bank deposit"
hangup
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment