Message:

SDK for Amazon Alexa

This is an SDK with APIs you will find useful for developing and deploying a custom Amazon Alexa skill. Custom skills can be implemented with Java, JavaScript or Codeless. The APIs available in the SDK can be consumed from any of these programming languages. The SDK should be installed from Backendless Marketplace using Backendless Console. Once installed, the APIs become instantly available in your Backendless app.

Other Marketplace Products

About the Product

Developing a custom Amazon Alexa skill requires you to process information from the Amazon Alexa requests. For example, your skill may need to determine the intent or obtain a value for a slot. These and other utility APIs are available in the SDK for Amazon Alexa. Additionally, publishing your skill to Amazon's Alexa skill store requires a special validation of the skill. The SDK includes an implementation of the validation algorithm which you can embed into your skill implementation.


Installation

To install the SDK:

  1. Login to Backendless Console and select your app
  2. Click the Marketplace icon in the vertical toolbar on the left.
  3. Click the All Services section and locate the SDK for Amazon Alexa.
  4. Click the Install button and the click Activate in the popup.
  5. Once installed, you will be able to confirm it by going to the Business Logic section of the console. You will see the AlexaUtils API service which provides the APIs documented below:
    alexautils methods - SDK for Amazon Alexa

Available APIs

The SDK provides access to the following APIs:

  • getIntentName – retrieves the name of the intent from the request sent by the Alexa service.
  • getSlotValue – retrieves the value for a slot for an intent.
  • sendAlexaResponse  – sends a response back to the Alexa service.
  • sendProgressiveAlexaResponse – sends an intermediary “progressive” response to Alexa while the skill is processing the original request. The progressive response is useful when you want to let the user know that the skill is still processing the request and needs more time. For more information about progressive Alexa responses, see the documentation.
  • verifyRequest – performs a verification of the request sent by the Alexa service. This is a required operation for the custom skills published to the Amazon Alexa skills store.
  • getRequestType – returns the type of the Alexa service request received by the skill. Returns one of the following values: LaunchRequest, IntentRequest or SessionEndedRequest.
  • isStarted, isInProgress, isCompleted – provide information about the state of the slots for the current intent. As user answers Alexa/skill’s questions and provides more information to fill up the slots, the APIs help the developer to determine if all the slots have the information.

getIntentName


The getIntentName  API has one argument, which is the request object sent by the Alexa service. The API returns a String  value which is the name of the intent. The API can be invoked from a custom Alexa skill as shown below:

From Java code:

From JavaScript code:

From Codeless logic:
getintentname codeless - SDK for Amazon Alexa

 

getSlotValue


The API has three arguments: (1) request object sent by the Alexa service, (2) intent name and (3) slot name. The operation locates the specified intent in the request and then retrieves the value for the specified slot name.

Using the API from Java code:

Using the API from JavaScript code:

Using the API from a Codeless logic:

get slot value codeless - SDK for Amazon Alexa

 

sendAlexaResponse


The API delivers a response from the skill to the Alexa service. The operation accepts two arguments: (1) a String object with a response which will be spoken to the user by Alexa. The string may contain SSML tags and (2) a boolean value indicating whether Alexa should wait for a response from the user.

Using the API from Java code:

Using the API from JavaScript code:

Using the API from a Codeless logic:

send alexa response codeless - SDK for Amazon Alexa

 

sendProgressiveAlexaResponse


A progressive response can be used whenever your skill needs more time to process a request and you want to let the user know you are still working on it. A progress response doesn’t require any response from the user, it is more of a verbal update so the user knows what’s going on. Think about it as a spoken “progress bar” indicating the progress of the performed action. For more information about progressive responses, see Amazon’s documentation. The operation accepts two arguments: (1) current request from Alexa, this is the request which the skill is processing and (2) a String object with a response which will be spoken to the user by Alexa. The string may be either plain text or contain SSML tags.

Using the API from Java code:

Using the API from JavaScript code:

Using the API from a Codeless logic:
progressive alexa response - SDK for Amazon Alexa

verifyRequest


Alexa service request verification is a mandatory step for any custom Alexa skill which will be published to the Amazon Alexa Skills store. Verification is a part of the certification requirements. This API performs request verification so your skill can take advantage of it with a single API call. The API accepts a single argument which is the request object. If the request is valid, the skill’s code will continue the execution. Otherwise, an error will be thrown and code execution will be aborted.

Using the API from Java code:

Using the API from JavaScript code:

Using the API from a Codeless logic:
verifyrequest codeless - SDK for Amazon Alexa

getRequestType


Determines and returns the type of the request from the Alexa service. The return value can be one of the following:

  • LaunchRequest – a request sent by the Alexa service when the user invokes the skill with the invocation name, but does not provide any data to map the request to an intent.
  • IntentRequest – sent when the user speaks a command which maps to an intent. The request includes the specific intent and defined slots (not all the slots may be filled yet, see the isCompleted method for more information).
  • SessionEndedRequest – a request when a currently open session is closed. The session can be closed when (1) the user says “exit”, (2) the user does not respond or says something that does not match an intent in your voice interface, (3) an error occurs.

For more information on request types, see Amazon’s documentation.

Using the API from Java code:

Using the API from JavaScript code:

Using the API from a Codeless logic:
get request type codeless - SDK for Amazon Alexa

isStarted, isInProgress, isCompleted


These APIs let you quickly determine the state of the slots for the intent. As the user provides information which fills up the slots the state of the request transforms from “started” to “completed”. The APIs help you determine the state of the request with regards to how completed the slots are with the data provided by the user:

  • isStarted – returns true if none of the slots have been filled up with the data provided by the user;
  • isInProgress – returns true if some of the slots have been filled up with the data provided by the user;
  • isCompleted – returns true if all of the slots have been filled up with the data provided by the user;

Using the API from Java code:

Using the API from JavaScript code:

Using the API from a Codeless logic:
isinprogress codeless - SDK for Amazon Alexa