serverless-sam
Version:
Serverless framework plugin to export AWS SAM templates for a service
103 lines (77 loc) • 3.63 kB
Markdown
<!--
title: AWS Serverless Alexa Skill example in Python
description: This example demonstrates how to setup your own Alexa skill using AWS Lambdas.
layout: Doc
-->
# Serverless Alexa Skill Example
This example demonstrates how to setup your own Alexa skill using AWS Lambdas.
## Use-cases
- Building custom Alexa skills
## How it works
In the Alexa Developer Portal you can add your own skill. To do so you need to define the available intents and then connect them to a AWS Lambda. The Lambda you can define and update with Serverless.
## Setup
In order to deploy the endpoint simply run
```bash
serverless deploy
```
The expected result should be similar to:
```bash
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
Serverless: Stack create finished...
Serverless: Packaging service...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading service .zip file to S3 (2 KB)...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
Serverless: Stack update finished...
Service Information
service: aws-python-alexa-skill
stage: dev
region: us-east-1
api keys:
None
endpoints:
None
functions:
aws-python-alexa-skill-dev-luckyNumber: arn:aws:lambda:us-east-1:377024778620:function:aws-python-alexa-skill-dev-luckyNumber
```
Next we need to setup a Alexa skill. Once you've signed up for the Amazon Developer Platform visit `https://developer.amazon.com/edw/home.html`. There you should see the following screen:

Next click on `Add a new Skill`:

Go through the steps and fill in all the required fields e.g. Intent Schema and Sample Utterances:
Intent Schema
```
{
"intents": [
{
"intent": "GetLuckyNumbers",
"slots": [
{
"name": "UpperLimit",
"type": "AMAZON.NUMBER"
}
]
}
]
}
```
Sample Utterances
```
GetLuckyNumbers what are my lucky numbers
GetLuckyNumbers tell me my lucky numbers
GetLuckyNumbers what are my lucky numbers lower than {UpperLimit}
GetLuckyNumbers tell me my lucky numbers lower than {UpperLimit}
```


Fill in the Lambda ARN which was printed or run `serverless info` to retrieve the ARN again.

Next up visit the test page, fill in the utterance and click on `Ask LuckyNumbers`.




You should have received a response containing the text `Your lucky number is` followed by your lucky number :)
Check out this [Amazon guide](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/overviews/steps-to-build-a-custom-skill#your-skill-is-published-now-what) to learn more about how to submit your skill for publication.