← Blog Β· Tutorial

Build an Alexa Skill with Node.js and Jovo

Jan KΓΆnig Β· Β· Updated Jan 2024 Β· 15 min read

In this tutorial, you'll build a fully functional Alexa Skill using Node.js and the Jovo Framework. By the end, you'll have a working skill that you can test on your Echo device or the Alexa simulator β€” and a solid foundation for building more complex voice applications.

What you'll learn

  • βœ“ Setting up a Jovo project with the Alexa platform plugin
  • βœ“ Defining intents and entities in the Jovo Language Model
  • βœ“ Writing handlers for LAUNCH, YesIntent, NoIntent, and HelpIntent
  • βœ“ Managing session state across multi-turn conversations
  • βœ“ Testing locally with the Jovo Debugger
  • βœ“ Deploying to AWS Lambda

Prerequisites

Before you start, make sure you have:

Step 1: Install the Jovo CLI

The Jovo CLI is your main tool for creating, running, and deploying voice apps. Install it globally:

$ npm install -g @jovotech/cli

$ jovo --version # Should output 4.x.x

Step 2: Create a New Project

Scaffold a new Alexa-specific project using the CLI:

$ jovo new my-alexa-skill --platform alexa

$ cd my-alexa-skill

This creates a project with the Alexa platform plugin pre-configured, a basic handler, and a language model with sample intents. The project structure looks like this:

my-alexa-skill/

β”œβ”€β”€ src/

β”‚ β”œβ”€β”€ app.ts

β”‚ β”œβ”€β”€ components/GlobalComponent.ts

β”‚ └── output/

β”œβ”€β”€ models/en.json # Language model

β”œβ”€β”€ jovo.project.ts

└── package.json

Step 3: Define Your Intents

Open models/en.json and define the intents your skill will handle. Each intent has a name and a list of sample phrases:

{

"invocation": "my quiz app",

"intents": {

"YesIntent": { "phrases": ["yes", "sure", "yep"] },

"NoIntent": { "phrases": ["no", "nope", "nah"] }

}

}

Step 4: Write Your Handlers

Handlers are where you define what happens when each intent is triggered. Open src/components/GlobalComponent.ts:

import { Component, BaseComponent, Global } from '@jovotech/framework';

@Global()

@Component()

export class GlobalComponent extends BaseComponent {

LAUNCH() {

return this.$send({

message: 'Welcome to my quiz! Ready to play?',

listen: true

});

}

YesIntent() {

return this.$send({

message: 'Great! Here is your first question...'

});

}

NoIntent() {

return this.$send({

message: 'Okay, maybe next time. Goodbye!'

});

}

}

Step 5: Test Locally

Start the local development server:

$ jovo run

Local dev server on port 3000...

βœ“ Webhook: https://webhook.jovo.cloud/abcdef

Open the Jovo Debugger in your browser to simulate conversations without needing a physical Echo device. You can send test requests, inspect the JSON request/response, and trace the handler flow in real time.

Step 6: Deploy to AWS Lambda

When you're ready to go live, deploy to AWS Lambda with a single command:

$ jovo build --platform alexa

$ jovo deploy --platform alexa

This packages your code, uploads it to Lambda, and updates the Alexa Skill manifest and interaction model in the Amazon Developer Console β€” all automatically.