Step 8: The Final Steps

by Kaan Kilic on Feb 13, 2019

We're at the final step where before we improve the project's structure, add small required intents and look ahead at what else could be added to the project.

Required Intents

There are a few intents that are required by the platforms to pass the certification. Those for Amazon Alexa are typically sitting in the alexa object of the Jovo Language Model.

In this section, we will build out the following required intents and will also make them work for Google Assistant by updating the language model:

Help Intent

In and outside the playback state our user should have the possibility to ask for help.

To make the intent work across platforms, we first add it to our language model and delete the AMAZON.HelpIntent inside the alexa object:

As this will still use the AMAZON.HelpIntent for Alexa, we have to map it to the HelpIntent in our intent map:

After that, we add it to our logic:

Cancel Intent

The user also has to be able to exit the app. For that we use the AMAZON.CancelIntent, which is already in our language model. On Google Action, the utterances cancel and stop will automatically close the app.

Inside our handler, we simply tell the user goodbye.

Stop Intent

Amazon also wants us to have the AMAZON.StopIntent implemented. Since it technically has the same task as the CancelIntent, we will map the AMAZON.StopIntent to the CancelIntent in our intent map:

Note: If people say "Alexa, stop" while the audio file is playing, this will still trigger the AMAZON.PauseIntent, not the AMAZON.StopIntent.

Separating the Logic into Multiple Handlers

Currently our handler inside the app.js file contains both platform-independent intents as well as platform-dependent intents, e.g. AudioPlayer requests, Amazon built-in intents, etc. Technically that works, but it's not really organized.

A better solution would be to split it up into three different handlers. A handler where we store the platform-independent intents, an handler specifically for Alexa intents and one for Google Action intents.

Here's how the separation would look like:

Handler State Intent
Generic - LAUNCH
  - NEW_USER
  - ListIntent
  - ChooseFromListIntent
  - LatestEpisodeIntent
  - FirstEpisodeIntent
  - NextIntent
  - PreviousIntent
  - ResumeIntent
  - HelpIntent
Alexa - AMAZON.PauseIntent
  - AMAZON.CancelIntent
  - AMAZON.PauseIntent
  - AMAZON.LoopOnIntent
  - AMAZON.LoopOffIntent
  - AMAZON.RepeatIntent
  - AMAZON.ShuffleOnIntent
  - AMAZON.ShuffleOffIntent
  - AMAZON.StartOverIntent
  AUDIOPLAYER AlexaSkill.PlaybackStarted
  AUDIOPLAYER AlexaSkill.PlaybackNearlyFinished
  AUDIOPLAYER AlexaSkill.PlaybackFinished
  AUDIOPLAYER AlexaSkill.PlaybackStopped
  AUDIOPLAYER AlexaSkill.PlaybackFailed
Google AUDIOPLAYER GoogleAction.Finished

We can also go one step further and move the platform specific handlers to separate files.

We create an alexa folder inside the app folder and add a handler.js file. Inside that file we store the content of our AlexaHandler:

We do the same for our GoogleHandler. Again, we create a google folder inside the app folder, add a handler.js file and move the content of our GoogleHandler over:

Now we can import both files in our app.js file and place them inside the AlexaHandler and GoogleHandler:

Next Steps

You've reached the end of the course. We're done!

The last thing you have to do is switching out the audio files. These have to hosted on a HTTPS endpoint. We used AWS S3, but there are a number of other possible services for that.

Besides that, if you want to publish your app on AWS Lambda, you have to switch to DynamoDB, because Lambda does not allow you to make any changes to files on runtime. You can find a guide on how to do that in our documentation.

Obviously, there are also a lot more features we can add to the app, but that would make the course even longer than it already is.

One of those things we cut because of time constraint is visual output. Both Alexa and the Google Assistant support smart displays, where you could, for example, also list the random episodes we suggest our user.

Feel free to modify the podcast player as you wish. We would love to see what you come up with!

If you have any questions or suggestions, you can reach us on Twitter or Slack.


Kaan Kilic

Technical Content Marketing Associate at Jovo

Comments and Questions

Any specific questions? Just drop them below or join the Jovo Community Forum.

Join Our Newsletter

Be the first to get our free tutorials, courses, and other resources for voice app developers.