49714 Programming for Online Prototypes
· 9 members
A hands on introduction to building online products and services through code
The purpose of this project was to develop a mini chatbot that used Ruby to gain a basic understanding of how the ruby language works and how the basic code structure is laid out. In addition, it also served as a way to get us to start thinking about the work that goes into developing a personality for a Zero-UI application. After being introduced to this project, I knew that I wanted to develop a chatbot that had the personality of my dog, Frasier. I have already projected a persona on my dog and have given him things that I believe are his favorite things, like music and movies, so I thought this project would be a fun way to develop that persona of Frasier into a tangible application that other people could interact with. And I thought it would be a way to make learning code fun, especially because this is my first time coding and I knew it was going to be a learning curve. In addition, going into this project, I knew I wanted to incorporate gifs and emojis into the conversation I develop.
This bot was developed purely out of my desire to build a bot that represented my dog, Frasier. Because of this, I decided early on that I want to incorporate lots of visuals, such as gifs and emojis, and silly things like really bad jokes.
For this project, I focused on the personality first by identifying what I wanted people to be able to engage with Frasier in conversation about. I had originally wanted a chatbot that would interrupt the user sporadically with jokes, gifs, and fun facts because I felt that action/interaction really demonstrated what it is like having Frasier around when you are trying to work. I thought of this chatbot as part annoying but also a nice little mental break from working. I found that I was not advanced enough to figure out the code to the spontaneous interruptions, even with all the googling I did. So I re-evaluated my concept and moved toward a bot that the user could ask questions to learn about Frasier's favorite things. I also thought what I say to Frasier when I am alone and talking to him (you know, thinking out loud) and how I could incorporate those kinds of questions, such as I always ask him "what should we have for dinner tonight?" This really got me thinking about what I would ask the bot and how it would respond. I wanted to still incorporate the "mental break" idea so I included jokes, however, I adjusted it so it would have a back and forward interaction (Frasier asking a joke, the user can guess, and then receive the answer). I wanted to incorporate the giphy api so I would have lots of different gifs that could be sent to the user as responses but I had a lot of issues adding it correctly. So to work around that I still incorporated gifs into the responses I created but they are specific gifs per response. It is not ideal but I do think it adds to the personality I am trying to develop.
All of Frasier bots responses are either based on his favorites things or they are dog-centric. So all of this gifs are either favorite things like food and Bob's Burgers or dog gifs. All of this jokes are dog jokes as well, which they are all really corny jokes. As I mentioned earlier, I wanted to use the giphy api but I had a lot of issues trying to incorporate it into my code correctly, so I had to figure out another way to incorporate gifs. So I decided to incorporate specific gifs into the responses I wrote, so I would still have the gifs to add to the fun personality that I wanted my Frasier bot to have. (see code below). Another thing I included was code that would have the chatbot search for keywords in the conversation and send replies based on those keywords. By having this it would not require the user to write an exact phase and allow the conversation to feel more fluid like you are talking to a friend. So for example with the code below, instead of requiring the user to write just "movie," the user could write "What is your favorite movie?" and the bot would see the keyword "movie" and then send the response.
Example of code I used:
message = "I love Ratatouille"
media = "https://media.giphy.com/media/xKggUfdA60O6A/giphy.gif"
I also incorporated jokes, which I started with the basic joke code from the skillsdev assignment. I wanted to make it more of a back and forth interaction, which I tried to figure out through google but was unsuccessful. So with the help from Daragh, I was able to apply the correct code to get the joke interaction I wanted. It incorporated sessions and .split('\n') which would split a single sentence into multiple parts. In addition, I noticed that the facts I had, while they were random in their response they would repeat sometimes, so I decided to apply the same session principle I used in the jokes section to my facts section.
Code I used:
What kind of dog does Dracula 🧛🏻♂️ have?\n A bloodhound!
array_of_lines = IO.readlines("jokes.txt")
# store the selected joke in a session
session["current_joke"] = array_of_lines.sample
# choose the first part of this: the question
# and send it to the user
message = session["current_joke"].split('\n')
elsif not session["current_joke"].nil?
# if there's a joke on the go...
# and they've replied
message = session["current_joke"].split('\n')
# clear the joke...
session["current_joke"] = nil
elsif body.include?("fact") || body.include?("yourself")
array_of_lines = IO.readlines("facts.txt")
# store the selected fact in a session
session["current_fact"] = array_of_lines.sample
# and send it to the user
message = session["current_fact"]
Heroku App Link: https://sheltered-retreat-11154.herokuapp.com
Frasier bot #: (813)-670-8710
I thought that this project was a great first experience in building a zero-ui application. Because I had an original vision of what I wanted this chatbot to be but not the skills to create that vision, I was forced to think about how I can achieve my original vision but at a scale that was feasible for my skill level. I always think that having to think outside of the box and work around restrictions is always a good learning experience. But I think for the next project, I will start with a small scale vision of my grand vision of the project from the beginning, so I don't get as frustrated from the start. I think I am started to understand the basics of the ruby code language but it has been difficult for me. I am finding that the more I practice the more I understand it so I want to continue on building this little bot on my own. I shared it with my family and they think it is funny because they can see Frasier's personality in the bot already, so I think it would be fun to make it more robust and try out some other methods, etc. I definitely want to try to figure out adding the giphy api and the spontaneous interruptions. I also think it would be fun to add actual pictures and gifs of Frasier doing things instead of gifs of random dogs.
This project is only listed in this pool. Be considerate and think twice before sharing.
Frasier bot is a dog bot. You can ask him questions to learn about his favorite things. He can also tell you some "cool" dog jokes.
September 23rd, 2018