When brainstorming for the SpartaHacks challenge, our team was determined to do some form of a hack for the Amazon Echo. We came up with a few ideas (some of which were already implemented by teams at past hackathons), but at some point we had this fun little joke idea of making a chat bot with the Echo. And who else would you rather have in your living room if not Donald J. Trump? And hence, Trumper was born.
(A developer name for this project was also Dysalexia: after dyxlexia + Alexa. This was after the sometimes jumbled and confusing, yet humorous, blurbs that the bot would spit out)
What it does
The chat bot is activated by calling "Alexa", and then asking the Echo device to "ask Trump" (or a number of similar intents). At that point, we enter a loop of conversation with fairly relevant replies (consisting of actual Donald Trump quotes) to what you say/ask.
We hunted down over 250 quotes from Trump- half of which are from a speech he gave while running for President, and the other half of which were aggregated from various online social media websites, labelled as "The Best of Donald Trump", or similar. This constituted our Trump brain.
Our original plan for simulating conversation was a first order (or even n-th order) Markov chain, in the style of the Monty chatbot. However, after a good chunk of playing around with the idea, and even implementing a working prototype in Ruby, we found out that the result was something that sounded somewhat Trump-y, but not very distinct and recognizable. This led to some confusion to testers of our product. Furthermore, since the phrases were being generated instead of being actual quotes, we felt as though the users were missing out on a good part of the experience. Therefore, we changed our technique.
The second attempt was to create a kind of fitness function for our list of quotes, and select which one is the most relevant (or "fit") as a reply based on the input data that the user provides (aka, a question or phrase). We first determined that we could get a reasonable answer by comparing the quotes to the input, word-by-word, and generating a list of the top 10 or so most similar quotes, and picking from there. Most of the time, having a keyword like "America" or "great again" or "wall" would give a quote that's on the subject, allowing for a somewhat natural discussion.
We had plans to expand on this idea and categorize the quotes into general buckets, and try to determine which bucket the input fell into to be able to get a response. Similarly, we were considering using keyword analysis to help branch into other, similar topics (i.e., "Obama" would be synonymous with "African American President", "our leader", "President", according to an analysis of the quotes we had), or at the very least help when determining which quote is most "fit" by its match compared to these different buckets. We made a couple of prototypes, but submitted the most stable version here, which used the second attempt described above.
How I built it
Challenges I ran into
The initial setup of the Alexa dev environment was a bit of an involved process. There was also somewhat of a learning curve when it came to the actual programming, but the Amazon developers made sure that it wasn't all that bad when it came down to it.
Accomplishments that I'm proud of
We managed to make Alexa, a kind and gentle-mannered little AI, into Donald Trump. That's one part scary and two parts cool.
What I learned
What's next for Trumper
We will work on implementing the stretch ideas and continue to tweak the project, since natural language is still very much an open field for study. Perhaps instead of writing our own algorithms, we will integrate with an API of some kind to be able to focus more on the perfecting of the project, rather than the actual gritty details of implementation.