This simple scenario enables users to create a well known Peppa Pig music meme by their voice. The skill will find the music through an open search API and create an audio compilation on the fly.

If you are not yet familiar with this amazing meme just watch this short video

In this tutorial we will learn
how to use SSML to generate audio output in Amazon Alexa skills and Google Assistant actions
how to invoke third-party API to search music
how to use our advanced tools to convert music tracks on the fly
how to use Amazon specific entities in your scenarios

Please note that you can play with this scenario without building. Just click on "Peppa Pig music" template on a main page of Aimylogic to open a complete bot.

How this bot works

After launching this bot asks the user about their favourite music and then searches it through an open Deezer API. If some tracks were found, the bot generates an audio output for voice assistant and the user listens a complete Peppa music meme.

First screen

In the very first screen of your scenario add some greeting text that prompts the user to provide some track title. For example

Here we also inserted a small screenshot from the original Peppa video. This image will be rendered on the devices that support screens.


The user can respond with some track's title they'd like to listen. Add Intents block on the first screen to extract track's title from the user's response.

How to extract music track's title from the user's speech

Once the bot asks the user for a track's title to search, the user can say anything they'd like to listen. We don't like to store an entire Deezer collection of tracks in our own database, so our bot has to extract a title of the track from the user's speech.

If we have a deal with some unknown part of the user's query, we can use a $TEXT system entity in our Intents block to extract a free text from the input. But this entity cannot be used in Alexa skills without some preceding words like "search", "play" and etc.

That is why we have to provide an Amazon specific entity $AMAZON.MusicRecording in the intent. This entity extracts the track's title from the user's speech.

How to search a music

Click on the $AMAZON.MusicRecording intent to create a new connected screen. Here our bot has to search tracks that matches the user's query.

Deezer music service provides a free HTTP API to search short (30 seconds) previews in a huge collection of MP3 tracks. You can explore this API here to see it in action. If something was found Deezer returns a JSON response.

Our bot can use HTTP Request block to search tracks, parse this JSON and pick the very first item with a direct link to the MP3 preview.

Click on HTTP Request block and provide these settings

Here we defined an URL${AMAZON.MusicRecording}
Aimylogic will extract the track's title from the user's query and replace ${AMAZON.MusicRecording} with an actual AMAZON.MusicRecording variable value.

Deezer returns a JSON with the search results array in data field. We have to extract the very first item from this array - thus create a new variable named track with value $[0]

Playing music

So, our bot invokes a Deezer API to search tracks that match the user's query and stores the very first tracks data in track variable.

Now our bot is ready to play the resulting meme to the user. Click on Success in the HTTP request and add Text block to a new screen. Place here some text like "I like this! It's very grown up!" and a little image with Peppa switching the boombox on.

Add one more Text block to display the track info and special Speech synthesis markup

The text bubble will show a track's info containing the title of the track and the artist's name. The Speech synthesis markup contains two audio tracks. The first one is an intro - the part of the original Peppa Pig meme where she has a small talk with her friends. And the second one - a particular track that the user would like to listen.

<audio src=""/>
<audio src="$track.preview"/>

Amazon Alexa requires the MP3 files to be converted to the special format before it can be played on Echo devices. Thus we have to convert both audio tracks. The first one can be converted manually through our Aimylogic audio converter.

The second track (that was found via Deezer API) has to be downloaded before. But our bot cannot do this, that is why Aimylogic provides an API of audio converter, so we can simply pass a track's URL (preview field) to the converter's API and paste this URL to the audio tag.

Connect to Amazon Alexa

Now we can create an Alexa skill to test this scenario on the real Echo device. Just click on the Channels menu item and then click on Alexa button. Keep everything as is in the settings window and click Connect. Grant Aimylogic rights to manage your Alexa skills and waits a couple of minutes while Amazon builds your skill.

Now you can invoke Alexa or go to the test console and command "Play Peppa Pig music". The skill will ask you about the music to search and then after a couple of seconds will play a complete audio meme with your track.


In this simple tutorial we learned how to create Alexa skill that extracts a music track's title form the user's speech, searches tracks over the open Deezer API and then generates an audio output.
Was this article helpful?
Thank you!