I often find myself in the dire situation of needing a new movie or show recommendation, but typing into search engines is so tedious! Enter "Pick Flick" which leverages the Alexa Skills Kit and the NetflixRoulette API to allow users to find their next film using only their voice.
I began this project as a way to learn a new platform during my Thanksgiving break. I am happy to say that I learned about several new topics, including Alexa Skills & AWS Lambda functions.
Programming for voice interaction is quite different from building a graphical UI, but also quite freeing.
Part 1 - Initial Implementation
I began the process of developing the application by reading through Amazon's documentation of the Alexa Skills Kit (ASK), best practices tips & some sample skills (more on that later).
Based on the recommendations, I started with the design of the Voice User Interface. I went through several iterations, and based on usability & the data set available in the API, I ended up with the flow below:
I implemented this first pass based on another Hackster.io project, the Alexa Hurricane Center. I learned a great deal from reading through that project's excellent documentation. I quickly found the ecosystem had improved since it was published, and refactored my code to leverage the alexa-app npm module by Matt Kruse.
Matt's module makes declaring Intents and handling interactions so much easier than using the "raw" methods. Especially helpful is the ability to define utterances in a format which allows for dynamic generation of the many possible combinations of natural speech.
app.intent('MovieByDirector', {
'slots': {
'Director': 'AMAZON.LITERAL'
},
'utterances': ['{find|pick|get|recommend} {movies|shows|a movie|show} directed by {onename|two name|three word name|Director}']
},
getMoviesByDirectorOrActor
);
Part 2 - Enhancing the Experience
Based on the NetflixRoulette API, I found that the most reliable way to interact with the user would be ask them to provide the name of an actor or director as the seed for the interaction. However, since (most) actors & directors participate in many films, I didn't want a one-and-done interaction. I felt it would be best to allow the user to skip movies they had already seen, or were not interested in.
In order to accomplish a back-and-forth exchange, I leveraged the "session" support available in ASK. I was pleasantly surprised to see that the session support was simple & flexible. Essentially developers are able to store arbitrary JSON data in the response to the Alexa-enabled device. If the user makes a further request, the subsequent request will send back the session data which can be leveraged further.
In my case, I decided to store the list of available movies in the session storage. This allows me to tell the user that there are additional selections available and they can respond with "Pick another one" to get a new recommendation based on the original result set. An added benefit of this approach is that it reduces the number of calls back to the NetflixRoulette API, helping to reduce load & cost.
One of the guiding principles of Alexa Skill development is simplicity. Keeping spoken responses short and to the point is critical. Initially, I had planned to have Alexa read out the entire movie summary to the user. However, that proved to be unwieldy and left test users annoyed. Instead I decided to leverage another ASK capability: Home Cards.
Home Cards are displayed in the user's Alexa app in order to provide extended information connected to a voice interaction. These turned out to be a perfect place to display movie posters, descriptions & ratings. (The movie posters are currently disabled due to a CORS issue)
Part 3 - Further Development
While I was able to get rather far with my first Alexa Skill in just a short time, there are definitely some areas I would love to improve on. Implementing Genre search would be a prime example which would leverage a Custom Slot Type.
I would like to offer the user additional sort methods or default settings, like a minimum star-rating.
I plan to continue development so watch the GitHub repo for updates, or send me a PR if you have an idea of your own.
Comments