I have been having a lot of fun with chatbots lately, which I previously described, are considered to be the "new app," taking the throne of mobile applications in the developer space.
For a project I am doing at work, we had a need for something resembling a customer service bot, that is able to hold down natural language conversations with the users of our platform, and we ended up using the services provided by api.ai.
At some point during this process, in an hour where I was a little bored, I had an idea that was both functional, as well as a little wacky.
Since the work project puts the chatbot in a position that takes quite some steps to reach within the overall application, and especially in the beginning requires a lot of testing and play to refine, I wanted to have a more stripped down, and simplified environment to do this in.
The wacky part came into play when I decided to code a quick little command line interface in Ruby, because I, for some strange reason, felt a need inside of me to be able to politely ask the computer to copy a file for me, instead of typing in the same tired old raw commands.
APE MACHINE SHELL, or amsh for short, is the result of this, and I now consider it more of a joke, or fun little project, than anything else, although I would like to see how far I can take this usability wise.
You can get it from github, if you feel the need to, and see how this will develop in the future. As for now, it is merely a proof of concept, and the only real command you can perform is actually quiting the shell.
It does do small talk though, and yes, it has text-to-speech, of course.
How does it work?
amsh (APE MACHINE SHELL) is a command-line shell enhanced with an A.I. chatbot.
For the A.I. chatbot we use the api.ai service, which handles all the small talk, as well as attempting to encode natural language into processable commands. This shell tries to combine the functionality of many tools on the system, so there are 4 steps in which any given input is processed, detailed below.
Send the user input off to api.ai and try to get a valid response. If this is categorized as small talk, just echo back the response, and run it through text-to-speech for a futuristic effect. If the chatbot recognizes this as an actual command, and all the required parameters are in place, send back an encoded string response that will perform the command inside the shell, using any of the following methods. If there are required parameters missing, use the api.ai chatbot to ask the user to define them in a natural language way.
How to install amsh?
- Make sure to install all the gems required at the top of amsh.rb
- Install mpg123 (for text-to-speech)
Improvements I want to make
- After trying to pass the command to the shell, and the exit status being anything else than 0, try to pass the command to Ruby itself, and see if we can run it that way. Then, and only then, try to handle it as an internal command.
- Implement recognition in the chatbot for desired actions, and collect all the required parameters.
ps. For those of you who have read "I Have No Mouth And I must Scream," don't worry your pretty little head about the prompt ;) It's purely a coincidence...