Skip to main content
Warning: this assignment is out of date. It may still need to be updated for this year's class. Check with your instructor before you start working on this assignment.
This assignment is due on Monday, April 11, 2022 at 11:59PM EST.

Homework 6: Alexa Action Castle


For this homework you will re-implement your Action Castle game from Homework 1 but turning it into a task-oriented dialog system, specifically in the form of a “Skill” for Amazon Alexa. You will be able to reuse a lot of the code you wrote in Homework 1, but the focus of this homework will be to implement commands using Alexa Intents and a command parser by creating Alexa Request Handlers. You can use the original Action Castle game, or if you want to be creative, you can implement any other interactive fiction game you would like. We will play all of your games and give full credit if there are no errors in the flow of the game.

You will not be using Colab for this assignment.


Before we explain what you will be doing, there are first some Alexa-specific terms we need define.

  • Skill: A 3rd party application for Amazon Alexa.
  • Request: What the user is trying to accomplish when they talk to Alexa.
  • Request Handler: The processes that send and receive requests.
  • Intent: A schema for capturing the Request (i.e., taking a command and turning it into something Alexa can work with).
  • Slot: Variables within an Intent.
  • Interaction Model: Determines whether the current Skill can handle certain Requests.

Starter Code

We have provided starter code for an Alexa adventure game. You are free to modify it however you want and bring in any dependencies you feel will be useful, but do not forget to add them to requirements.txt.

  • The file contains all of the Request Handlers. Add your Request Handlers here.
  • and hold all of the Action Castle code. Put your game code here.
  • is just a list of global constants you want the entire application to have access to. You might not need this.
  • You probably won’t need to edit unless you want to add extra utilities.

Setting up the Environment

Click on the "Console" button Sign in to the Alexa Developer Console (see image above).

Then click on “Create Skill”. Select the Custom Model and Alexa Hosted (Python) options. In the next page select the Start from Scratch option. Once you create your skill, click on it and go on the Code tab. There you can copy and paste the template files we gave you in, or even better, you can use Python’s import functionality.

What to Do

You will be defining a set of Amazon Intents and implementing Request Handlers to parse them. You may find it useful to look into the ASK Skills Documentation.

In, each Request Handler has its own class, and within that class there is a can_handle() function and a handle() function. can_handle() is where you specify the Intent (aka the keywords) to trigger this. handle() is what will happen when it’s triggered.

Add a new Handler class for each command and then add it to the SkillBuilder() at the end of the file with the command sb.add_request_handler(yourHandlerClass()). Note: We have implemented the “direction” Request Handler for you (lines 30-70 of You will still have to implement the Intents in the Interaction Model. You can use the “direction” Request Handler as a guide for creating other Request Handlers.

Once you have your Handlers all setup, you need to add them to the Interaction Model as Intents. You can find the Intents in the Developer Console by going to the “Build” tab, selecting “Interaction Model” and then “Intents”. The Intents page should look something like this: Interaction Model

Some Useful Commands

  • ask_utils.is_request_type(type)(handler_input): checks if the Request type is equal to the input type.
  • ask_utils.is_intent_name(name)(handler_input): checks if the Request Intent name is equal to the input name.
  • ask_utils.request_util.get_slot(handler_input, slot_name): returns an object of the Slot with name slot_name. You can use obj.value to get the string name of the Slot.


  • You can test your Skill in the Test tab of the console. The logs from there will be on CloudWatch.
    • Important: To start the Skill, you will first need to say/type: open action castle
  • You can use CloudWatch to debug your code. When you are in the Code tab in the Alexa developer console, you can click on CloudWatch logs to be directed on your skill’s log output.

Invite Beta Testers

In order to submit your code, you should invite the TAs as beta testers. Here are the instructions on how to do this. Our emails & When you release a Skill for beta testing you need to complete the Privacy and Compliance Component. You can safely answer no to all those questions.

What to Submit

You should invite the TAs to be beta testers for your Skill, as instructed in the relevant section above. You should also submit:

  1. A text file called playthrough.txt with all of the commands that we would need to complete your game. It shold be a plain text file with one command per line.
  2. A zipped folder called that contains the code for your game.

Submissions should be done on Gradescope.


  • Play through runs fully (full points)
  • Play through runs but not complex enough (50% points)
  • Playthrough plays partially but errors at some point (50% points)
  • Skill does not start up but code shows effort (30% points)
  • The code and the play through show inadequate exploration of Alexa API documentation (0% of the points)