RUFUS – Developing my first talking AI


I’ve always been interested with the concept of AI. The computer’s ability to respond and learn based from the patterns of your responses. Back in the day, there was SimSimi. What was interesting about it was it stored other people’s feedback and then uses it to its own benefit by recycling them in another conversation. How could I be sure? Well, for one, I’m pretty certain bots don’t talk back in my native language and even if it did, it wouldn’t be so casual. It was great and all until people started abusing it and not long after, the responses were dirtier than a pig rolling joyfully in mud. But still, it was a good laugh.

So now, I thought to myself what if I make my own chatbot but with additional features like text-to-speech and can search words on the web. It would also remember user details and can filter unwanted words. I know the concept isn’t new and there a lot more better ones. But still, it’d be nice to try it out for myself.

Understanding the logic

I did what anybody would do with no knowledge of AI development whatsoever, I went to the internet. After reading through a bunch of sites, I found AIML (Artificial Intelligence Markup Language). It was built using XML and was the most-used language by chatbots. Basically I could specify different patterns or ‘categories’, as they are called, and it would go through the database to search for the right response. Wildcards could be used so that input could be dynamic, meaning the bot can still make out mixed-up words. There were also special tags that could save the user’s data on session which proved useful for users’ names, location, etc.

There were different approaches on how to integrate AIML. Most suggested Python but since I am not familiar yet with the language, I decided to use PHP. Hopefully, I might stray away from this method in the future as many suggested that it wasn’t the most practical way of making an AI bot.

When Rufus was complete and the database was working properly, I proceeded to upload a lot of AIML categories which consisted of generic words and conversations people usually talk about. This allowed my bot to have some little bit of knowledge and give somewhat proper replies. As soon as that was done, I proceeded to work on the front end design. As you can see it isn’t much, but I prefer it that way. Simplicity is beauty. And faster page loads lead to happy users 🙂 (also I was lazy)

Let there be sound!

When the aesthetics were done, it was time to look for a good text-to-speech engine. That’s when I found ResponsiveVoice.js, which was free and had a lot of different accents to choose from. Initially there were some problems. Like the voices going out of sync and sometimes it wouldn’t play. After some tweaking with the code and applying some callbacks, they were eventually fixed. So if you have tried Rufus, you would hear that you are like two people talking.

I NEEDS the web

Connecting the bot to search for topics online wasn’t that difficult. There was some source code I found to start with and just made a few adjustments to make it display properly and communicate with the voice engine. To make Rufus search online, just type “search” or “search for” (without the quotes) then the word/s you want. So for example: search potato – would show a definition about ‘potato’. You could also use the command “define” which acts the same way.

So that’s pretty much Rufus. It isn’t much but I’m proud of what I was able to accomplish in a week, alongside having a day job. I will continue improving it and add some other cool features. I will also keep on cleaning out the database of conflicting records and unnecessary patterns. Because as of now, it’s still pretty stupid haha.


UPDATE (02/06/17): Replaced ResponsiveVoice.js for another library called Artyom.js, a more robust text-to-speech plugin. With Artyom.js, I was able to integrate speech-to-text which allows the user to use their microphone to speak to Rufus. Just hold the ‘record’ button down and let go when you are ready to send your message. I will still leave the ‘Text’ option for those who would rather type their responses instead. This is a good alternative especially if the plugin cannot properly processed your words.

Icons made by Freepik from is licensed by CC 3.0 BY
Elmer Balbin

Web developer from Bacolod, Steam Sale hunter, and casual DotA 2 player.

about me

Leave a comment


Get great deals on hotel rooms from all over the world BOOK NOW