Now, I'm going to give you a quick run through about how to build a simple flash briefing skill using Java, the Alexa Developer Console, and API Gateway. This is going to be a fairly lengthy and technical post, so if you aren't interested in diving into the technical pieces of being a developer then you might want to skip this.
What is a Flash Briefing?
The point of a flash briefing is to deliver content on a daily basis to users, and it has a set interaction model that you have no control over. This is good because it means that users can link your skill into their daily briefing and don't have to learn your Voice User Interface, but it can be bad because it offers very little customization or features to work correctly.
For this example, I will discuss my flash briefing skill for Word of the Day. This is one I put together to deliver a daily word to users in as simple and straightforward a process as possible. Feel free to try the skill out to see what the final product sounds like, and then start considering what you might want to offer to your users daily as part of a flash briefing.
Steps To Build Your Flash Briefing
- Make a developer account: Developer.amazon.com
- Create a new Alexa Skill.
What you need after you have created a new feed is a couple of things. Your preamble is going to start with 'in' or 'from' and essentially summarizes where your information is coming here. This is customizable so you can have it say whatever you want.
The important part is the link in JSON or RSS for the Feed. That's what we're going to build to get your daily content.
Building Your Feed
It is important to note that you can't just take an RSS feed from online and toss it in there. That won't work, because Alexa is expecting some VERY specific things that it will use to play your flash briefing. You can either tell Alexa to play information from a stream or from text. In my skill, I use text because I don't have audio files (nor the desire to create them) to play for the flash briefing. Instead, I pass the words to Alexa and let her read them to the user.
Study this link to understand how the JSON should look. Amazon Flash Briefing API. It explains everything you need to send to Alexa. I use Lambda to build this information, but you could host your own server if you prefer. The key is it needs to have:
- uid (this is something we can get directly from Amazon).
- updateDate (Java 8 has this built in super easy).
- titleText (Up to you to create).
- mainText (This is what Alexa reads.)
- streamUrl (Only if you are sending in a stream).
- redirectionUrl (Anything you want to put that relates).
If you are familiar with JSON formatting, this isn't very hard to do. This is the entire method I use to build this data.
As you can see, using the ZonedDateTime included with Java I can easily pass the date in the correct format, and using UUID to get random uid's means I don't have to worry about the code at all. The main text is passed through from my custom class that builds the daily information, so you will need to change that to be whatever actual value you want to display daily. Just make sure it is something custom and differentiated enough that you don't keep repeating the same data.
It's as simple as that, and you will have your java code ready to go to deliver your daily information. So, how do you bridge that gap to get the data to Alexa?
Lambda and API Gateway
Create a new Lambda function. If you don't have a role, make a basic execution role for Lambda and then hit create function.
Create a new API gateway connection, then fill in the details. Make sure to select open (though for a production skill you might consider adding more security) and then add the configuration.
Fill in the information for the lambda function itself and upload your jar file created from the first step. You will put your handler as the package of the file plus the name of the method to be called.
Now, under the gateway, you will find the link to the url that you created. You can also find the link under API Gateway on the Amazon AWS website if you would prefer to go there to find it. It will be called the invokeURL. Hitting it should look something like this:
This is your feed URL that will be passed in on the alexa page. When you try to save it, the site will let you know if there are errors with your feed. If there are any, then you might have missed something in the configuration. If not you are good to go.
The last step is going to be testing and adding launch details for your skill. For these skills, the only thing you need to configure is the US environment. Just fill out the information, add an icon (512 x 512) and then hit submit for certification. You can't test flash briefing skills on their site, unfortunately, but if you have an echo device at home you can enable it for testing and use it there.
That's it! Once it goes live, you can submit it for developer perks. You can submit each month, actually, as long as you make a new skill each time. Their perks are getting harder to acquire with each month, so eventually I'm sure this program will go away, but for now it is alive and well!
Questions or Comments?
If something isn't working or you need more guided help, please reach out and contact me directly. I'm making some assumptions about the starting point of people reading this post, but if you need more help in getting set up in eclipse or building your first skill then I would be glad to help with that, too.
The key difference between this and the custom skills is that API gateway is a middle ground between the two. For a normal skill, Alexa can call directly to lambda to interact with your skill, but for a flash briefing you need that JSON formatted piece passed through a real api gateway to get the data to Amazon.
My next post will be creating a simple custom skill, but much of the process will be the same.