This skill demonstrates how to create a single stream audio skill. Single stream skills are typically used by radio stations to provide a convenient and quick access to their live stream.
User interface is limited to Play and Stop use cases.
Alexa, play my radio
Alexa, stop
You will need to change a few configuration files before creating the skill and upload the lambda code.
This is a NodeJS Lambda function and skill defintion to be used by ASK CLI.
You need to initialize ASK CLI with
$ ask init
You need an AWS account and an Amazon developer account to create an Alexa Skill.
You need to download NodeJS dependencies :
$ (cd lambda && npm install)
$ (cd lambda/src && npm install)
-
./skill.json
Change the skill name, example phrase, icons, testing instructions etc ...
Remember than many information are locale-specific and must be changed for each locale (en-GB and en-US)
Please refer to https://developer.amazon.com/docs/smapi/skill-manifest.html for details about manifest values.
-
./lambda/src/audioAssets.js
Modify each value in the audioAssets.js file to provide your skill at runtime the correct value : your radio name, description, icon and, obviosuly, URL of your stream (https only).
To learn more about Alexa App cards, see https://developer.amazon.com/docs/custom-skills/include-a-card-in-your-skills-response.html
var audioData = {
title: "<The title of the card for the Alexa App>",
subtitle: "<The subtitle of the card for the Alexa App>",
cardContent: "<The contect of the card for the Alexa App>",
url: "<your stream HTTPS URL>",
image: {
largeImageUrl: "<the HTTPS URL of your large icon for the Alexa App>",
smallImageUrl: "<the HTTPS URL of your small icon for the Alexa App>"
}
};
./models/*.json
Change the model defintion to replace the invocation name (it defaults to "my radio") and the sample phrases for each intent.
Repeat the operation for each locale you are planning to support.
This code is using Mocha and Chai to test the responses returned by your skill. Before to deploy, be sure to have no test failures.
Execute your test by typing
$ (cd lambda && npm test)
ASK will create the skill and the lambda function for you.
Lambda function will be creadted in us-east-1
(Northern Virginia) by default.
You deploy the skill and the lambda function in one step :
$ ask deploy
You can test your deployment by FIRST ENABLING the TEST switch on your skill in the Alexa Developer Console.
Then
$ ask simulate -l en-GB -t "alexa, play my radio"
✓ Simulation created for simulation id: 4a7a9ed8-94b2-40c0-b3bd-fb63d9887fa7
◡ Waiting for simulation response{
"status": "SUCCESSFUL",
...
You should see the code of the skill's response after the SUCCESSFUL line.
Once the skill and lambda function is deployed, do not forget to add the skill id to lambda/src/constants.js
to ensure your code is executed only for your skill.
Uncomment the AppId
line and change it with your new skill id. You can find the skill id by typing :
$ ask api list-skills
{
"skills": [
{
"lastUpdated": "2017-10-08T08:06:34.835Z",
"nameByLocale": {
"en-GB": "My Radio",
"en-US": "My Radio"
},
"skillId": "amzn1.ask.skill.123",
"stage": "development"
}
]
}
Then copy/paste the skill id to lambda/src/constants.js
module.exports = Object.freeze({
//App-ID. TODO: set to your own Skill App ID from the developer portal.
appId : "amzn1.ask.skill.123",
// when true, the skill logs additional detail, including the full request received from Alexa
debug : false
});
To be able to invoke the skill on your device, you need to login to Alexa Developer Console, and enable the "Test" switch on your skill.
See https://developer.amazon.com/docs/smapi/quick-start-alexa-skills-kit-command-line-interface.html#step-4-test-your-skill for more testing instructions.
Then, just say :
Alexa, open my radio.