Blog

Developing an Alexa Skill Without Writing Any Code – Part 2 (Intents and Slots)

by on December 21, 2017

This is Part 2 of the article about developing an Amazon Alexa skill without any coding. In Part 1, you learned the following:

  • How to create a Codeless API Service responsible for handling Amazon Alexa requests. The service completely removes the need for adding AWS Lambda functions and runs without any cost in the free plan of Backendless.
  • How to use the Backendless SDK for Alexa to send a response back to Alexa from a custom skill.
  • How to create a basic Alexa Skill and test it from the Amazon developer console.
  • How to invoke the skill on Alexa, process the invocation in your Codeless Backendless API service and get a response back on Alexa.

In this article, you will learn the following:

  • Creating a voice interaction model with “slots” – special placeholders for the “dynamic” parts of the requests for your skill.
  • Processing slots in the Codeless API service in Backendless.
  • Executing codeless logic to do something useful and generate a meaningful response.

We strongly recommend you go through Part 1 just so you have the basic environment setup. Also, make sure to watch the “Developing an Alexa Skill without any coding” video, which shows the entire process in action.

Interaction Model Slots

  1. To get started, log in to your Amazon Developer Portal account. Locate the skill you created in Part 1 and click the “edit” link.
  2. Click the “+ Add” button next the Intents menu to create a new custom intent.
  3. Type in Table and click the Create custom intent button.
    creating-new-custom-intent
  4. Add the following sample utterances:
    What is the size of the {TableName} table
    How big is the {TableName} table
    How many objects are in the {TableName} table
    What is the object count of the {TableName} table
    

    The word in the parenthesis is the slot name – “TableName”. So what is a slot? From the video, you might remember I was asking Alexa:

    “how many objects are in the Users table”

    The name of the table here is a dynamic part, I could have asked about the Person table or any other table for that matter. Slots in the intent schema are what makes it possible. Think about slots as the arguments for an intent.

  5. As you entered the utterances listed in the previous step, the TableName slot is automatically created:
    tablename-slot-alexa
  6. A slot must have a slot type. Think about it as a “dictionary” of all the words which can be put into the slot in the sample utterances. In my demo, the slot may have the names of some data tables such as Users, Person, Order, etc. To define these, we should create a custom slot type. To do that, click the “+ Add” button next to the Slot Types menu:
    adding-slot-type
  7. Enter BackendlessTable for the custom slot type name and click the Create custom slot type button.
    backendlesstable-custom-slot-type
  8. Enter the following values as the slot values:
    Users
    Person
    Address
    Order
    OrderItem
  9. Once the slot type values are added, return to the TableName slot definition and select the newly created slot type:
    slottype-in-slot-definition
  10. Click the Save Model button and then the Build Model button at the top of the screen. The next step is to add the logic for processing the requests on the Backendless side.

API Service for the Alexa Skill

  1.  In part 1, you already created a basic service for the Alexa skill. The service returned a constant string value. The logic to handle a request with dynamic parts (slots) is quite different. To locate the existing method, expand the AlexaService node and click the handleRequest method:
    handle-request-method
  2. Remove any codeless blocks you already had in the method as you’d be starting with a blank logic. Compose the logic as shown below. Make sure to use the blocks from the AlexaUtils service, which contains the functionality provided by the Backendless SDK for Alexa:
    alexa-skill-codeless-complete
  3. Click the DEPLOY MODEL button when you are done. Once the service is deployed, you can test your Amazon Alexa skill. To do this, simply ask:
    Alexa, ask super demo how many objects are in the Users table

    where super demo is the skills’ invocation name configured in Amazon Developer Portal (see the Information section)

Happy Codeless Coding!

Leave a Reply