You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are several aspects of developing an Alexa skill with in-skill purchases that require the use of the Alexa Skills Kit Command Line Interface (ASK CLI), so this entire walkthrough will require you to have installed and configured the ASK CLI. If you haven't done this before, here are the resources you need to get the ASK CLI installed on your machine:
7
-
8
-
*[Quick Start Guide for Installing the ASK CLI](https://developer.amazon.com/docs/smapi/quick-start-alexa-skills-kit-command-line-interface.html)
If you have used the ASK CLI previously, you will also need to **make sure** that you have the **most recent version** of the ASK CLI. You can make sure you have the latest version by running the command:
12
-
13
-
```bash
14
-
$ npm update -g ask-cli
15
-
```
16
-
17
-
## Setup the ASK SDK for Python
18
-
19
-
We have provided the code for this skill on [here](lambda/py). To properly upload this code to Lambda, you'll need to perform the following:
20
-
21
-
1. This skill uses the [ASK SDK for Python](https://github.com/alexa/alexa-skills-kit-sdk-for-python) for development. The skill code is provided in the [lambda_function.py](lambda/py/lambda_function.py), and the dependencies are mentioned in [requirements.txt](lambda/py/requirements.txt). Download the contents of the [lambda/py](lambda/py) folder.
22
-
2. On your system, navigate to the lambda folder and install the dependencies in a new folder called “skill_env” using the following command:
23
-
24
-
```
25
-
pip install -r py/requirements.txt -t skill_env
26
-
```
27
-
28
-
3. Copy the contents of the `lambda/py` folder into the `skill_env` folder.
29
-
30
-
```
31
-
cp -r py/* skill_env/
32
-
```
33
-
34
-
4. Zip the contents of the `skill_env` folder. Remember to zip the **contents** of the folder and **NOT** the folder itself.
35
-
5. On the AWS Lambda console, change the **code entry type** drop-down to **Upload a .ZIP file**, upload the zip created in the previous step and click on **Save**.
36
-
37
-
*(Optional)* Follow the ASK Python SDK [Getting Started](https://alexa-skills-kit-python-sdk.readthedocs.io/en/latest/GETTING_STARTED.html#adding-the-ask-sdk-for-python-to-your-project) documentation, to check alternative ways of installing the sdk and deploying to AWS Lambda console.
38
-
39
-
6. On the **Triggers** section, add **Alexa Skills Kit** as a trigger and click on **Save**.
40
-
41
-
### Create Skill on Developer Console
42
-
43
-
1. Create a new skill by following these steps:
44
-
45
-
* Log in to the Alexa Skills Kit Developer Console.
46
-
* Click the Create Skill button in the upper right.
47
-
* Enter `Premium Facts Sample` as your skill name and click Next.
48
-
* For the model, select Custom and click Create skill.
49
-
50
-
2. Next, define the interaction model for the skill from the JSON Editor. Select JSON Editor from the sidebar and **replace** the contents with the contents provided in [this JSON file](models/en-US.json), and save it.
51
-
52
-
3. Build the skill model.
53
-
54
-
4. Navigate to the skill endpoints and add the previously created AWS Lambda Function ARN as the Default Region endpoint. Save the endpoints.
55
-
56
-
### Local installation for ASK CLI and Skill
57
-
58
-
1. Create a new directory for CLI work and navigate to the directory.
59
-
60
-
2. **Clone** the `Premium_Facts_Sample` skill created above using the CLI. This would get you the skill metadata and lambda code cloned at a single place, for working with ISP.
61
-
62
-
```bash
63
-
$ ask clone
64
-
```
65
-
66
-
3. **Navigate** to your project folder.
67
-
68
-
```bash
69
-
$ cd Premium_Facts_Sample
70
-
```
71
-
72
-
4. **Explore** the project structure. You should see folders for lambda and models, and skill.json file.
73
-
74
-
```bash
75
-
$ ls
76
-
lambda models skill.json
77
-
```
78
-
79
-
### Creating In-Skill Products
80
-
81
-
There are ASK CLI commands for creating your in-skill purchases. This guide will walk you through creating three different one-time purchases (entitlements), as well as a subscription. Our sample code is expecting these to be created as described, so make sure to follow along carefully.
82
-
83
-
1. **Create** your first in-skill product. You should be in the project's root directory.
84
-
85
-
```bash
86
-
$ ask add isp
87
-
```
88
-
89
-
3. **Choose** Entitlement.
90
-
91
-
```bash
92
-
? List of in-skill product types you can choose (Use arrow keys)
93
-
❯ Entitlement
94
-
Subscription
95
-
```
96
-
97
-
4. **Choose** Entitlement_Template as your template.
98
-
99
-
```bash
100
-
? List of in-skill product templates you can choose (Use arrow keys)
101
-
❯ Entitlement_Template
102
-
```
103
-
104
-
5. **Name** your in-skill product *science_pack*.
105
-
106
-
```bash
107
-
? Please type in your new in-skill product name:
108
-
(Entitlement_Template) science_pack
109
-
```
110
-
111
-
6. **Repeat** steps #2 - #5 to create two more entitlements: *history_pack* and *space_pack*.
112
-
113
-
```bash
114
-
? Please type in your new in-skill product name:
115
-
(Entitlement_Template) history_pack
116
-
...
117
-
? Please type in your new in-skill product name:
118
-
(Entitlement_Template) space_pack
119
-
```
120
-
121
-
7. **Create** a subscription product named *all_access* using a similar process.
122
-
123
-
```bash
124
-
$ ask add isp
125
-
126
-
? List of in-skill product types you can choose (Use arrow keys)
127
-
Entitlement
128
-
❯ Subscription
129
-
130
-
? List of in-skill product templates you can choose (Use arrow keys)
131
-
❯ Subscription_Template
132
-
133
-
? Please type in your new in-skill product name:
134
-
(Subscription_Template) all_access
135
-
136
-
8. **Navigate** to the new ISPs directory, and note the two folders, *entitlement* and *subscription*. This is where the JSON files for each of your in-skill products reside.
137
-
138
-
```bash
139
-
$ cd isps
140
-
$ ls
141
-
```
142
-
143
-
9. **Navigate** to the *entitlement* folder. You should see three files in this directory, one for each of the entitlements you created in our previous steps.
144
-
145
-
```bash
146
-
$ cd entitlement
147
-
$ ls
148
-
```
149
-
150
-
10. **Open** history_pack.json
151
-
152
-
This JSON file contains all of the necessary fields for your in-skill product, but you'll need to add the details to get them ready to sell. Because we used the Entitlement_Template template, we have provided a small explanation for each field, make sure you replace all of them. Take a look at [the sample in our docs](https://developer.amazon.com/docs/smapi/isp-schemas.html#entitlement-schema) for an additional reference. For this sample, at a minimum, you will need to update the name (not referenceName!), smallIconUri, largeIconUri, summary, description, purchasePromptDescription, boughtCardDescription, releaseDate and privacyPolicyUrl. Alternatively you can copy and paste the contents of the files found here: [ISP Entitlements](isps.samples/entitlement).
5
+
Create Skill on Developer Console by importing from GitHub
6
+
--------------------
153
7
154
-
After updating *history.pack.json*, Fill out the details for the *science_pack.json* and *space_pack.json* files. You will need to update with content about your science and space products including icons for each.
8
+
1. Go to the **[Alexa Developer Console](https://developer.amazon.com/alexa/console/ask)**. Enter your account credentials and click the **Sign In** button.
9
+
(If you don't already have an account, you will be able to create a new one for free.)
155
10
156
-
> **IMPORTANT: Don't change the *referenceName* in your files, as our codebase is relying on those to be consistent.**
11
+
2. Once you have signed in, select the **Create Skill** button near the top-right of the list of your Alexa Skills.
157
12
158
-
Once you are happy with your pricing, descriptions, and the other metadata for your three entitlements, you should update the same fields plus the subscriptionPaymentFrequency for your subscription. Alternatively you can copy and paste the contents of [All Access ISP subscription sample](isps.samples/subscription/all_access.json) into your *all_access.json* file.
13
+
3. Give your new skill a **Name**, for example, 'Premium Facts Sample'.
159
14
160
-
11. **Review and edit** the subscription file.
15
+
4. Select the Default Language. This tutorial will presume you have selected 'English (US)'. Click the **Next** button at the top right.
161
16
162
-
```bash
163
-
$ cd ../subscription
164
-
$ open all_access.json
165
-
```
17
+
5. Select **Other** under the *'Choose a type of experience'* section.
166
18
167
-
Now that you have customized your in-skill products, you can deploy your skill using the ASK CLI, and start testing it.
19
+
6. Select the **Custom** model under the *'Choose a model'* section.
168
20
169
-
> _Note: Be sure to review the output to confirm there were no errors._
21
+
7. Select **Alexa-hosted (Python)** under the *'Hosting services'* section. Click the **Next** button at the top right.
170
22
171
-
### Deployment
23
+
8. Choose **Start from scratch** from the *Templates* section and click the **Import skill** button at the top right.
172
24
173
-
1. **Navigate** to the project's root directory. You should see a file named 'skill.json' there.
25
+
9. Paste the following link in the dialog box and click **Import**.
Once the skill is created, you will have an Alexa-hosted skill with the interaction model based on the content provided in this [JSON file](models/en-US.json), and the code as per this [lambda function](lambda/py/lambda_function.py).
178
31
179
-
2. **Deploy** the skill and the Lambda function in one step by running the following command:
32
+
Creating In-Skill Products
33
+
--------------------
180
34
181
-
```bash
182
-
$ ask deploy
183
-
```
184
-
Assuming that you followed all of the setup instructions for the ASK CLI, your entire skill and Lambda function should be created on their respective portals.
35
+
1. To create an In-Skill product, on the **Build** page, under Skill builder checklist, click **Monetize Your Skill**. Or, in the left pane, click **TOOLS**, and then select **Monetize Your Skill**.
185
36
37
+
2. Follow all the steps in the documentation for **[Add a product and link it with the skill](https://developer.amazon.com/en-US/docs/alexa/in-skill-purchase/create-isp-dev-console.html#create-and-edit-in-skill-products)**
186
38
187
-
### Testing
39
+
Testing
40
+
--------------------
188
41
189
-
1. To test, login to [Alexa Developer Console](https://developer.amazon.com/alexa/console/ask), click on the **Premium Facts Sample** entry in your skill list, and click on the "Test" tab. The "Test" switch on your skill should have been automatically enabled. If it was not, enable it now.
42
+
1. To test, login to [Alexa Developer Console](https://developer.amazon.com/alexa/console/as), click on the **Premium Facts Sample** entry in your skill list, and click on the "Test" tab. The "Test" switch on your skill should have been automatically enabled. If it was not, enable it now.
190
43
191
44
2. Your skill can now be tested on devices associated with your developer account, as well as the Test tab in the Developer Portal. To start using your skill, just type or say:
192
45
@@ -196,6 +49,7 @@ There are ASK CLI commands for creating your in-skill purchases. This guide wil
196
49
197
50
**Note: The developer account associated with the skill is never charged for in-skill products.** For more details about testing skills with in-skill products, please refer to the [In-Skill Purchase Testing Guide](https://developer.amazon.com/docs/in-skill-purchase/isp-test-guide.html)
198
51
52
+
199
53
Additional Resources
200
54
--------------------
201
55
@@ -204,13 +58,8 @@ Additional Resources
204
58
- [Amazon Developer Forums](https://forums.developer.amazon.com/spaces/165/index.html) : Join the conversation!
205
59
- [Hackster.io](https://www.hackster.io/amazon-alexa) - See what others are building with Alexa.
0 commit comments