Skip to content

sandagolcea/chatterbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chatterbox Challenge

What is it?

This is a regular chat bot with a very limited vocabulary

What does it do?

It chats with you on a limited range of items. The chatbot is in the 'chatbot.rb' file, run it from the command line and then experiment chatting with it.

You can also add your own responses to your chosen keywords (see how to run)

How to run

git clone git@github.com:sandagolcea/chatterbox.git
cd chatterbox
ruby chatbot.rb

To add more responses, write this phrase in the chatbot discussion, replacing the keywords and the response with your own input : When someone says '<keywords>' you say '<response>'

Possible Improvements

Original ruby input:

def get_response(input)
  key = RESPONSES.keys.select {|k| /#{k}/ =~ input }.sample
  /#{key}/ =~ input
  response = RESPONSES[key]
  response.nil? ? 'sorry?' : response % { c1: $1, c2: $2}
end

RESPONSES = { 'goodbye' => 'bye', 
              'sayonara' => 'sayonara', 
              'the weather is (.*)' => 'I hate it when it\'s %{c1}', 
              'I love (.*)' => 'I love %{c1} too', 
              'I groove to (.*) and (.*)' => 'I love %{c1} but I hate %{c2}'}

puts "Hello, what's your name?"
name = gets.chomp
puts "Hello #{name}"
while(input = gets.chomp) do
  puts get_response(input)
end

Resources:

About

Chatbot in ruby (Makers Academy pre-course week3)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages