In-Skill Purchases
Learn more about how to let your users do In-Skill Purchases (ISP) with your Alexa Skill. You can also use the following template to get started: Jovo Template for Alexa ISP.
- Introduction to In-Skill Purchases
- Manage Products with ASK CLI
- Update the Language Model
- Implement Purchasing with Jovo
Introduction to In-Skill Purchases
In May 2018, Amazon introduced the ability for Skill developers to make money through in-skill purchasing. It allows you to sell items either through one-time purchases or subscriptions. Take a look at the official reference by Amazon: In-Skill Purchasing Overview.
There are three things that need to be done to successfully implement in-skill purchasing for your Alexa Skill with Jovo:
Manage Products with ASK CLI
Purchasable products can be added and managed with ASK CLI, the command line interface for the Alexa Skills Kit.
If you're using the common Jovo project structure, go into your platforms/alexaSkill
folder and then tell the ASK ClI to add isp
. After going through the process, it will add a new folder isps
to your project files.
After that, there should be a frozen_sword.json
file in your alexaSkill/isps
folder. The content of that json
file is used to define the price, release date, description as well as the prompts Alexa will use when she handles the transaction and much much more. You can find examples and a small description for each field here.
Here's how our product's file looks like:
Update the Language Model
Here is an example language model you can for purchasing and refunding products. It is recommended to use the reference name as an ID
when creating the input/slot values:
Implement Purchasing with Jovo
In general, you can access the in-skill purchasing interface like this:
Before you start any kind of transaction or refund process, always retrieve the product first:
The data you get looks like this:
Using that data we can check if the user already owns the product:
Upsell
The upsell()
method is used to proactively offer the user your products. To send out the request, you need three things:
Name | Description | Value | Required |
---|---|---|---|
productId |
ID used to determine the correct product | String |
Yes |
prompt |
Prompt Alexa will read to ask the user whether they are interested | String |
Yes |
token |
Token you use to help you resume the Skill after the transaction finished | String |
Yes |
Purchase Request
The buy()
method is used to start the transaction after the user requested the purchase.
Name | Description | Value | Required |
---|---|---|---|
productId |
ID used to determine the correct product | String |
Yes |
token |
Token you use to help you resume the Skill after the transaction finished | String |
Yes |
Refund
The cancel()
method is used to start the refund process after the user asked for it.
Name | Description | Value | Required |
---|---|---|---|
productId |
ID used to determine the correct product | String |
Yes |
token |
Token you use to help you resume the Skill after the transaction finished | String |
Yes |
ON_PURCHASE
After successfully going through the process of purchasing or refunding a product, your Skill will receive a request notifying you about the result:
The important parts of that request are:
Name | Description |
---|---|
name |
Either Upsell , Buy or Cancel . Used to determine which kind of transaction took place |
payload.purchaseResult |
Either ACCEPTED , DECLINED , ALREADY_PURCHASED or ERROR . Used to determine the outcome of the transaction |
payload.productId |
The product in question |
token |
The token used to resume the skill where it left off |
That request will be mapped to the built-in ON_PURCHASE
intent: