Create an Alexa Radio Skill in 5 Minutes with Standard Library and Nodejsby@tinkr
20,050 reads
20,050 reads

Create an Alexa Radio Skill in 5 Minutes with Standard Library and Nodejs

by @tinkrDecember 12th, 2018
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Create an Alexa Radio Skill in 5 Minutes with Standard Library and Nodejs. You can say “Alexa, open radio” and Alexa will start streaming your custom station. 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. If a channel is found, a random station from that channel is played. If your channel contains multiple MP3 files, the skill will queue up the next file automatically. Change what the skill says for Now playing, Next etc. Change them as often as you wish.

People Mentioned

Mention Thumbnail

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Create an Alexa Radio Skill in 5 Minutes with Standard Library and Nodejs
@tinkr HackerNoon profile picture

Create your own Alexa Radio Skill with your favourite streaming stations. Once deployed, you can say Alexa, open radio and Alexa will start streaming a radio station. You can stream a particular genre by saying Alexa, ask radio to play Jazz music. You can, of course, add or delete the stations, so you can have a completely personalised music playing experience. Getting up and running is super simple.

If you haven’t checked out Code on Standard Library, do that right now. Sign up and get an account. It’s free.

Next, click on Open and this will open up a panel with some featured templates you can use.

Click on the Community API Sources tab and search for alexa-radio-skill. Click on Create API to use it as a template for your own service. Once it’s created, proceed to the next step.

Minute One: Choose Your Favorite Radio Stations

In the main.js file, at the top is astations object. This holds all the stream information.

const stations = {meditate: {name: "Meditation Radio",url: ["",""]}}

If you want to add your own stations, the simplest way is to go to shoutcast and search for your favourite stations. To get the URL of the the station, click on the download icon and right-click and copy the Any player (.m3u) value.

You can also add any streaming link, as long as it starts with https://.

Minute 2: Deploy Alexa-Radio-Skill API on Standard Library

Now, navigate to the env.json file and populate the environments with your Standard Library Token.

The code will not work without the token.

To retrieve your Standard Library Token, place the cursor in between the yellow quotes and right click. Select your Standard Library Token from the drop-down menu and the variable should automatically populate.

Click on the green Run button to deploy the service. Once deployed, note the URL of your endpoint. It should look something like this:https://[username]

The skill will give you a message when it’s run directly because it’s expecting a request event from Alexa. You can ignore this message.

Minute 3: Create an Alexa Skill

Go to 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 Create Skill button.

Here you can give your skill a name and choose your default language. Choose Custom for model to add to your skill.

On the next screen, choose Start from scratch.

Once you create the Alexa Skill, create the Interaction Model. Click on JSON Editor at the bottom left.

Next head back to Code on Standard Library and navigate to AlexaInteractionModel.json file.

Copy it’s contents and paste it into the right-hand pane of the JSON Editor on the Alexa developer portal.

The invocation name is set as radio. If you want to change it, do so before you paste. To change the name, just change the invocationName value in the JSON file.

Make sure you select Save Model on the JSON Editor to save your model.

Minute 4: Save Alexa Endpoint & Add Audio Interface

Click on Endpoint in the sidebar to update the endpoint URL.

Now paste the URL endpoint here. Make sure you choose My development endpoint is a sub-domain of a domain option from the drop down menu.

Add Audio Interface

Click on Interfaces and turn on the Audio Player interface. The skill will not work without this being enabled.

Minute 5: Save Endpoints and Build Model

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.

Test your skill

Once you get the pop-up saying that the Build Succeeded, click on the Test tab next to Build on the Alexa Developer console.

This will open the test console.

Enable the skill if it’s not. Then enter open radio in the chat text box.

If you have setup everything correctly, you should get a reply. If it works, then you can directly test it on your Alexa device.

**Notes**- All streaming URLs should be https.- The test simulator on Alexa Developer portal does not play any audio.

If you get stuck anywhere, or if you have any feedback, write to me.