Guided Lab: Amazon Alexa

Speech Recognition and Natural Language Processing usually go hand in hand to solve a multitude of problems in Interactive Technologies.

In this exercise, you will create a Custom skill for Amazon Alexa.

  1. Navigate to this link in your browser.
  2. Click the Sign In link on the top right corner of the page
  3. Proceed with using your Amazon account or create a new one. Irrespective of whether you use your existing account or created a new account, you will be asked for additional information to let you develop on Amazon Alexa platform, subject to its Terms and Conditions, etc.
  4. Proceed with the account creation and this will lead you to Alexa developer console
  5. Go ahead and create a new skill
    ASK Console
  6. On the skill creation page, give the following information
    • Skill Name
    • Locale: English (IN)
    • Choose a model to add to your skill : Custom
    • Choose a method to host your skill’s backend resources: Alexa-hosted (Python)
  7. Click Create Skill

The next page will prompt you for a template, select

Choose a template to add to your skill: Start from Scratch

  1. Once the skill is created, on the Build tab -> Go to Invocations -> Skill Invocation Name and give a 2 word invocation name for the Alexa skill (Eg: smarty sam)
  2. Save the model and build it
  3. Once the build is completed, go to the Test tab and select Development in Skill testing is enabled in: dropdown
  4. Either type launch {Skill Invocation Name} (Eg: launch smarty sam) or press and hold the microphone on the text box and say launch {Invocation name}
  5. The skill will respond you with Welcome, you can say Hello or Help. Which would you like to try?
  6. You could proceed with typing or saying hello to get the response Hello World!

This was a quick test of developing a new Alexa skill. Let’s add a new intent to this skill now and customise its response!

  1. Go to the Build tab -> Interaction Model -> Intents and click Add Intent
  2. Give a name for the intent (Eg: NameTheCEO). Note this down along with the capitalisation as we will need it later
  3. Give the sample utterances to invoke this intent
    • Who is the CEO of Atria University
    • Give me the CEO’s name of AU
    • What is the name of Atria University’s CEO
  4. Save the model and Build it
  5. Navigate to the Code tab and in the lambda_function.py file, and do the following
    • Add a new IntentHandler newIntentHandler such that your last lines in this files looks as follows
sb = SkillBuilder()

sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(HelloWorldIntentHandler())
sb.add_request_handler(newIntentHandler()) # This is the newly inserted handler
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(CancelOrStopIntentHandler())
sb.add_request_handler(FallbackIntentHandler())
sb.add_request_handler(SessionEndedRequestHandler())
sb.add_request_handler(IntentReflectorHandler()) # make sure IntentReflectorHandler is last so it doesn't override your custom intent handlers

sb.add_exception_handler(CatchAllExceptionHandler())

lambda_handler = sb.lambda_handler()
  • Let’s now define the newIntentHandler() by adding the following snippet in the line 20
class newIntentHandler(AbstractRequestHandler):
    def can_handle(self, handler_input):
        return ask_utils.is_intent_name("NameTheCEO")(handler_input)

    def handle(self, handler_input):
        return ( handler_input.response_builder.speak("The CEO of Atria University is Shaheem Rahiman").response )
  • Save and Deploy the code
    1. Navigate to the Test section and this time try the command ask smarty sam who is the CEO of Atria University
  1. You should listen to the response as you provided in the code
  2. Since the skill is developed and deployed in your own Amazon account, feel free to create more intents, associate their utterances, code their response and try it out

Lab complete

‚Äč Congratulations! You have completed the lab.

Last modified: January 31, 2022

Author

Comments

Write a Reply or Comment

Your email address will not be published.