One month ago I read a the book “The Everything Store: Jeff Bezos and the Age of Amazon” iconic history of Amazon becoming the The Everything Store. I realize how was Jeff Bezos a fan of Star Trek. Some weeks later I received an email from Amazon Alexa Team introducing Alexa Skills for developer portal, I read about Alexa and I was thinking that it could be the beginning of has “The computer voice” audio interface equipped on Stark Trek federation starships (http://memory-alpha.wikia.com/wiki/Computer_voice) and that is fascinating. I realize the potential of this devices and even more the platform Alexa which enable everyone to create such novelty voice like Star Trek computer voice applications. I’ve started doing tutorials and think what I could do to get in touch with this technology.
I’ve started to brainstorming writing what application I could do enough simple but not too boring such that keep my interest on its development, finally I said well would like to build a conversation experience with alexa about querying movies and then I asked myself where I can find a whole set of movies which I can query pragmatically, such that I would not make the development too heavy or too complex then finally I was looking for a subset of movies ; the best movies based on some metric.
After Googling some times I found in the guardian a list of greates film of all times http://www.theguardian.com/news/datablog/2010/oct/16/greatest-films-of-all-time, so the next step was what can do I do with this data, and to keep it simple just though in ability to ask Alexa about movies of that subset of movies given a year or a range of years, so Alexa could speak back to me with her findings and the I could tell her what to do with what she found. so you can ask her to read the result of the movies found by saying read last five, or first ten or read first. The Alexa could start to read what movies found, what was his actors and his summary, etc. This way I could query and know when and which were the best movies based on rating of all the times.
So having that Idea in mind I’ve read Alexa tutorial pages http://amzn.to/1LGWsLG then I downloaded the Alexa example for python and start to work on top of this example code, I’ve workend on it to build the Best Movies app. I created a github repository with all the code here https://github.com/moisesweb/best_movies. The steps I did for create the Alexa app are below:
1. Create an amazon aws lambda function in aws console and upload the zip file which contains the lambda function code, then I added an Alexa Skills as event source for this lambda function. Finally I copied the ARN identifier which is introduced when creating the Alexa Skill en developer portal in step 2. The images below shows the step I performed to create the lambda function. (https://console.aws.amazon.com)
1.b Start to create lambda function.
1.c I skipped the the lambda function blueprint, instead I filled out the next screen with the language to use which is Python in this case, then upload the zip file containing the code and added the default handler `lambda_function.lambda_handler` and a basic role call `lambda_basic_execution`. In the source code I want to have a file calle `lambda_function.py` and in there a function call `lambda_handler` which will receive Alexa events.
1.d After I click on next it shows the resume of my function then I click on create function and message appear in notifying as show in 1.e
1.e Once I have the lambda function the next thing is add the event source which will communicate with this function in this case I selected Alexa skills kit and then submitted it.
1.g submit source event
2. I have entered in amazon developer portal in Alexa section and start to create an amazon Alexa Skill, just filled out the info requested, and put the ARN identifier of my lambda function such that Alexa can send events to it. (https://developer.amazon.com/)
2.a Start to create Alexa Skill
2.b Add new Skill
2.c Set app name and invocation name(The name for this could be Best Movies Lab)
2.d Setting up the Interaction Model ; I take the model and the custom slot types from the code, https://github.com/moisesweb/best_movies/blob/master/intent_schema.json, the same for the sample Utterances.
2.e In this step it is important to select Lambda ARN and set the ARN identifier shown in figure 1.f
2.f Once specified this ARN, it is time to test the function as shown in the figure below. At this point I had to back to aws console lambda section (figure 1.a) then edit the function and upload again the code, but before I needed to modify the code by copying this file `https://github.com/moisesweb/best_movies/blob/master/config.py.sample` and renaming it as `config.py`. To avoid unwanted events from other skills I modified the file `config.py` and set my alexa skill app id in `app_id` value. In the image below when I did the first test I found the `applicationId` value which set in the config file.
After set that app_id I compress the folder content and upload again, then I pressed `Save and Test`. I compressed as zip file, the the lambda files from inside the folder instead of outside.
3. Finally after iterate several times with Alexa testing facilities, developing code and fixing error, I submitted the Alexa Skill for certification. Then I wait for feedback and I’ve fixed some issues and resubmit until it get certified.
Now Best Movies is live. To make sure the skill will work without prior errors I wrote some unit and integration test, using events fixtures to emulate Alexa events and this way I could test the lambda function that make this skill works (https://github.com/moisesweb/best_movies/tree/master/test).