Skip to content

Instantly share code, notes, and snippets.

@chug2k
Created October 9, 2013 01:37
Show Gist options
  • Save chug2k/6894803 to your computer and use it in GitHub Desktop.
Save chug2k/6894803 to your computer and use it in GitHub Desktop.
Simple conversation bot
# We're going to write a very simple conversation bot.
def get_response(prompt)
if prompt.include?("hello")
"Hello! How are you?"
elsif prompt.include?("bye")
"Bye! It was great talking to you!"
else
"I do not understand what you mean by: \"#{prompt}\""
end
end
puts "Hello, I am a computer."
while true
print '> '
puts get_response(gets.strip.downcase)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment