Blog

Developing an Alexa Skill Without Writing Any Code (Part 1)

by on August 21, 2017

Codeless Programming is a general approach for creating programs without writing any code. When combined with the power of the Backendess mBaaS, Codeless becomes a powerful and super-efficient tool. In this post, we will describe how to use Codeless to create a custom Amazon Alexa skill. In this first part, you will develop a basic Alexa skill which replies with a static greeting to a voice command. In the second part, we will delve into a more complex implementation.

You can see a demo of what you will build over the course of both posts in the video below:

Before we start, take a look at the diagram below. It illustrates a typical flow between the “moving parts” when a user interacts with Alexa:

  1. The user speaks a “command” to an Alexa-powered device, such as Echo Dot, invoking one of the installed apps.
  2. Echo sends the command to the Amazon Alexa service.
  3. Alexa interprets the voice command and sends it for processing to an API service or a Lambda function.
  4. The API service applies the logic to handle the command.
  5. Once the command is handled by the logic, the service sends a response back to Amazon/Alexa.
  6. Alexa delivers the response to the original device.
  7. The device speaks the response to the user.

alexa-flow
In order to create an Amazon Alexa skill with Backendless, you will need the following:

  1. A Backendless developer account. You can register for free at https://develop.backendless.com/registration
  2. An Amazon developer account with access to the Amazon developer portal.
  3. Install Backendless SDK for Alexa from the Backendless Marketplace.

Install Backendless SDK for Alexa

The Backendless SDK for Alexa significantly simplifies the process of developing a custom skill. It includes the functionality for retrieving data from the received requests and sending the responses back to Alexa. The SDK is available in Backendless Marketplace. The SDK is free of charge, however, an application must be on a paid plan to be able to install a product (the SDK in this case) from the Marketplace. If your app is on the Free Plan, you will need to add a credit card (it will not be charged).

  1. Login to your account in Backendless Console and select or create an app.
  2. Make sure the app is on a paid plan and has a credit card added to the account on the Manage > Billing screen.
  3. Click the Marketplace icon in the vertical bar on the left, then click the All Services section.
  4. Click the product box for SDK for Amazon Alexa:
    sdk-alexa-marketplace
  5. Click the INSTALL and then ACTIVATE button.
  6. Verify that the SDK is installed by switching to the Business Logic (Cloud Code) screen. You should see the AlexaUtils service:
    alexautils-methods

Developing a Codeless API Service

  1. Log in to your account in Backendless Console. If you do not have an app in your account, create one.
  2. Click the Business Logic (Cloud Code) icon located in the icon bar on the left. You will see the API SERVICES screen.
  3. Click the “+” icon to create a new service. Make sure to select CODELESS in the “New Service” popup. Enter “AlexaService” for the service name. Click the SAVE button:
    backendless-api-service-step1
  4. Backendless creates the API Service and will prompt you to create a method for the service. This will be the method that will process requests from Alexa. Enter “handleRequest” for the method name. Make sure to select POST for the REST operation, and declare an argument with the name of “req” and type “Any Object” as shown below:
    backendless-api-service-step2
  5. Backendless creates a placeholder for the codeless logic of the method. Click the EDIT button which will open the Codeless Logic Designer:
    backendless-api-service-step3
  6. When the Logic Designer opens, locate the API SERVICES section which will contain the AlexaUtils service. The AlexaUtils service contains all the functions provided by the SDK for Alexa. Locate the sendAlexaResponse block and drag it into the Logic Designer work area:send-alexa-response-codeless-article
  7. Modify the logic of your method as shown below:
    hello-from-a-codeless-service
  8. Click the DEPLOY button in the upper right corner of the Codeless Logic Designer. At this point, the service is ready and can process Alexa requests.
  9. Click API SERVICES and then click the show full URL button. The displayed URL identifies your Codeless service operation on the Internet. You will need to use it in one of the steps when configuring an Alexa app in the Amazon Developer portal (see the instructions below).
    backendless-api-service-step9

Registering Your Alexa App

  1. To get started, you need to register an app in the Amazon developer portal. Log in to your account and select Alexa Skills Kit > Learn > Start A Skill Now as shown in the screenshot below:
    starting-new-skill-amazon
  2. Click the Create Skill button.
  3. Enter a name for your skill and click Next.
  4. Click Select for the Custom box and click the Create skill button.
  5. There are four steps for configuring a custom skill. You can see them in the Skill Builder Checklist:
    skill-builder-checklist-demo-skill
  6. Click the first step (“Invocation Name”).  Enter an invocation name. The “invocation name” is used when you want to trigger your skill by saying: “Alexa, ask <invocation name>….“. Click the Save Model button at the top of the screen:
    save-model-alexa-skill
  7. Click the “+ Add” button in the Intents menu as shown below:
    add-intent-screen
  8.  You will need to create a custom intent. Enter Demo in the field for the intent name and click the Create custom intent button.
  9. In this step you will write up possible utterances a user may speak when communicating with your Alexa skill. These utterances will be mapped to the intent you just created. Whenever Alexa recognizes a particular phrase, the request sent to the skill will include the name of the intent. Add the following utterances using the text box on the screen (pressing Enter will add an utterance to the list):
    to say something
    how is it going
  10. Once you are done entering utterances, your intent configuration screen will look as shown below:
    alexa-skill-utterances
  11. Click the Save Model and then Build Model buttons at the top of the screen. Once the model is built, click the Endpoint menu.
    endpoint-menu-alexa-skill
  12. The Endpoint step is where you configure your Alexa skill to point to the Codeless API Service you deployed. Select HTTPS and paste the URL you copied in step 9 above (from the “Developing a Codeless API Service” section) in the into the Default Region text input.
  13. In the Select SSL certificate type drop-down select “My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority”.  Click the Save Endpoints button. The final selection on the Endpoint screen should look as shown below:
    endpoint-alexa-skill
  14. To make sure everything is configured and you didn’t miss any configuration properties click the CUSTOM menu in the upper left corner of the interface and inspect the Skill builder checklist, it should look as shown below:
    skill-builder-checklist-complete

Testing the Skill

  1. Click the Test tab in the horizontal menu. Before you can test the skill, Test must be enabled for the skill using the toggle:
    enabling-test
  2. Once the test is enabled, type in or speak a request and press Enter. Alexa invokes your skill in Backendless and provides a visual response. Additionally, you can see both JSON Input (request sent to the skill) and JSON Output (the response sent by the skill back):
    testing-alexa-skill-from-amazon
  3. Now that you tested the service and confirmed that you receive a valid response, you can test the skill on your Alexa device. Install the skill and say:
    "Alexa, ask super demo how is it going"
    

This concludes Part 1 of Building an Alexa skill with Codeless. The service you built is very basic, and most of the time went into configuring it. In Part 2, I will show you how to enhance your Codeless logic for more advanced processing, such as working with speech slots and using Backendless mBaaS Database in your service.

Leave a Reply