Created
November 11, 2010 01:09
-
-
Save chrismetcalf/671812 to your computer and use it in GitHub Desktop.
New handler for SMS and text in tropo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Decide whether this is text or phone | |
if $currentCall.nil? | |
log "Curious. No currentCall. Am I running outside Tropo?" | |
elsif $currentCall.initialText.nil? | |
# Phone call | |
say "Welcome to the King County Christmas Tree Recycling Line." | |
# Setting up our options for "ask". We accept 5 digits, either spoken or entered | |
# by DTMF, and time out after 10 seconds. | |
zipcode_options = { :choices => "[5 DIGITS]", | |
:repeat => 3, | |
:timeout => 10, | |
:onBadChoice => lambda { say 'Invalid entry, please try again.' }, | |
:onTimeout => lambda { say 'Timeout, please try again.' }, | |
:onChoice => lambda { |zip| phone(zip.value) } | |
} | |
ask 'Enter or say your ZIP code to find a Christmas tree facility in your area.', zipcode_options | |
say 'Thank you for using the King County Christmas Tree Recycling Line. Goodbye.' | |
elsif $currentCall.initialText =~ /^\d{5}$/ | |
# Text message, proper zip code | |
message($currentCall.initialText) | |
else | |
# Text message, invalid zip code | |
say("Please text me a valid zip code to look up Christmas tree disposal facilities in your area.") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment