├── .ask
└── config
├── .gitignore
├── InteractionModel.json
├── LICENSE.txt
├── README.md
├── instructions
├── 0-intro.md
├── 1-voice-user-interface.md
├── 2-lambda-function.md
├── 3-connect-vui-to-code.md
├── 4-testing.md
├── 5-customization.md
└── 6-publication.md
├── lambda
├── custom
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
└── data
│ ├── facts-de-DE.js
│ ├── facts-en-GB.js
│ └── facts-en-US.js
├── models
└── en-US.json
└── skill.json
/.ask/config:
--------------------------------------------------------------------------------
1 | {
2 | "deploy_settings": {
3 | "default": {
4 | "skill_id": "",
5 | "was_cloned": false,
6 | "merge": {
7 | "skillManifest": {
8 | "apis": {
9 | "custom": {
10 | "endpoint": {
11 | "uri": "what_name_you_want_to_name_the_lambda"
12 | }
13 | }
14 | }
15 | }
16 | }
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | /lambda/custom/node_modules
--------------------------------------------------------------------------------
/InteractionModel.json:
--------------------------------------------------------------------------------
1 | {
2 | "intents": [
3 | {
4 | "name": "AMAZON.CancelIntent",
5 | "samples": []
6 | },
7 | {
8 | "name": "AMAZON.HelpIntent",
9 | "samples": []
10 | },
11 | {
12 | "name": "AMAZON.StopIntent",
13 | "samples": []
14 | },
15 | {
16 | "name": "GetNewFactIntent",
17 | "samples": [
18 | "a fact",
19 | "a space fact",
20 | "tell me a fact",
21 | "tell me a space fact",
22 | "give me a fact",
23 | "give me a space fact",
24 | "tell me trivia",
25 | "tell me a space trivia",
26 | "give me trivia",
27 | "give me a space trivia",
28 | "give me some information",
29 | "give me some space information",
30 | "tell me something",
31 | "give me something"
32 | ],
33 | "slots": []
34 | }
35 | ]
36 | }
37 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Regions: [🇯🇵](../../tree/ja-JP)
2 |
3 |
4 |
5 | # Build An Alexa Fact Skill 🇺🇸
6 |
7 |
8 |
9 | This Alexa sample skill is a template for a basic fact skill. Provided a list of interesting facts about a topic, Alexa will select a fact at random and tell it to the user when the skill is invoked.
10 |
11 | If you would like to see an example of this skill in action, you can enable the [Gloucester Facts](https://www.amazon.com/Robert-McCauley-Gloucester-Facts/dp/B01I5MOIA2/) from the [Alexa Skill Store](http://amazon.com/skills).
12 |
13 |
14 |
15 | If this is your first time here, you're new to Alexa Skills Development, or you're looking for more detailed instructions, click the **Get Started** button below:
16 |
17 |
18 |
19 |
20 |
21 |
22 | Be sure to take a look at the [Additional Resources](#additional-resources) at the bottom of this page!
23 |
24 |
25 | ## About
26 | **Note:** The rest of this readme assumes you have your developer environment ready to go and that you have some familiarity with CLI (Command Line Interface) Tools, [AWS](https://aws.amazon.com/), and the [ASK Developer Portal](https://developer.amazon.com/alexa-skills-kit). If not, [click here](./instructions/0-intro.md) for a more detailed walkthrough.
27 |
28 |
29 |
30 | ### Usage
31 |
32 | ```text
33 | Alexa, ask Space Facts for a fact
34 | >> Here's your fact: A year on Mercury is just 88 days long.
35 |
36 | Alexa, start Space Facts
37 | ```
38 |
39 | ### Repository Contents
40 | * `/.ask` - [ASK CLI (Command Line Interface) Configuration](https://developer.amazon.com/docs/smapi/ask-cli-intro.html)
41 | * `/lambda/custom` - Back-End Logic for the Alexa Skill hosted on [AWS Lambda](https://aws.amazon.com/lambda/)
42 | * `/models` - Voice User Interface and Language Specific Interaction Models
43 | * `/instructions` - Step-by-Step Instructions for Getting Started
44 | * `skill.json` - [Skill Manifest](https://developer.amazon.com/docs/smapi/skill-manifest.html)
45 |
46 | ## Setup w/ ASK CLI
47 |
48 | ### Pre-requisites
49 |
50 | * Node.js (> v4.3)
51 | * Register for an [AWS Account](https://aws.amazon.com/)
52 | * Register for an [Amazon Developer Account](https://developer.amazon.com/)
53 | * Install and Setup [ASK CLI](https://developer.amazon.com/docs/smapi/quick-start-alexa-skills-kit-command-line-interface.html)
54 |
55 | ### Installation
56 | 1. Clone the repository.
57 |
58 | ```bash
59 | $ git clone https://github.com/alexa/skill-sample-nodejs-fact/
60 | ```
61 |
62 | 2. Initiatialize the [ASK CLI](https://developer.amazon.com/docs/smapi/quick-start-alexa-skills-kit-command-line-interface.html) by Navigating into the repository and running npm command: `ask init`. Follow the prompts.
63 |
64 | ```bash
65 | $ cd skill-sample-nodejs-fact
66 | $ ask init
67 | ```
68 |
69 | 3. Install npm dependencies by navigating into the `/lambda/custom` directory and running the npm command: `npm install`
70 |
71 | ```bash
72 | $ cd lambda/custom
73 | $ npm install
74 | ```
75 |
76 |
77 | ### Deployment
78 |
79 | ASK CLI will create the skill and the lambda function for you. The Lambda function will be created in ```us-east-1 (Northern Virginia)``` by default.
80 |
81 | 1. Deploy the skill and the lambda function in one step by running the following command:
82 |
83 | ```bash
84 | $ ask deploy
85 | ```
86 |
87 | ### Testing
88 |
89 | 1. To test, you need to login to Alexa Developer Console, and enable the "Test" switch on your skill from the "Test" Tab.
90 |
91 | 2. Simulate verbal interaction with your skill through the command line using the following example:
92 |
93 | ```bash
94 | $ ask simulate -l en-GB -t "start space facts"
95 |
96 | ✓ Simulation created for simulation id: 4a7a9ed8-94b2-40c0-b3bd-fb63d9887fa7
97 | ◡ Waiting for simulation response{
98 | "status": "SUCCESSFUL",
99 | ...
100 | ```
101 |
102 | 3. Once the "Test" switch is enabled, your skill can be tested on devices associated with the developer account as well. Speak to Alexa from any enabled device, from your browser at [echosim.io](https://echosim.io/welcome), or through your Amazon Mobile App and say :
103 |
104 | ```text
105 | Alexa, start space facts
106 | ```
107 |
108 |
109 |
110 | ## Customization
111 |
112 | 1. ```./skill.json```
113 |
114 | Change the skill name, example phrase, icons, testing instructions etc ...
115 |
116 | Remember than many information are locale-specific and must be changed for each locale (en-GB and en-US)
117 |
118 | See the Skill [Manifest Documentation](https://developer.amazon.com/docs/smapi/skill-manifest.html) for more information.
119 |
120 | 2. ```./lambda/custom/index.js```
121 |
122 | Modify messages, and facts from the source code to customize the skill.
123 |
124 | 3. ```./models/*.json```
125 |
126 | Change the model defintion to replace the invocation name and the sample phrase for each intent. Repeat the operation for each locale you are planning to support.
127 |
128 | ## Additional Resources
129 |
130 | ### Community
131 | * [Amazon Developer Forums](https://forums.developer.amazon.com/spaces/165/index.html) - Join the conversation!
132 | * [Hackster.io](https://www.hackster.io/amazon-alexa) - See what others are building with Alexa.
133 |
134 | ### Tutorials & Guides
135 | * [Voice Design Guide](https://developer.amazon.com/designing-for-voice/) - A great resource for learning conversational and voice user interface design.
136 | * [CodeAcademy: Learn Alexa](https://www.codecademy.com/learn/learn-alexa) - Learn how to build an Alexa Skill from within your browser with this beginner friendly tutorial on CodeAcademy!
137 |
138 | ### Documentation
139 | * [Official Alexa Skills Kit Node.js SDK](https://www.npmjs.com/package/alexa-sdk) - The Official Node.js SDK Documentation
140 | * [Official Alexa Skills Kit Documentation](https://developer.amazon.com/docs/ask-overviews/build-skills-with-the-alexa-skills-kit.html) - Official Alexa Skills Kit Documentation
141 |
--------------------------------------------------------------------------------
/instructions/0-intro.md:
--------------------------------------------------------------------------------
1 | # Build An Alexa Fact Skill
2 |
3 |
4 | [](1-voice-user-interface.md)[](2-lambda-function.md)[](3-connect-vui-to-code.md)[](4-testing.md)[](5-customization.md)[](6-publication.md)
5 |
6 | ## What You Will Learn
7 | * AWS Lambda
8 | * Alexa Skills Kit (ASK)
9 | * Skill Builder
10 | * Voice User Interface (VUI) Design
11 | * Skill Certification
12 |
13 | ## What You Will Need
14 | * [Amazon Developer Portal Account](http://developer.amazon.com)
15 | * [Amazon Web Services Account](http://aws.amazon.com/)
16 | * The sample code on [GitHub](https://github.com/alexa/skill-sample-nodejs-fact).
17 | * Simple graphical editing tool
18 | * At least 25 facts about your favorite topic.
19 |
20 | ## What Your Skill Will Do
21 | A fact skill for Alexa is a "Hello, World" example. You provide a list of interesting facts about a topic, and Alexa will read one of those facts to your user when they start your skill. The purpose of building this skill is to teach you how the different pieces of the Alexa development process fit together, while still producing an interesting, useful skill that others can enjoy.
22 |
23 | This Alexa skill template helps you create your first fact skill. Your users will be able to say things like:
24 |
25 | * "Alexa, ask Superhero Facts for a new fact."
26 | * "Alexa, start Baseball Facts."
27 | * "Alexa, ask Titanic Facts to give me another fact."
28 |
29 | Alexa will respond to all of these requests with responses like these:
30 |
31 | * "Here's your superhero fact: Iron Man's armor used to include roller skates."
32 | * "Here's your baseball fact: Ralph Kiner is the only player ever to lead the league in homers for seven years in a row — his first seven years as a major league player."
33 | * "Here's your Titanic fact: The ship burned around 600 tons of coal a day – hand shoveled into its furnaces by a team of 176 men. Almost 100 tons of ash were ejected into the sea each day."
34 |
35 | If you would like to see an example of this skill in action, you can enable the [Gloucester Facts](https://www.amazon.com/Robert-McCauley-Gloucester-Facts/dp/B01I5MOIA2/) from the [Alexa Skill Store](http://amazon.com/skills).
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/instructions/1-voice-user-interface.md:
--------------------------------------------------------------------------------
1 | # Build An Alexa Fact Skill
2 | [](./1-voice-user-interface.md)[](./2-lambda-function.md)[](./3-connect-vui-to-code.md)[](./4-testing.md)[](./5-customization.md)[](./6-publication.md)
3 |
4 | ## Setting up Your Alexa Skill in the Developer Portal
5 |
6 | There are two parts to an Alexa skill. The first part is the [Voice User Interface (VUI)](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/defining-the-voice-interface). This is where we define how we will handle a user's voice input, and which code should be executed when specific commands are uttered. The second part is the actual code logic for our skill, and we will handle that on [page #2](./2-lambda-function.md) of this instructions guide.
7 |
8 | 1. **Go to the [Amazon Developer Portal](http://developer.amazon.com). In the top-right corner of the screen, click the "Sign In" button.** (If you don't already have an account, you will be able to create a new one for free.)
9 |
10 |
11 |
12 | 2. **Once you have signed in, click the Alexa button at the top of the screen.**
13 |
14 |
15 |
16 | 3. **On the Alexa page, choose the "Get Started" button for the Alexa Skills Kit.**
17 |
18 |
19 |
20 | 4. **Select "Add A New Skill."** This will get you to the first page of your new Alexa skill.
21 |
22 |
23 |
24 | 5. **Fill out the Skill Information screen.** Make sure to review the tips we provide below the screenshot.
25 |
26 |
27 |
28 | ### Skill Information Tips
29 | 1. **Skill Type** For this skill, we are creating a skill using the Custom Interaction Model. This is the default choice.
30 |
31 | 2. **Language** Choose the first language you want to support. You can add additional languages in the future, but we need to start with one. (This guide is using U.S. English to start.)
32 |
33 | 3. **Name** This is the name that will be shown in the Alexa Skills Store, and the name your users will refer to.
34 |
35 | 4. **Invocation Name** This is the name that your users will need to say to start your skill. We have provided some common issues developers encounter in the list below, but you should also review the entire [Invocation Name Requirements](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/choosing-the-invocation-name-for-an-alexa-skill).
36 |
37 | | Invocation Name Requirements | Examples of incorrect invocation names |
38 | | ---------------------------- | -------------------------------------- |
39 | | The skill invocation name must not infringe upon the intellectual property rights of an entity or person. | korean air; septa check |
40 | | Invocation names should be more than one word (unless it is a brand or intellectual property), and must not be a name or place | horoscope; trivia; guide; new york |
41 | | Two word invocation names are not allowed when one of the words is a definite article, indefinite article, or a preposition | any poet; the bookie; the fool |
42 | | The invocation name must not contain any of the Alexa skill launch phrases and connecting words. Launch phrase examples include "launch," "ask," "tell," "load," and "begin." Connecting word examples include "to," "from," "by," "if," "and," "whether." | trivia game for star wars; better with bacon |
43 | | The invocation name must not contain the wake words "Alexa," "Amazon," "Echo," or the words "skill" or "app." | hackster initial skill; word skills |
44 | | The invocation name must be written in each language you choose to support. For example, the German version of your skill must have an invocation name written in German, while the English (US) version must have an invocation name written in English. | kitchen stories (German skill) |
45 |
46 | 5. **Audio Player** For this Fact skill, we won't be using any audio files, so you can select No for this option. If you would like to learn more about adding audio to your skills, please check out our [Audio Player Guide](https://github.com/alexa/skill-sample-nodejs-audio-player).
47 |
48 | 6. **Click the Next button to move to the Interaction Model.**
49 |
50 |
51 |
52 | 7. Click on the **Launch Skill Builder** (Beta) button . This will launch the new Skill Builder Dashboard.
53 |
54 | 
55 |
56 | 8. Click on the "Code Editor" item under **Dashboard** on the top left side of the skill builder.
57 |
58 | 9. In the textfield provided, replace any existing code with the code provided in the [Interaction Model](../InteractionModel.json), then click "Apply Changes" or "Save Model".
59 |
60 | 10. Click on the "Dashboard" button.
61 |
62 | 11. Add some more sample utterances for your newly generated intents. Think of all the different ways that a user could request to make a specific intent happen. Here are a few examples for DescriptionIntent:
63 |
64 | * Give me a fact
65 | * Tell me a fact
66 | * Tell me something
67 | * Tell me a space fact
68 |
69 | 
70 |
71 | 11. Click on the **Save Model** button, and then click on the **Build Model** button.
72 |
73 | 
74 |
75 |
117 |
118 | 12. If your interaction model builds successfully, click on **Configuration button** to move on to Configuration. In our next step of this guide, we will be creating our Lambda function in the AWS developer console, but keep this browser tab open, because we will be returning here on [Page #3: Connect VUI to Code](./3-connect-vui-to-code.md).
119 | 
120 |
121 | If you get an error from your interaction model, check through this list:
122 |
123 | * **Did you copy & paste the provided code into the appropriate boxes?**
124 | * **Did you accidentally add any characters to the Interaction Model or Sample Utterances?**
125 |
126 |
127 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/instructions/2-lambda-function.md:
--------------------------------------------------------------------------------
1 | # Build An Alexa Fact Skill
2 | [](./1-voice-user-interface.md)[](./2-lambda-function.md)[](./3-connect-vui-to-code.md)[](./4-testing.md)[](./5-customization.md)[](./6-publication.md)
3 |
4 | ## Setting Up A Lambda Function Using Amazon Web Services
5 |
6 | In the [first step of this guide](./1-voice-user-interface.md), we built the Voice User Interface (VUI) for our Alexa skill. On this page, we will be creating an AWS Lambda function using [Amazon Web Services](http://aws.amazon.com). You can [read more about what a Lambda function is](http://aws.amazon.com/lambda), but for the purposes of this guide, what you need to know is that AWS Lambda is where our code lives. When a user asks Alexa to use our skill, it is our AWS Lambda function that interprets the appropriate interaction, and provides the conversation back to the user.
7 |
8 | 1. **Go to http://aws.amazon.com and sign in to the console.** If you don't already have an account, you will need to create one. [If you don't have an AWS account, check out this quick walkthrough for setting it up](https://github.com/alexa/alexa-cookbook/tree/master/aws/set-up-aws.md).
9 |
10 |
11 |
12 | 2. **Click "Services" at the top of the screen, and type "Lambda" in the search box.** You can also find Lambda in the list of services. It is in the "Compute" section.
13 |
14 |
15 |
16 | 3. **Check your AWS region.** AWS Lambda only works with the Alexa Skills Kit in two regions: US East (N. Virginia) and EU (Ireland). Make sure you choose the region closest to your customers.
17 |
18 |
19 |
20 | 4. **Click the "Create a Lambda function" button.** It should be near the top of your screen. (If you don't see this button, it is because you haven't created a Lambda function before. Click the blue "Get Started" button near the center of your screen.)
21 |
22 |
23 |
24 | 5. **There are two boxes labeled "Author from scratch" and "Blueprints". Click the radio button in the box titled "Blueprints" then choose the blueprint named "alexa-skill-kit-sdk-factskill".** We have created a blueprint as a shortcut to getting everything set up for your skill. You can search for a blueprint using the provided search box. This blueprint adds the alexa-sdk to your Lambda function so that you don't have to upload it yourself.
25 |
26 |
27 |
28 | 6. **Configure your function.** This screen is where we will enter the important parts of our Lambda function. These values will only ever be visible to you, but make sure that you name your function something meaningful. "SpaceFacts" is sufficient if you don't have another idea for a name.
29 |
30 |
31 |
32 | 7. **Set up your Lambda function role.** If you haven't done this before, we have a [detailed walkthrough for setting up your first role for Lambda](https://github.com/alexa/alexa-cookbook/tree/master/aws/lambda-role.md). If you have done this before, set your **Existing role** value to "lambda_basic_execution."
33 |
34 |
35 |
36 | 8. **Click Create Function in the bottom right corner.** You will need to scroll down to find **Create Function.**
37 |
38 |
39 |
40 | 9. **After you create the function, the ARN value appears in the top right corner. Copy this value for use in the next section of the guide.**
41 |
42 |
43 |
44 | 10. **Configure your trigger.** Look at the column on the left called "Add triggers", and select Alexa Skills Kit from the list. If you don't see Alexa Skills Kit in the list, jump back to step #3 on this page.
45 |
46 |
47 |
48 | Once you have selected Alexa Skills Kit, scroll down and click the **Add** button. Then click the **Save** button in the top right. You should see a green success message at the top of your screen. Now, click the box that has the Lambda icon followed by the name of your function (SpaceFacts if you used our suggestion) and scroll down to the field called "Function code".
49 |
50 | 7. **Copy and paste the [provided code](https://github.com/alexa/skill-sample-nodejs-fact/blob/en-US/lambda/custom/index.js) into the Lambda function code box.** We have provided the code for this skill on [GitHub](https://github.com/alexa/skill-sample-nodejs-fact/blob/en-US/lambda/custom/index.js). Delete the contents of the code box, and paste the contents of the new code.
51 | Click "Save".
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/instructions/3-connect-vui-to-code.md:
--------------------------------------------------------------------------------
1 | # Build An Alexa Fact Skill
2 | [](./1-voice-user-interface.md)[](./2-lambda-function.md)[](./3-connect-vui-to-code.md)[](./4-testing.md)[](./5-customization.md)[](./6-publication.md)
3 |
4 | ## Connecting Your Voice User Interface To Your Lambda Function
5 |
6 | On [page #1](./1-voice-user-interface.md) of this guide, we created a voice user interface for the intents and utterances we expect from our users. On [page #2](./2-lambda-function.md), we created a Lambda function that contains all of our logic for the skill. On this page, we need to connect those two pieces together.
7 |
8 | 1. **Go back to the [Amazon Developer Portal](https://developer.amazon.com/edw/home.html#/skills/list) and select your skill from the list.** You may still have a browser tab open if you started at the beginning of this tutorial.
9 |
10 | 2. **Open the "Configuration" tab on the left side.**
11 |
12 |
13 |
14 | 3. **Select the "AWS Lambda ARN" option for your endpoint.** You have the ability to host your code anywhere that you would like, but for the purposes of simplicity and frugality, we are using AWS Lambda. ([Read more about Hosting Your Own Custom Skill Web Service](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/developing-an-alexa-skill-as-a-web-service).) With the AWS Free Tier, you get 1,000,000 free requests per month, up to 3.2 million seconds of compute time per month. Learn more at https://aws.amazon.com/free/. In addition, Amazon now offers [AWS Promotional Credits for developers who have live Alexa skills that incur costs on AWS related to those skills](https://developer.amazon.com/alexa-skills-kit/alexa-aws-credits).
15 |
16 |
17 |
18 | 4. **Select "North America" or "Europe" as your geographical region.** IMPORTANT: Make sure you select the same region that you created your Lambda in. Remember, Alexa skills using AWS Lambda can only run in N. Virginia (North America) and Ireland (Europe).
19 |
20 |
21 |
22 | 5. **Paste your Lambda's ARN (Amazon Resource Name) into the textbox provided.** It should look similar to the screenshot above.
23 |
24 | 6. **Leave "Account Linking" set to "No."** For this skill, we won't be using Account Linking, but you can learn more about [Linking an Alexa User with a User in Your System.](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/linking-an-alexa-user-with-a-user-in-your-system)
25 |
26 | 7. **Click the "Next" button to continue to page #4 of this guide.**
27 |
28 | [](./4-testing.md)
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/instructions/4-testing.md:
--------------------------------------------------------------------------------
1 | # Build An Alexa Fact Skill
2 | [](./1-voice-user-interface.md)[](./2-lambda-function.md)[](./3-connect-vui-to-code.md)[](./4-testing.md)[](./5-customization.md)[](./6-publication.md)
3 |
4 | ## Testing Your Alexa Skill
5 |
6 | So far, we have [created a Voice User Interface](./1-voice-user-interface.md) and [a Lambda function](./2-lambda-function.md), and [connected the two together](./3-connect-vui-to-lambda.md). Your skill is now ready to test.
7 |
8 | 1. **Go back to the [Amazon Developer Portal](https://developer.amazon.com/edw/home.html#/skills/list) and select your skill from the list.** You may still have a browser tab open if you started at the beginning of this tutorial.
9 |
10 | 2. **Open the "Test" tab on the left side.**
11 |
12 |
13 |
14 | 3. **Understand the voice simulator.** While it's not specific to your skill, the Voice Simulator is a valuable testing tool for every skill. Type a word into the box, and click the "Listen" button to hear how Alexa will
15 | pronounce it. To make changes to her pronunciation, use Speech Synthesis Markup Language [(SSML)](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference) to modify how Alexa will interpret text to speech. Try these examples:
16 |
17 | ```html
18 | 12345
19 | ```
20 |
21 | ```html
22 | 12345
23 | ```
24 |
25 | ```html
26 | 12345
27 | ```
28 |
29 |
30 |
31 | Return to the Voice Simulator as needed to ensure that Alexa says words and phrases as you would expect.
32 |
33 | 4. **Test your skill with the Service Simulator.** To validate that your skill is working as expected, use the Service Simulator. In the **Enter Utterance** text box, type "open reindeer trivia"
34 |
35 |
36 |
37 | ### Service Simulator Tips
38 | * After you click the "Ask [Your Skill Name]" button, you should see the **Lambda Request** and **Lambda Response** boxes get populated with JSON data like in the screenshot above.
39 | * Click the **Listen** button in the bottom right corner to hear Alexa read the response.
40 |
41 | * If you receive a response that reads: *"The remote endpoint could not be called, or the response it returned was invalid,"* this is an indication that something is broken. AWS Lambda offers an additional testing tool to help you troubleshoot your skill.
42 |
43 | 5. **Configure a test event in AWS Lambda.** Now that you are familiar with the **request** and **response** boxes in the Service Simulator, it's important for you to know that you can use your **requests** to directly test your Lambda function every time you update it. To do this:
44 | 1. Enter an utterance in the service simulator, and copy the generated Lambda Request for the next step.
45 |
46 | 2. **Open your Lambda function in AWS, open the Actions menu, and select "Configure test events."**
47 |
48 |
49 |
50 | 3. **Select "Create New Test Event". Choose "Alexa Start Session" as the Event Template from the dropdown list.** You can choose any test event in the list, as they are just templated event requests, but using "Alexa Start Session" is an easy one to remember.
51 |
52 |
53 |
54 | 4. **Type in an Event Name into the Event Name Dialog box. Delete the contents of the code editor, and paste the Lambda request you copied above into the code editor.** The Event Name is only visible to you. Name your test event something descriptive and memorable. For our example, we entered an event name as "startSession". Additionally, by copying and pasting your Lambda Request from the service simulator, you can test different utterances and skill events beyond the pre-populated templates in Lambda.
55 |
56 |
57 |
58 | 5. **Click the "Create" button.** This will save your test event and bring you back to the main configuration for your lambda function.
59 |
60 | 6. **Click the "Test" button to execute the "startSession" test event.**
61 |
62 |
63 |
64 | This gives you visibility into four things:
65 |
66 | * **Your response, listed in the "Execution Result."**
67 |
68 |
69 |
70 | * **A Summary of the statistics for your request.** This includes things like duration, resources, and memory used.
71 |
72 |
73 |
74 | * **Log output.** By effectively using console.log() statements in your Lambda code, you can track what is happening inside your function, and help to figure out what is happening when something goes wrong. You will find the log to be incredibly valuable as you move into more advanced skills.
75 |
76 |
77 |
78 | * **A link to your [CloudWatch](https://console.aws.amazon.com/cloudwatch/home?region=us-east-1#logs:) logs for this function.** This will show you **all** of the responses and log statements from every user interaction. This is very useful, especially when you are testing your skill from a device with your voice. (It is the "[Click here](https://console.aws.amazon.com/cloudwatch/home?region=us-east-1#logs:)" link in the Log Output description.)
79 |
80 | 6. **Other testing methods to consider:**
81 |
82 | * [Echosim.io](https://echosim.io) - a browser-based Alexa skill testing tool that makes it easy to test your skills without carrying a physical device everywhere you go.
83 | * [Unit Testing with Alexa](https://github.com/alexa/alexa-cookbook/tree/master/testing/postman/README.md) - a modern approach to unit testing your Alexa skills with [Postman](http://getpostman.com) and [Amazon API Gateway](http://aws.amazon.com/apigateway).
84 |
85 | 7. **If your sample skill is working properly, you can now customize your skill.**
86 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/instructions/5-customization.md:
--------------------------------------------------------------------------------
1 | # Build An Alexa Fact Skill
2 | [](./1-voice-user-interface.md)[](./2-lambda-function.md)[](./3-connect-vui-to-code.md)[](./4-testing.md)[](./5-customization.md)[](./6-publication.md)
3 |
4 | ## Customize the Skill to be Yours
5 |
6 | At this point, you should have a working copy of our Fact skill. In order to make it your own, you will need to customize it with data and responses that you create. Here are the things you will need to change:
7 |
8 | 1. **New data.** You will need to provide a set of facts for your topic. We recommend a minimum of 25, but a total closer to 100 offers a better experience.
9 |
10 | 1. **Open a copy of index.js.** If you haven't already downloaded the code for this project, [you can find a copy of index.js here on GitHub](https://github.com/alexa/skill-sample-nodejs-fact/blob/en-US/lambda/custom/index.js). You can use a simple, lightweight code editor like [Atom](http://atom.io), [Sublime Text](http://sublimetext.com), or [VSCode](http://code.visualstudio.com), but you also have the option to edit the code directly in your Lambda function.
11 |
12 | 2. **Search for the comment "TODO: Replace this data with your own."** This is the data for our skill. You can see that it is a simple list of facts.
13 |
14 | 3. **When you have replaced the data in index.js, copy the contents of your file to your Lambda function.** This should be as simple as copying the text, and pasting it into the code box for your Lambda.
15 |
16 |
17 |
18 | 2. **New sentences to respond to your users.** There are several sentences and responses that you will want to customize for your skill.
19 |
20 | 1. **Go back to your copy of [index.js]((https://github.com/alexa/skill-sample-nodejs-fact/blob/en-US/lambda/custom/index.js)).**
21 |
22 | 2. **Look for the comment "TODO: The items below this comment need your attention."** This is the beginning of the section where you need to customize several text strings for your skill.
23 |
24 | 3. **Continue through index.js until you reach the bottom of the file.** This will ensure that you cover each of the values that you need to update.
25 |
26 | 3. **New language.** If you are creating this skill for another language other than English, you will need to make sure Alexa's responses are also in that language.
27 |
28 | * For example, if you are creating your skill in German, every single response that Alexa makes has to be in German. You can't use English responses or your skill will fail certification.
29 |
30 | 4. **Once you have made the updates listed on this page, you can click "Next" to move on to Publishing and Certification of your skill.**
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/instructions/6-publication.md:
--------------------------------------------------------------------------------
1 | # Build An Alexa Fact Skill
2 | [](./1-voice-user-interface.md)[](./2-lambda-function.md)[](./3-connect-vui-to-code.md)[](./4-testing.md)[](./5-customization.md)[](./6-publication.md)
3 |
4 | ## Get Your Skill Certified and Published
5 |
6 | We are almost done! The last step is to add the metadata that your skill will use in the [Alexa app](http://amazon.com/skills). This page will walk you through the remaining steps, and give you some tips on how to avoid the common mistakes developers make that result in a failed certification.
7 |
8 | 1. **Go to your skill's Publishing Information tab on the [Amazon Developer Portal](https://developer.amazon.com/edw/home.html#/skills/list).**
9 |
10 |
11 |
12 | 2. **Complete the Global Fields data.** These fields apply across all of the languges that your skill supports.
13 |
14 |
15 |
16 | * **For Category, we are building a fact skill, so select "Games, Trivia, and Accessories."** You will also be presented with a **Sub-Category** option. For this skill, choose "Knowledge and Trivia."
17 |
18 | * **Provide testing instructions.** Testing instructions give you an opportunity to explain your skill, and any special or possibly confusing features, to the certification team. A value is required in this box.
19 |
20 | * Since you are using our Fact Sample, make sure to add this sentence to your Testing Instructions:
21 |
22 | ```
23 | This was built using the Fact Sample.
24 | ```
25 |
26 | This will let the testing team understand what you're providing them, and should decrease the testing time required.
27 |
28 | * **Countries and Region can be for "all countries", unless you have a specific reason to exclude a specific location.** This gives Amazon the ability to distribute your skill globally. Remember that you will need to create additional versions of your skill in the other available languages before they will be available in those countries.
29 |
30 | 3. **Write your skill descriptions.**
31 |
32 |
33 |
34 | * **Spend some time coming up with an enticing, succinct description.** This is one of the few places you have an opportunity to attract new users, so make the most of it! These descriptions show up in the list of skills available in the [Alexa app](http://alexa.amazon.com/spa/index.html#skills).
35 |
36 | 4. **For your example phrases, come up with the three most exciting ways a user can talk to your skill.**
37 |
38 |
39 |
40 | * **Make sure that each of your example phrases are a perfect match with one of your Sample Utterances.** Incorrect example phrases are one of the most common reasons that skills fail certification, so we have provided a short list of things to consider as you write your example phrases:
41 |
42 | | Common Failure Points for Example Phrases |
43 | | ----------------------------------------- |
44 | | Example phrases **must** adhere to the [supported phrases](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/supported-phrases-to-begin-a-conversation). |
45 | | Example phrases **must** be based on sample utterances specified in your Intent Schema. |
46 | | Your first example phrase **must** include a wake word and your invocation name. |
47 | | Example phrases **must** provide a contextual response. |
48 |
49 | * **Choose three example phrases that are likely to be the most common ways that users will attempt to interact with your skill.** Make sure that each of them works well, and provides an excellent user experience.
50 |
51 | 5. **Provide a comprehensive list of keywords for users that are searching for new skills.** This is an optional field, and searching the [Alexa app](http://alexa.amazon.com) will also find the words in your Skill Name and descriptions, so you don't need to overdo it. That being said, if there are words that you want users to find your skill with, you should include them here. Separate the keywords with commas.
52 |
53 |
54 |
55 | 6. **Create your skill's icons.** You need two sizes of your icon: 108x108px and 512x512px.
56 |
57 |
58 |
59 | * **Make sure you have the rights to the icons you create.** Please don't violate any trademarks or copyrights.
60 | * **If you don't have software to make icons, try one of these free options:**
61 |
62 | * [GIMP](https://www.gimp.org/) (Windows/Mac/Linux)
63 | * [Paint.NET](http://www.getpaint.net/index.html) (Windows)
64 | * [Inkscape](http://inkscape.org) (Windows/Mac/Linux)
65 | * [Iconion](http://iconion.com/) (Windows/Mac)
66 |
67 | * To make it easier to get started, we've created blank versions of these icons in both sizes for many formats:
68 |
69 | * [PSD](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/icon-templates/psd._TTH_.zip)
70 | * [PNG](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/icon-templates/png._TTH_.zip)
71 | * [GIF](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/icon-templates/gif._TTH_.zip)
72 | * [PDF](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/icon-templates/pdf._TTH_.zip)
73 | * [JPG](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/icon-templates/jpg._TTH_.zip)
74 | * [SVG](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/icon-templates/svg._TTH_.zip)
75 | * [PDN](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/icon-templates/pdn._TTH_.zip) - for [Paint.NET](http://www.getpaint.net/index.html)
76 | * [XCF](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/icon-templates/xcf._TTH_.zip) - for [GIMP](https://www.gimp.org/)
77 |
78 | 7. **Open the Privacy & Compliance tab on the left side of your skill in the [Developer Portal](https://developer.amazon.com/edw/home.html#/skills/list).**
79 |
80 |
81 |
82 | 8. **Answer each of the Global Fields questions using the guidance below.** These fields also apply across all of the languages that your skill supports.
83 |
84 |
85 |
86 | * **Does this skill allow users to make purchases or spend real money?** For this fact skill, the answer is no. For future skills, make sure you answer this appropriately.
87 |
88 | * **Does this Alexa skill collect users' personal information?** Again, for this fact skill, the answer is no. If you do collect information about a user, such as names, email addresses, phone numbers, and so forth, ensure that you answer Yes to this question.
89 | * Answering "yes" to this question will also require you to provide a link to your Privacy Policy at the bottom of the page.
90 |
91 | * **Is your skill directed to children under the age of 13?** Because you customized this skill with data you provided, it is possible that you created a skill that targets children under the age of 13. For this fact skill, the answer is **no** because it doesn't target a specific age group.
92 | * Factors to consider in determining if this skill is directed to children under 13 include:
93 | * Subject matter of the skill
94 | * Presence of child-oriented activities and incentives
95 | * Type of language used in the skill
96 | * Music and other audio content in the skill
97 | * How the skill is described and marketed
98 | * Intended audience for the skill
99 |
100 | If you're not sure, please see the [FTC's COPPA Guidance and FAQ](https://www.ftc.gov/tips-advice/business-center/guidance/complying-coppa-frequently-asked-questions) for more information.
101 |
102 | 9. **Export Compliance.** Be certain that you agree with all of the conditions. If you do, make sure to check this box, as Amazon requires this permission to distribute your skill around the globe.
103 |
104 | 10. **Privacy Policy URL.** This is an optional field, and should not be required for this Fact skill sample. You can leave it blank.
105 |
106 | 11. **Terms of Use URL.** This is also optional, and you can leave it blank.
107 |
108 | 12. **Click the Save button at the bottom of the page.**
109 |
110 |
111 |
112 | 13. **Each checkmark should be green, as shown.**
113 |
114 |
115 |
116 | 14. **If you feel that your skill is ready for certification, click the "Submit for Certification" button at the bottom of the page.**
117 |
118 |
119 |
120 | 15. **You're done with your submission!** Here are a few things you might need to know:
121 |
122 | * **Certification can take several days to complete.** Please be patient. It takes time because we want to get it right.
123 |
124 | * **Did something go wrong?** Our team of evangelists run [online office hours every Tuesday from 1-2pm Pacific Time](https://attendee.gotowebinar.com/rt/8389200425172113931). They can help answer any questions you might have.
125 |
126 | * **Want the coolest t-shirt you've ever seen?** Every month, we create a brand-new Alexa Developer t-shirt or hoodie, and send them out to developers that published a skill that month. [You can get yours here if you live in the US](https://developer.amazon.com/alexa-skills-kit/alexa-developer-skill-promotion), [here for the UK](https://developer.amazon.com/en-gb/alexa-skills-kit/alexa-developer-skill-promotion), and [here for Germany](https://developer.amazon.com/de-de/alexa-skills-kit/alexa-developer-skill-promotion).
127 |
128 |
129 |
--------------------------------------------------------------------------------
/lambda/custom/index.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable func-names */
2 | /* eslint quote-props: ["error", "consistent"]*/
3 | /**
4 | * This sample demonstrates a simple skill built with the Amazon Alexa Skills
5 | * nodejs skill development kit.
6 | * This sample supports multiple lauguages. (en-US, en-GB, de-DE).
7 | * The Intent Schema, Custom Slots and Sample Utterances for this skill, as well
8 | * as testing instructions are located at https://github.com/alexa/skill-sample-nodejs-fact
9 | **/
10 |
11 | 'use strict';
12 | const Alexa = require('alexa-sdk');
13 |
14 | //=========================================================================================================================================
15 | //TODO: The items below this comment need your attention.
16 | //=========================================================================================================================================
17 |
18 | //Replace with your app ID (OPTIONAL). You can find this value at the top of your skill's page on http://developer.amazon.com.
19 | //Make sure to enclose your value in quotes, like this: const APP_ID = 'amzn1.ask.skill.bb4045e6-b3e8-4133-b650-72923c5980f1';
20 | const APP_ID = undefined;
21 |
22 | const SKILL_NAME = 'Space Facts';
23 | const GET_FACT_MESSAGE = "Here's your fact: ";
24 | const HELP_MESSAGE = 'You can say tell me a space fact, or, you can say exit... What can I help you with?';
25 | const HELP_REPROMPT = 'What can I help you with?';
26 | const STOP_MESSAGE = 'Goodbye!';
27 |
28 | //=========================================================================================================================================
29 | //TODO: Replace this data with your own. You can find translations of this data at http://github.com/alexa/skill-sample-node-js-fact/lambda/data
30 | //=========================================================================================================================================
31 | const data = [
32 | 'A year on Mercury is just 88 days long.',
33 | 'Despite being farther from the Sun, Venus experiences higher temperatures than Mercury.',
34 | 'Venus rotates counter-clockwise, possibly because of a collision in the past with an asteroid.',
35 | 'On Mars, the Sun appears about half the size as it does on Earth.',
36 | 'Earth is the only planet not named after a god.',
37 | 'Jupiter has the shortest day of all the planets.',
38 | 'The Milky Way galaxy will collide with the Andromeda Galaxy in about 5 billion years.',
39 | 'The Sun contains 99.86% of the mass in the Solar System.',
40 | 'The Sun is an almost perfect sphere.',
41 | 'A total solar eclipse can happen once every 1 to 2 years. This makes them a rare event.',
42 | 'Saturn radiates two and a half times more energy into space than it receives from the sun.',
43 | 'The temperature inside the Sun can reach 15 million degrees Celsius.',
44 | 'The Moon is moving approximately 3.8 cm away from our planet every year.',
45 | ];
46 |
47 | //=========================================================================================================================================
48 | //Editing anything below this line might break your skill.
49 | //=========================================================================================================================================
50 |
51 | exports.handler = function(event, context, callback) {
52 | var alexa = Alexa.handler(event, context);
53 | alexa.appId = APP_ID;
54 | alexa.registerHandlers(handlers);
55 | alexa.execute();
56 | };
57 |
58 | const handlers = {
59 | 'LaunchRequest': function () {
60 | this.emit('GetNewFactIntent');
61 | },
62 | 'GetNewFactIntent': function () {
63 | const factArr = data;
64 | const factIndex = Math.floor(Math.random() * factArr.length);
65 | const randomFact = factArr[factIndex];
66 | const speechOutput = GET_FACT_MESSAGE + randomFact;
67 |
68 | this.response.cardRenderer(SKILL_NAME, randomFact);
69 | this.response.speak(speechOutput);
70 | this.emit(':responseReady');
71 | },
72 | 'AMAZON.HelpIntent': function () {
73 | const speechOutput = HELP_MESSAGE;
74 | const reprompt = HELP_REPROMPT;
75 |
76 | this.response.speak(speechOutput).listen(reprompt);
77 | this.emit(':responseReady');
78 | },
79 | 'AMAZON.CancelIntent': function () {
80 | this.response.speak(STOP_MESSAGE);
81 | this.emit(':responseReady');
82 | },
83 | 'AMAZON.StopIntent': function () {
84 | this.response.speak(STOP_MESSAGE);
85 | this.emit(':responseReady');
86 | },
87 | };
88 |
--------------------------------------------------------------------------------
/lambda/custom/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "skill-sample-nodejs-fact-i18n",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "dependencies": {
6 | "alexa-sdk": {
7 | "version": "1.0.12",
8 | "resolved": "https://registry.npmjs.org/alexa-sdk/-/alexa-sdk-1.0.12.tgz",
9 | "integrity": "sha1-9+OBOPzVehfIikiVpVf/Tr2vuck="
10 | },
11 | "aws-sdk": {
12 | "version": "2.101.0",
13 | "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.101.0.tgz",
14 | "integrity": "sha1-ElLDZLhA66GuC4zYwazPeL+hTZY="
15 | },
16 | "base64-js": {
17 | "version": "1.2.1",
18 | "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.1.tgz",
19 | "integrity": "sha512-dwVUVIXsBZXwTuwnXI9RK8sBmgq09NDHzyR9SAph9eqk76gKK2JSQmZARC2zRC81JC2QTtxD0ARU5qTS25gIGw=="
20 | },
21 | "buffer": {
22 | "version": "4.9.1",
23 | "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz",
24 | "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg="
25 | },
26 | "crypto-browserify": {
27 | "version": "1.0.9",
28 | "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-1.0.9.tgz",
29 | "integrity": "sha1-zFRJaF37hesRyYKKzHy4erW7/MA="
30 | },
31 | "events": {
32 | "version": "1.1.1",
33 | "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz",
34 | "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ="
35 | },
36 | "i18next": {
37 | "version": "3.5.2",
38 | "resolved": "https://registry.npmjs.org/i18next/-/i18next-3.5.2.tgz",
39 | "integrity": "sha1-kwOQ1cMYzqpIWLUt0OQOayA/n0E="
40 | },
41 | "i18next-sprintf-postprocessor": {
42 | "version": "0.2.2",
43 | "resolved": "https://registry.npmjs.org/i18next-sprintf-postprocessor/-/i18next-sprintf-postprocessor-0.2.2.tgz",
44 | "integrity": "sha1-LkCfEENXk4Jpi2otpwzapVHWfqQ="
45 | },
46 | "ieee754": {
47 | "version": "1.1.8",
48 | "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz",
49 | "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q="
50 | },
51 | "isarray": {
52 | "version": "1.0.0",
53 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
54 | "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
55 | },
56 | "jmespath": {
57 | "version": "0.15.0",
58 | "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz",
59 | "integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc="
60 | },
61 | "lodash": {
62 | "version": "4.17.4",
63 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
64 | "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4="
65 | },
66 | "punycode": {
67 | "version": "1.3.2",
68 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz",
69 | "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0="
70 | },
71 | "querystring": {
72 | "version": "0.2.0",
73 | "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
74 | "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA="
75 | },
76 | "sax": {
77 | "version": "1.2.1",
78 | "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz",
79 | "integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o="
80 | },
81 | "url": {
82 | "version": "0.10.3",
83 | "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz",
84 | "integrity": "sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ="
85 | },
86 | "uuid": {
87 | "version": "3.0.1",
88 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.0.1.tgz",
89 | "integrity": "sha1-ZUS7ot/ajBzxfmKaOjBeK7H+5sE="
90 | },
91 | "xml2js": {
92 | "version": "0.4.17",
93 | "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.17.tgz",
94 | "integrity": "sha1-F76T6q4/O3eTWceVtBlwWogX6Gg="
95 | },
96 | "xmlbuilder": {
97 | "version": "4.2.1",
98 | "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.2.1.tgz",
99 | "integrity": "sha1-qlijBBoGb5DqoWwvU4n/GfP0YaU="
100 | }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/lambda/custom/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "skill-sample-nodejs-fact-i18n",
3 | "version": "1.0.0",
4 | "description": "I18n version of fact skill.",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [
10 | "alexa",
11 | "skill",
12 | "fact"
13 | ],
14 | "author": "Amazon.com",
15 | "license": "Apache-2.0",
16 | "dependencies": {
17 | "alexa-sdk": "^1.0.12"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/lambda/data/facts-de-DE.js:
--------------------------------------------------------------------------------
1 | var data = [
2 | "Ein Jahr dauert auf dem Merkur nur 88 Tage.",
3 | "Die Venus ist zwar weiter von der Sonne entfernt, hat aber höhere Temperaturen als Merkur.",
4 | "Venus dreht sich entgegen dem Uhrzeigersinn, möglicherweise aufgrund eines früheren Zusammenstoßes mit einem Asteroiden.",
5 | "Auf dem Mars erscheint die Sonne nur halb so groß wie auf der Erde.",
6 | "Die Erde ist der einzige Planet, der nicht nach einem Gott benannt ist.",
7 | "Jupiter hat den kürzesten Tag aller Planeten.",
8 | "Die Milchstraßengalaxis wird in etwa 5 Milliarden Jahren mit der Andromeda-Galaxis zusammenstoßen.",
9 | "Die Sonne macht rund 99,86 % der Masse im Sonnensystem aus.",
10 | "Die Sonne ist eine fast perfekte Kugel.",
11 | "Eine Sonnenfinsternis kann alle ein bis zwei Jahre eintreten. Sie ist daher ein seltenes Ereignis.",
12 | "Der Saturn strahlt zweieinhalb mal mehr Energie in den Weltraum aus als er von der Sonne erhält.",
13 | "Die Temperatur in der Sonne kann 15 Millionen Grad Celsius erreichen.",
14 | "Der Mond entfernt sich von unserem Planeten etwa 3,8 cm pro Jahr."
15 | ];
16 |
17 | var SKILL_NAME = "Weltraumwissen auf Deutsch";
18 | var GET_FACT_MESSAGE = "Hier sind deine Fakten: ";
19 | var HELP_MESSAGE = "Du kannst sagen, „Nenne mir einen Fakt über den Weltraum“, oder du kannst „Beenden“ sagen... Wie kann ich dir helfen?";
20 | var HELP_REPROMPT = "Wie kann ich dir helfen?";
21 | var STOP_MESSAGE = "Auf Wiedersehen!";
22 |
23 |
--------------------------------------------------------------------------------
/lambda/data/facts-en-GB.js:
--------------------------------------------------------------------------------
1 | var data = [
2 | "A year on Mercury is just 88 days long.",
3 | "Despite being farther from the Sun, Venus experiences higher temperatures than Mercury.",
4 | "Venus rotates counter-clockwise, possibly because of a collision in the past with an asteroid.",
5 | "On Mars, the Sun appears about half the size as it does on Earth.",
6 | "Earth is the only planet not named after a god.",
7 | "Jupiter has the shortest day of all the planets.",
8 | "The Milky Way galaxy will collide with the Andromeda Galaxy in about 5 billion years.",
9 | "The Sun contains 99.86% of the mass in the Solar System.",
10 | "The Sun is an almost perfect sphere.",
11 | "A total solar eclipse can happen once every 1 to 2 years. This makes them a rare event.",
12 | "Saturn radiates two and a half times more energy into space than it receives from the sun.",
13 | "The temperature inside the Sun can reach 15 million degrees Celsius.",
14 | "The Moon is moving approximately 3.8 cm away from our planet every year."
15 | ];
16 |
17 | var SKILL_NAME = "British Space Facts";
18 | var GET_FACT_MESSAGE = "Here's your fact: ";
19 | var HELP_MESSAGE = "You can say tell me a space fact, or, you can say exit... What can I help you with?";
20 | var HELP_REPROMPT = "What can I help you with?";
21 | var STOP_MESSAGE = "Goodbye!";
--------------------------------------------------------------------------------
/lambda/data/facts-en-US.js:
--------------------------------------------------------------------------------
1 | var data = [
2 | "A year on Mercury is just 88 days long.",
3 | "Despite being farther from the Sun, Venus experiences higher temperatures than Mercury.",
4 | "Venus rotates counter-clockwise, possibly because of a collision in the past with an asteroid.",
5 | "On Mars, the Sun appears about half the size as it does on Earth.",
6 | "Earth is the only planet not named after a god.",
7 | "Jupiter has the shortest day of all the planets.",
8 | "The Milky Way galaxy will collide with the Andromeda Galaxy in about 5 billion years.",
9 | "The Sun contains 99.86% of the mass in the Solar System.",
10 | "The Sun is an almost perfect sphere.",
11 | "A total solar eclipse can happen once every 1 to 2 years. This makes them a rare event.",
12 | "Saturn radiates two and a half times more energy into space than it receives from the sun.",
13 | "The temperature inside the Sun can reach 15 million degrees Celsius.",
14 | "The Moon is moving approximately 3.8 cm away from our planet every year."
15 | ];
16 |
17 | var SKILL_NAME = "American Space Facts";
18 | var GET_FACT_MESSAGE = "Here's your fact: ";
19 | var HELP_MESSAGE = "You can say tell me a space fact, or, you can say exit... What can I help you with?";
20 | var HELP_REPROMPT = "What can I help you with?";
21 | var STOP_MESSAGE = "Goodbye!";
--------------------------------------------------------------------------------
/models/en-US.json:
--------------------------------------------------------------------------------
1 | {
2 | "interactionModel": {
3 | "languageModel": {
4 | "invocationName": "space facts",
5 | "intents": [
6 | {
7 | "name": "AMAZON.CancelIntent",
8 | "samples": []
9 | },
10 | {
11 | "name": "AMAZON.HelpIntent",
12 | "samples": []
13 | },
14 | {
15 | "name": "AMAZON.StopIntent",
16 | "samples": []
17 | },
18 | {
19 | "name": "GetNewFactIntent",
20 | "samples": [
21 | "a fact",
22 | "a space fact",
23 | "tell me a fact",
24 | "tell me a space fact",
25 | "give me a fact",
26 | "give me a space fact",
27 | "tell me trivia",
28 | "tell me a space trivia",
29 | "give me trivia",
30 | "give me a space trivia",
31 | "give me some information",
32 | "give me some space information",
33 | "tell me something",
34 | "give me something"
35 | ],
36 | "slots": []
37 | }
38 | ]
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/skill.json:
--------------------------------------------------------------------------------
1 | {
2 | "skillManifest": {
3 | "publishingInformation": {
4 | "locales": {
5 | "en-US": {
6 | "summary": "Learn fun facts about space.",
7 | "examplePhrases": [
8 | "Alexa open space facts",
9 | "Alexa ask space facts for a fact",
10 | "Alexa tell space facts to tell me trivia"
11 | ],
12 | "keywords": [
13 | "space",
14 | "facts",
15 | "trivia"
16 | ],
17 | "name": "Space Facts",
18 | "description": "Ask for Space Facts, and learn about what really matters, like dark matter.\n\nSpace Facts provides fun the whole family can enjoy and is guaranteed to make you smarter.\n\nTo start, just say \"Alexa, launch Space Facts\" or \"Alexa, open Space Facts\" to get a fact\".\n\nAt anytime, you can stop by saying \"Alexa, stop\""
19 | },
20 | "en-GB": {
21 | "summary": "Listen to My Radio, less bla bla bla, more la la la.",
22 | "examplePhrases": [
23 | "Alexa, open My Radio",
24 | "Alexa, play My Radio",
25 | "Alexa, ask My Radio to play"
26 | ],
27 | "keywords": [
28 | "music",
29 | "streaming",
30 | "radio"
31 | ],
32 | "name": "My Radio",
33 | "description": "Listen to My Radio, with less bla bla bla, and more la la la.\n\nMy Radio provides a high quality sound 24/7 with the best music.\n\nTo start, just say \"Alexa, launch My Radio\" or \"Alexa, play my radio\" to start the radio\".\n\nAt anytime, you can stop the radio by saying \"Alexa, stop\""
34 | }
35 | },
36 | "isAvailableWorldwide": true,
37 | "testingInstructions": "Sample Testing Instructions.",
38 | "category": "EDUCATION_AND_REFERENCE",
39 | "distributionCountries": []
40 | },
41 | "apis": {
42 | "custom": {
43 | "endpoint": {
44 | "sourceDir": "lambda/custom"
45 | }
46 | }
47 | },
48 | "manifestVersion": "1.0"
49 | }
50 | }
51 |
--------------------------------------------------------------------------------