Apr 1, 2021

Build your own Audio Player or Sounds Skill with Amazon Alexa and WordPress website

Interested in developing your own Alexa sounds skill? Your new shiny Alexa sounds skill can be ready in a matter of minutes, using just your WordPress website and Convoworks WP GUI. Recently, with v0.21, we reworked our audio player interfaces and related components in a manner that now we have easy to build and yet very customizable music player capabilities.

First time here? Learn how to use Convoworks with our Getting started tutorial.

Core concepts

In order to play your mp3s, you have to define how the system will access them. For that purpose we use service context components which are implementing IMediaSourceContext interface. Right now we have two implementations, one that reads files from the given folder (convo-filesystem package) and one that reads WordPress media library (convo-wp-core package).

Once the skill starts and we know the user’s intent, we will start the playback. To help us with that we use two new components in convo-core package: Media info element and Start audio playback element

Media info element enables you to be aware are there any results at all and customize workflow for each case. Start audio playback will start playing and as addition it enables you to send the playlist index of the desired song.

Once you start the player, your service ends the session. While in the “player mode”, your user can make several predefined requests without saying the skill name: Next, Previous, Shuffle, Loop. Check the full list on Amazon. On the display enabled devices, your user can manually tap on player commands. All those requests are categorized as media requests and are directly routed to your service’s media block. Media block from our convo-core package has a built in capabilities to handle all those requests. The only thing you have to worry about is to respond with an appropriate message if user requested unsatisfiable operation (e.g. Next on the last song when the loop is off).

Test services

wp-core package comes with 2 audio player service templates. One simple and the second full featured, searchable audio service. Both of them should work automatically, without any additional configuration. Just connect them to the Amazon and upload mp3 files into your WordPress media library.

Do not forget:
1. Turn on Audio Player interface on the “Amazon Alexa Configuration” Convoworks view.
2. To be able to test skill on your device, you have to enable Test on the Amazon ASK GUI.

Loop player

Dead simple audio service. It just plays whatever your WP Media source returns, with a loop enabled by default. Next, Previous and all other media requests that users can make without specifying skill name, are properly handled.

Searchable player

This is the real audio player skill, which demonstrates how to apply search, sort and few additional functionalities.

First, the search. If a search term is provided, it will narrow the results. In the WordPress implementation, search is s argument for the \WP_Query object. User can search for a song, artist or he can ask to play all songs. In this service we are matching against two intents to set the current search phrase: convo-core.PlaySong and convo-core.PlayAll. Until we provide it through the GUI, you can check which utterances are supported here, in the convo-core package intents definition file.

The sort order is defined by the order and orderby parameters and we are using just two custom intents: PlayAlphabeticallyIntent and PlayNewestIntent.

As an addition, we are using the PlayerStatusIntent custom intent to inform the user about current player info (Alexa ask Searchable Player for the player status). We are using provided media status to read information about the loop status, which song is the current …

Our skill has just one “normal” step in the conversation – Home, and while you are on it, you can ask to start playback: Play all, Play songs by David Bowie … If there are any results, the player will start playing automatically. Otherwise, the skill will inform you and ask to change your search phrase. The actual results handling is done in the Handle search results fragment.


Once the player starts, the regular skill session ends. While in streaming mode, in addition to player commands which do not require skill name, you can apply commands in combination with skill name. Those direct intents are handled by the processors in the Session start step.

Try to say Alexa, ask Searchable Player

  • for playlist info
  • for player info
  • for recent first
  • for newest first
  • to sort by name
  • to sort alphabetically
  • to play the last song
  • to resume
  • to play all
  • to play songs by The Police

What about Convoworks Prototype?

If you are running Convoworks Prototype you can use File Player template from our convo-filesystem package. It has pretty much same functionality as Searchable Player and there is walkthrough in our documentation section.

Does it works on Google Assistant?

Yes, it works. Just follow the procedure to connect Google Assistant via Dialogflow and it should work out of the box. Well, it behaves a bit differently than the Alexa version, but it can serve the purpose.

Final thoughts

We provided just basic examples of how you can create your audio skill. Although those examples are already comparable and even better than the existing skills on market, we believe that this is just a beginning and that we will soon see many variations.

Remember, media source is defined with the IMediaSourceContext interface. Meaning that you can create a Media source component optimized for usage with some existing mp3 player WordPress plugin, with some cloud storage or anything else that would make sense to act as source for the audio player.


Download Convoworks WP and try it for yourself!

Convoworks WP on WordPress.org

Tihomir Dmitrović

Tihomir Dmitrović

Full stack developer with 20+ years of professional experience, specialized in solving complex problems in a scalable manner. Founded Convoworks, which is a GUI based tool for creating voice and chatbot applications through WordPress.

Sep 1, 2021  | 

Use Amazon S3 and Have no Limits with your WordPress based Alexa Audio Player

Many hosting providers have limits to their storage capacity and traffic bandwidth. In case you have a very popular…

VIEW FULL POST

Aug 4, 2021  | 

Create Alexa music player skill with Audioigniter or MP3 Music Player by Sonaar plugins for WordPress

Many musicians have their own music websites with their creations. Like with everything on the Internet, many of them…

VIEW FULL POST