Message:

Subscribe rss
Blog categories
All | Backendless features
Developing Alexa skill without writing any code – Part1 (Codeless in Backendless mBaaS)
August 21, 2017 by markpiller
Spread the love

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, I will describe how to use Codeless to create a custom Amazon Alexa skill. In the first part, you will develop a basic Alexa skill which replies with a static greeting to a voice command. The second post 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 - Developing Alexa skill without writing any code - Part1 (Codeless in Backendless mBaaS)

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.

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 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 - Developing Alexa skill without writing any code - Part1 (Codeless in Backendless mBaaS)
  4. Backendless creates the API Service and will prompt you to create a method for the service. This will be the method which 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 - Developing Alexa skill without writing any code - Part1 (Codeless in Backendless mBaaS)
  5. Backendless creates a placeholder for the codeless logic of the method. Click the EDIT button to start switch to the Codeless Logic Designer:
    backendless api service step3 - Developing Alexa skill without writing any code - Part1 (Codeless in Backendless mBaaS)
  6. Alexa’s requests and response must be in a special format. In order to process requests and send responses back to Alexa, you will create a few reusable Codeless functions. Every codeless function is also represented by a dynamically generated block. It is a great way to apply logic reuse in your Codeless apps. Click the “Add New” node under Functions in the BROWSER section:
    backendless api service step4 - Developing Alexa skill without writing any code - Part1 (Codeless in Backendless mBaaS)
  7. In the created function placeholder block, click the area that says “doSomething” and change it to “sendAlexaResponse”. Click the SAVE button so the function is saved:
    backendless api service step5 - Developing Alexa skill without writing any code - Part1 (Codeless in Backendless mBaaS)
  8.  Click the gear icon located in the purple block right next to the word “Function”. Add two arguments by dragging the input blocks as shown in the image below. Assign the names of the arguments as “whatToSay” and “waitForResponse“. Notice that as you add arguments, the Context Blocks area is automatically populated with the blocks representing argument values:
    codeless function arguments - Developing Alexa skill without writing any code - Part1 (Codeless in Backendless mBaaS)
  9. Modify the function’s logic so it looks as in the image below. For the “Create Objects” blocks, use the gear icon to change the name of the object properties. Do not forget to save your work by clicking the SAVE button.
    sendAlexaResponse function - Developing Alexa skill without writing any code - Part1 (Codeless in Backendless mBaaS)
  10. Now that the custom function is built, switch back to the handleRequest method of the AlexaService service.
    backendless api service step6 - Developing Alexa skill without writing any code - Part1 (Codeless in Backendless mBaaS)
  11. Click the Custom Functions category in the toolbar on the left and drag the sendAlexaResponse block to connect with the return connector of your service method:
    backendless api service step7 - Developing Alexa skill without writing any code - Part1 (Codeless in Backendless mBaaS)
  12. Modify the logic of your method as shown below:
    backendless api service step8 - Developing Alexa skill without writing any code - Part1 (Codeless in Backendless mBaaS)
  13. 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.
  14. 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 - Developing Alexa skill without writing any code - Part1 (Codeless in Backendless mBaaS)

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 click the Alexa menu:
    alexa step1 - Developing Alexa skill without writing any code - Part1 (Codeless in Backendless mBaaS)
  2. Click the “Get Started >” button for “Alexa Skills Kit”, then click the “Add a New Skill” button:
    alexa step2 - Developing Alexa skill without writing any code - Part1 (Codeless in Backendless mBaaS)
  3. Enter app name and invocation name as shown below. The app name is used to identify the app in the list of installed apps for your Alexa-enabled device. The “invocation name” is used when you want to trigger your Alexa skill. For the example below, you will say “Alexa, ask my demo….”. Click SAVE at the bottom of the screen:
    alexa step4 - Developing Alexa skill without writing any code - Part1 (Codeless in Backendless mBaaS)
  4. Click Next to switch to the Interaction Model step. This is the step where you write up possible utterances a user may speak when communicating with your Alexa skill. Paste the following text into the Intent Schema field:
  5. Scroll down to the “Sample Utterances” field and paste the following. This is what a user may say when communicating with your Alexa skill. The first word identifies the intent, which is registered in the previous step:
  6. Click Next at the bottom of the screen. The next step is Configuration. This is where you configure your Alexa skill to point to the Codeless API Service you deployed. Select HTTPS in the Endpoint section and paste the URL you copied in step 14 above into the Default text input:
    alexa endpoint configuration - Developing Alexa skill without writing any code - Part1 (Codeless in Backendless mBaaS)
  7. Click Next to proceed to the final configuration step: SSL Certificate. Make the selection as shown in the image below and click Next:
    alexa servlerless endpoint certificate - Developing Alexa skill without writing any code - Part1 (Codeless in Backendless mBaaS)
  8. The Test step can be used to test your Alexa skill. Scroll down to the Service Simulator and type in “how is it going” into the Enter Utterance field. Click the Ask Backendless button to send a request. You will see the response from your Codeless service in the Service Response area:
    sample alexa request - Developing Alexa skill without writing any code - Part1 (Codeless in Backendless mBaaS)
  9. 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:

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 the next part, 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.

Share this post
Tweet about this on TwitterShare on FacebookGoogle+