Skip to content

Instantly share code, notes, and snippets.

@willawill
Last active December 11, 2015 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willawill/4533965 to your computer and use it in GitHub Desktop.
Save willawill/4533965 to your computer and use it in GitHub Desktop.
def build_response(from, commands)
response = Plivo::Response.new
commands.map do |c|
case c[:cmd]
when :reject
response.addHangup(reason: 'busy')
when :ivr
response.addHangup(reason: 'busy')
dial = response.addDial(callerId: from)
dial.addNumber(c[:to])
digit = response.addGetDigits(action: '/', method: 'GET', redirect: false)
digit.addSpeak("#{c[:text]}")
response.addSpeak('No input received')
when :record
response.addSpeak("#{c[:promt]}")
response.addRecord(action: "#{c[:voicemail].plivo_callback}", callbackUrl: "#{c[:voicemail].plivo_callback}")
end
end
p response
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment