Skip to content

Commit 0da7e74

Browse files
authored
Update README.md
1 parent a5a6d0b commit 0da7e74

1 file changed

Lines changed: 28 additions & 179 deletions

File tree

README.md

Lines changed: 28 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -1,192 +1,45 @@
1-
# Build An Alexa Skill with In-Skill Purchases using ASK Python SDK
1+
# Build An Alexa Skill with In-Skill Purchases using Developer Console
22

33
<img src="https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/fact/header._TTH_.png" />
44

5-
## Setup the ASK CLI
6-
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)
9-
* [ASK CLI Command Reference](https://developer.amazon.com/docs/smapi/ask-cli-command-reference.html)
10-
11-
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+
--------------------
1537

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.)
15510

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.
15712

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'.
15914

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.
16116

162-
```bash
163-
$ cd ../subscription
164-
$ open all_access.json
165-
```
17+
5. Select **Other** under the *'Choose a type of experience'* section.
16618

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.
16820

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.
17022

171-
### Deployment
23+
8. Choose **Start from scratch** from the *Templates* section and click the **Import skill** button at the top right.
17224

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**.
26+
```
27+
https://github.com/alexa-samples/skill-sample-python-fact-in-skill-purchases
28+
```
17429

175-
```bash
176-
$ cd ../..
177-
```
30+
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).
17831

179-
2. **Deploy** the skill and the Lambda function in one step by running the following command:
32+
Creating In-Skill Products
33+
--------------------
18034

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**.
18536

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)**
18638

187-
### Testing
39+
Testing
40+
--------------------
18841

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.
19043

19144
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:
19245

@@ -196,6 +49,7 @@ There are ASK CLI commands for creating your in-skill purchases. This guide wil
19649
19750
**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)
19851
52+
19953
Additional Resources
20054
--------------------
20155
@@ -204,13 +58,8 @@ Additional Resources
20458
- [Amazon Developer Forums](https://forums.developer.amazon.com/spaces/165/index.html) : Join the conversation!
20559
- [Hackster.io](https://www.hackster.io/amazon-alexa) - See what others are building with Alexa.
20660
207-
### Tutorials & Guides
208-
209-
- [Voice Design Guide](https://developer.amazon.com/designing-for-voice/) -
210-
A great resource for learning conversational and voice user interface design.
211-
21261
### Documentation
21362
214-
- [Official Alexa Skills Kit Python SDK](https://pypi.org/project/ask-sdk/)
215-
- [Official Alexa Skills Kit Python SDK Docs](https://alexa-skills-kit-python-sdk.readthedocs.io/en/latest/)
216-
- [Official Alexa Skills Kit Docs](https://developer.amazon.com/docs/ask-overviews/build-skills-with-the-alexa-skills-kit.html)
63+
- [Create and Manage In-Skill Products](https://developer.amazon.com/en-US/docs/alexa/in-skill-purchase/create-isp-dev-console.html)
64+
- [Test In-Skill Purchasing Skills](https://developer.amazon.com/en-US/docs/alexa/in-skill-purchase/isp-test-guide.html#test-products)
65+

0 commit comments

Comments
 (0)