We recently launched consumables as a new type of in-skill purchasing (ISP). This means that you can sell things like coins, hints, or gems that your customers can use in your Alexa skills.
I’ve been excited to use consumables in a new game skill I built called “Name the Show.” The skill gives you the name of an actor or actress from a television show. You have to guess which show Alexa is thinking about. You can guess multiple times, but if you can’t figure it out, you can buy and use hints, which will give you a second (or third) actor from the same show, making it easier to determine the correct answer.
When adding consumables to my skill, I learned a few lessons about persistence, user experience, and certification that could be useful to any skill builder looking to do the same. These learnings should definitely save you some time when you build your first skill with consumables.
If you’ve already started building or tinkering with one-time purchases or subscriptions as in-skill products, you’ll be delighted to know that everything you’ve learned applies to consumables as well. You can perform upsell and buy requests, and the responses you get from the API are identical, with possible values of ACCEPTED, DECLINED, or ERROR.
This makes it easy to create new consumable products, without having to learn an entirely new process. The only real difference I noticed when building my own consumables is managing an inventory, which happens to be lesson #2.
This might seem obvious at first. A customer buys some hints in your game, and you’re responsible for keeping track of how many they’ve purchased, as well as how many they’ve used. There’s a few tricks to this, however.
First, you need to call the inSkillProduct API to get a list of your products, and to determine how many times the customer has purchased your consumables. This is the number of times a customer bought each product, which is called the activeEntitlementCount. In my skill, when you buy hints, you get five hints for $0.99. I multiply the activeEntitlementCount by five to get the total number of hints a customer has purchased.
const ms = handlerInput.serviceClientFactory.getMonetizationServiceClient();
return ms.getInSkillProducts(locale).then(function(res) {
if (res.inSkillProducts.length > 0) {
const hintpack = res.inSkillProducts[0];
const hintsPurchased = (hintpack.activeEntitlementCount * 5);
Second, you need to keep track of how many consumables your customer has used. This is pretty straightforward because you just decrement this value each time that you give them a hint. It’s important to persist this value to an external database (like Amazon DynamoDB) because you’ll need an accurate count every time that your customer starts the skill.
Finally, you need the difference between the total number of consumables purchased, and the total number of consumables used, which is the total number of consumables remaining.
It is incredibly important to check this count every time you start your skill (at a minimum). For example, if a customer accidentally makes a purchase, they can go through Amazon customer service to get a refund on their consumable purchase. When this happens, your activeEntitlementCount will actually go down by one, and you’ll need a way to reconcile the user’s new total of consumables. I recommend always favoring your customer when your count seems incorrect.
In a mobile app, consumables tend to take center stage at the top of the screen. Customers always have an easy way to know how many items they have remaining. With a voice user interface, we need to make it easy for a customer to determine how many items they have left, regardless of whether they have an Echo device with or without a screen.
To do this, I create a new intent, called InventoryIntent that allows a customer to ask my skill things like:
When they hit this intent, I respond to them with a quick description of their hint total, followed by a question to keep them in the game, like:
“You currently have 7 hints remaining. Are you ready for your next question?”
This is a requirement for certification, so make sure you make it easy for your customers to determine their consumables counts.
My opinion is that you can’t save your inventory data often enough. Every time we send a Connections.SendRequest directive, the user actually leaves our session (and our skill), and when a response returns, it does not include any of the session data we might have created. This can lead to data loss if you don’t persist it to a database.
I’m currently checking the API and updating my database record every single time my AWS Lambda function is called. While this might be slightly more than is necessary, I feel better knowing I’ve always got an accurate count of my customer’s inventory in my database.
At a minimum, I’d recommend checking their inventory each time your user starts your skill, and persisting your changes when they’re done.
Finally, with the advent of these new consumable in-skill products, there are also some new certification requirements to go with them. There are two, specifically, that are important to note:
These requirements should be relatively simple to achieve, but it’s important to know that the certification team will be testing these two cases, as you plan your deployment.
I am super excited about consumables in Alexa skills, and can’t wait to show off the skill I’ve been working on. I’d love to hear how you’re using them too! Reach out to me on Twitter @jeffblankenburg. Register for our webinar on October 16, 10-11am PST, to learn more about building Alexa Skills with consumables.
You can make money for eligible skills that drive some of the highest customer engagement with Alexa Developer Rewards. You can also make money with Alexa skills using in-skill purchasing or Amazon Pay for Alexa Skills. Download our introductory guide to learn more.