Paid Skills Task Reference
Use the paid skill tasks with skill connections to invoke the Amazon purchase and cancellation flows. Before you invoke the purchase flow, make sure to get customer entitlement status to determine if the customer already purchased the skill.
Skill connections enable a skill to use another skill to perform a specific task. Before you implement the paid skills tasks, review the following topics:
Tasks
The paid skills interface include the following tasks.
Task | Task name |
---|---|
| |
|
Buy request
To start the Amazon purchase flow, include the Connections.SendRequest
directive in your response to Alexa from an intent handler. The directive invokes the Buy
task by using the skill connections interface. To identify your paid skill, set the productID
to your Skill ID.
Buy
request. Make sure that you save any relevant user data in a persistent data store. After the purchase flow completes, Alexa launches your skill again. You can use the stored data to continue the skill. For details about persistent attributes, see
ASK SDK documentation for Node.js, Java, or Python.The following example shows a request to start the purchase flow.
This code example uses the Alexa Skills Kit SDK for Node.js (v2).
return handlerInput.responseBuilder
.addDirective({
type: "Connections.SendRequest",
name: "Buy",
payload: {
InSkillProduct: {
productId: "amzn1.ask.skill.efd6d738-0a1b-4f14-ae0f-6e2174bd6be3",
}
},
token: "correlationToken"
})
.getResponse();
JSON syntax for a Connections.SendRequest
directive for a purchase request.
{
"directives": [
{
"type": "Connections.SendRequest",
"name": "Buy",
"payload": {
"InSkillProduct": {
"productId": "amzn1.ask.skill.efd6d738-0a1b-4f14-ae0f-6e2174bd6be3"
}
},
"token": "correlationToken"
}
]
}
Buy task definition
Property | Description | Type |
---|---|---|
|
The type of request. |
String |
|
The name of the task to invoke. |
String |
|
Contains the parameters required for purchase. |
|
|
(Optional) An optional string that Alexa returns in the response when the purchase flow completes. For example, you might use the token to store information to help you resume the skill after the purchase. |
String |
Cancel request
For a cancellation request, include the Connections.SendRequest
directive in your response to Alexa from an intent handler. The directive invokes the Cancel
task by using the skill connections interface. To identify your paid skill, set the productID
to your Skill ID.
Cancel
request. Make sure that you save any relevant user data in a persistent data store. After the purchase flow completes, Alexa launches your skill again. You can use the stored data to continue the skill. For details about persistent attributes, see
ASK SDK documentation for Node.js, Java, or Python.The following example shows a request to start the cancellation flow.
This code example uses the Alexa Skills Kit SDK for Node.js (v2).
return handlerInput.responseBuilder
.addDirective({
type: 'Connections.SendRequest',
name: 'Cancel',
payload: {
InSkillProduct: {
productId: "amzn1.ask.skill.efd6d738-0a1b-4f14-ae0f-6e2174bd6be3",
}
},
token: "correlationToken"
})
.getResponse();
JSON syntax for a Connections.SendRequest
directive for a cancel request.
{
"directives": [
{
"type": "Connections.SendRequest",
"name": "Cancel",
"payload": {
"InSkillProduct": {
"productId": "amzn1.ask.skill.efd6d738-0a1b-4f14-ae0f-6e2174bd6be3"
}
},
"token": "correlationToken"
}
]
}
Cancel task definition
Property | Description | Type |
---|---|---|
|
The type of request. |
String |
|
The name of the task to invoke. |
String |
|
Contains the parameters required for purchase. |
|
|
(Optional) An optional string that Alexa returns in the response when the purchase flow completes. For example, you might use the token to store information to help you resume the skill after the cancellation. |
String |
Buy and cancel response
Your skill receives the result of the purchase or cancel request as a Connections.Response
request. Resume the skill based on the purchaseResult
included in the payload
.
Connections.Response example
The following example shows a successful response to the purchase flow.
{
"type": "Connections.Response",
"requestId": "string",
"timestamp": "string",
"name": "Buy",
"status": {
"code": "200",
"message": "OK"
},
"payload": {
"purchaseResult": "ACCEPTED",
"productId": "amzn1.ask.skill.efd6d738-0a1b-4f14-ae0f-6e2174bd6be3",
"message": "optional additional message"
},
"token": "correlationToken"
}
Connections.Response parameters
Property | Description | Type |
---|---|---|
|
Type of request. |
String |
|
Unique identifier for the Connections.Response request. |
String |
|
Time of the Connections.Response request. |
String |
|
Name of the request to which this response applies. |
String |
|
HTTP status result. |
Object |
|
HTTP response status such as |
String |
|
HTTP status message, such as |
String |
|
Contains the results of the purchase or cancel transaction. |
Object |
|
Result of the purchase or cancel request. |
String |
|
Paid skill ID sent in the request. |
String |
|
(Optional) Additional details about the cancel or purchase transaction. |
String |
|
Optional string that Alexa returns in the response when the purchase or cancel flow completes. For example, you might use the token to store information to help you resume the skill after the purchase. |
String |
Object definitions
Payload request object
The Payload
object included in the request defines the paid skill.
Payload object details
Property | Description | Type |
---|---|---|
|
Defines the paid skill. Include one object. |
Array objects |
|
Set to your skill ID. |
String |
Related topics
Last updated: Mar 26, 2024