This tutorial has been updated on 6th September, 2019. If you have done the tutorial before, you’ll need to do it again. The biggest change is now you get a responsive web page to add channels and stations.
Create your own Alexa Radio Skill with your favourite streaming stations or audiobooks. Once deployed, you can say “Alexa, open radio” and Alexa will start streaming your custom station.
Adding and deleting your stations is a breeze with a responsive web page your API will automatically serve. Add channels, which are a collection of stations, easily. If you’re adding an audiobook, the channel name will be Game of Thrones and each station would be the individual books.
You can ask Alexa for a channel or a station by name. If you say “Alexa, ask radio to play Blues”, the skill will first search for a channel with that name and then the stations. If a channel is found, a random station from that channel is played. If it’s an audiobook, it would resume playing where you last stopped.
You can also customise what Alexa will say when you go to the next station or when encountering an error, using the web page.
Check out a live demo — Alexa Radio
Deploying it is incredibly easy thanks to Standard Library. It involves two steps, lots of button clicking and some copy pasta.
The first step is to deploy your code to Standard Library. Right-Click on the button below and open the link, to deploy.
Click here to deploy to Standard Library
On the new page, click on the Generate Identity button. Once that’s done, click on the Deploy Project button under it to deploy the code.
After the code is deployed, you’ll be taken to your project page. Here you can change your project name and add your own description.
Now click on the dev button to see all the endpoints of your project.
Note down the second URL. You’ll need it for the next step. If you are curious, click on the first link and you can see the web page to add and delete your custom stations.
Go to developer.amazon.com to create a new Alexa Skill. If you haven’t signed up for an Amazon Developer account yet, do so now. Once logged in, you should see the Create Skill button.
Give your skill a name like radio and choose your Default Language. Choose Custom for model to add to your skill and click on Create Skill.
On the next screen, choose Start from scratch.
Once you have created the Alexa Skill, click on JSON Editor at the bottom left. Delete everything inside it.
Replace the entire contents with the contents from the AlexaInteractionModel.json on the GitHub repo
Right-click and open the AlexaInteractionModel.json file on the Github repo. Copy the file contents.
Go back to the Alexa developer portal, and paste it into the JSON Editor. Click on Save Model, to save the model.
The invocation name is set as radio. To change the name, just change the invocationName value at the top of the JSON file.
We are almost done. Click on Endpoint to link our Standard Library deployed code to the Alexa skill. Enter the Standard Library API URL you noted earlier.
Your endpoint should look like https://[username].api.stdlib.com/[email protected]/alexa. Make sure you choose My development endpoint is a sub-domain of a domain option from the drop down menu.
Next, click on Interfaces and turn on the Audio Player interface. The skill will not work without this being enabled.
That’s all the setup you need to do. In the Alexa Development portal, click on Build Model. This might take a couple of minutes.
Once you get the pop-up saying that the Build Succeeded, click on the Test tab next to Build on the Alexa Developer console. Turn on testing and type in open radio. You should get a reply asking you to go to the web page to add your stations.
If you get a reply on the console, it means the skill is also active on your Alexa device. Ask the same question to your device and you should get the same reply.
Now let’s add some channels with stations. Go to your main Standard Library URL, which is the first URL noted below.
Clicking on the above link will open a web page where you can add channels and stations, as well as customise Alexa responses.
Let’s add a channel first. Channels are like playlists, based on a mood or genre. In the case of an audiobook, it would be the book series name. Click on the Channel button to add a new channel.
This will open a modal where you can add details of your channel. You can add multiple stations here. A few things to note:
https
s
if needed for the URL so it is a https
linkClick on the Save button once you’ve added your channel. You can of course add more channels if you want.
You can also rename any of the channels, stations or edit the URL by clicking on them.
You can customise Alexa responses by clicking the gear icon on the top right of the main page. Here you can add or remove the responses.
Use SSML if you want, to give it more personality.
Notes
If you get stuck anywhere, or if you have any feedback, write to me. You can find the code repository here.
Thanks to Janeth Ledezma and Jacob Lee.