├── .ask └── config ├── InteractionModel.json ├── LICENSE.txt ├── README.md ├── data ├── books.js ├── monarchs.js ├── states.js └── videogames.js ├── 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.json ├── 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": "ask-custom-StatesQuiz" 12 | } 13 | } 14 | } 15 | } 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /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.PauseIntent", 13 | "samples": [] 14 | }, 15 | { 16 | "name": "AMAZON.StartOverIntent", 17 | "samples": [] 18 | }, 19 | { 20 | "name": "AMAZON.StopIntent", 21 | "samples": [] 22 | }, 23 | { 24 | "name": "AnswerIntent", 25 | "samples": [ 26 | "{StateName}", 27 | "{Capital}", 28 | "{StatehoodYear}", 29 | "{StatehoodOrder}", 30 | "{Abbreviation}", 31 | "tell me about {StateName}", 32 | "tell me about {Capital}", 33 | "tell me about {StatehoodYear}", 34 | "tell me about {StatehoodOrder}", 35 | "tell me about {Abbreviation}", 36 | "what do you know about {StateName}", 37 | "what do you know about {Capital}", 38 | "what do you know about {StatehoodYear}", 39 | "what do you know about {StatehoodOrder}", 40 | "what do you know about {Abbreviation}", 41 | "{StateName} information", 42 | "{Capital} information", 43 | "{StatehoodYear} information", 44 | "{StatehoodOrder} information", 45 | "{Abbreviation} information" 46 | ], 47 | "slots": [ 48 | { 49 | "name": "StateName", 50 | "type": "AMAZON.US_STATE", 51 | "samples": [] 52 | }, 53 | { 54 | "name": "Capital", 55 | "type": "AMAZON.US_CITY", 56 | "samples": [] 57 | }, 58 | { 59 | "name": "StatehoodYear", 60 | "type": "AMAZON.FOUR_DIGIT_NUMBER", 61 | "samples": [] 62 | }, 63 | { 64 | "name": "Abbreviation", 65 | "type": "US_STATE_ABBR", 66 | "samples": [] 67 | }, 68 | { 69 | "name": "StatehoodOrder", 70 | "type": "AMAZON.NUMBER", 71 | "samples": [] 72 | } 73 | ] 74 | }, 75 | { 76 | "name": "QuizIntent", 77 | "samples": [ 78 | "start a quiz", 79 | "start a quiz game", 80 | "and start a quiz", 81 | "and quiz me", 82 | "for a quiz", 83 | "a quiz" 84 | ], 85 | "slots": [] 86 | } 87 | ], 88 | "types": [ 89 | { 90 | "name": "US_STATE_ABBR", 91 | "values": [ 92 | { 93 | "name": { 94 | "value": "AK" 95 | } 96 | }, 97 | { 98 | "name": { 99 | "value": "AL" 100 | } 101 | }, 102 | { 103 | "name": { 104 | "value": "AZ" 105 | } 106 | }, 107 | { 108 | "name": { 109 | "value": "AR" 110 | } 111 | }, 112 | { 113 | "name": { 114 | "value": "CA" 115 | } 116 | }, 117 | { 118 | "name": { 119 | "value": "CO" 120 | } 121 | }, 122 | { 123 | "name": { 124 | "value": "CT" 125 | } 126 | }, 127 | { 128 | "name": { 129 | "value": "DE" 130 | } 131 | }, 132 | { 133 | "name": { 134 | "value": "FL" 135 | } 136 | }, 137 | { 138 | "name": { 139 | "value": "GA" 140 | } 141 | }, 142 | { 143 | "name": { 144 | "value": "HI" 145 | } 146 | }, 147 | { 148 | "name": { 149 | "value": "ID" 150 | } 151 | }, 152 | { 153 | "name": { 154 | "value": "IL" 155 | } 156 | }, 157 | { 158 | "name": { 159 | "value": "IN" 160 | } 161 | }, 162 | { 163 | "name": { 164 | "value": "IA" 165 | } 166 | }, 167 | { 168 | "name": { 169 | "value": "KS" 170 | } 171 | }, 172 | { 173 | "name": { 174 | "value": "KY" 175 | } 176 | }, 177 | { 178 | "name": { 179 | "value": "LA" 180 | } 181 | }, 182 | { 183 | "name": { 184 | "value": "ME" 185 | } 186 | }, 187 | { 188 | "name": { 189 | "value": "MD" 190 | } 191 | }, 192 | { 193 | "name": { 194 | "value": "MA" 195 | } 196 | }, 197 | { 198 | "name": { 199 | "value": "MI" 200 | } 201 | }, 202 | { 203 | "name": { 204 | "value": "MN" 205 | } 206 | }, 207 | { 208 | "name": { 209 | "value": "MS" 210 | } 211 | }, 212 | { 213 | "name": { 214 | "value": "MO" 215 | } 216 | }, 217 | { 218 | "name": { 219 | "value": "MT" 220 | } 221 | }, 222 | { 223 | "name": { 224 | "value": "NE" 225 | } 226 | }, 227 | { 228 | "name": { 229 | "value": "NV" 230 | } 231 | }, 232 | { 233 | "name": { 234 | "value": "NH" 235 | } 236 | }, 237 | { 238 | "name": { 239 | "value": "NJ" 240 | } 241 | }, 242 | { 243 | "name": { 244 | "value": "NM" 245 | } 246 | }, 247 | { 248 | "name": { 249 | "value": "NY" 250 | } 251 | }, 252 | { 253 | "name": { 254 | "value": "NC" 255 | } 256 | }, 257 | { 258 | "name": { 259 | "value": "ND" 260 | } 261 | }, 262 | { 263 | "name": { 264 | "value": "OH" 265 | } 266 | }, 267 | { 268 | "name": { 269 | "value": "OK" 270 | } 271 | }, 272 | { 273 | "name": { 274 | "value": "OR" 275 | } 276 | }, 277 | { 278 | "name": { 279 | "value": "PA" 280 | } 281 | }, 282 | { 283 | "name": { 284 | "value": "RI" 285 | } 286 | }, 287 | { 288 | "name": { 289 | "value": "SC" 290 | } 291 | }, 292 | { 293 | "name": { 294 | "value": "SD" 295 | } 296 | }, 297 | { 298 | "name": { 299 | "value": "TN" 300 | } 301 | }, 302 | { 303 | "name": { 304 | "value": "TX" 305 | } 306 | }, 307 | { 308 | "name": { 309 | "value": "UT" 310 | } 311 | }, 312 | { 313 | "name": { 314 | "value": "VT" 315 | } 316 | }, 317 | { 318 | "name": { 319 | "value": "VA" 320 | } 321 | }, 322 | { 323 | "name": { 324 | "value": "WA" 325 | } 326 | }, 327 | { 328 | "name": { 329 | "value": "WV" 330 | } 331 | }, 332 | { 333 | "name": { 334 | "value": "WI" 335 | } 336 | }, 337 | { 338 | "name": { 339 | "value": "WY" 340 | } 341 | } 342 | ] 343 | } 344 | ] 345 | } 346 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Amazon Software License 2 | 3 | 1. Definitions 4 | “Licensor” means any person or entity that distributes its Work. 5 | 6 | “Software” means the original work of authorship made available under this License. 7 | 8 | “Work” means the Software and any additions to or derivative works of the Software that are made available under this License. 9 | 10 | The terms “reproduce,” “reproduction,” “derivative works,” and “distribution” have the meaning as provided under U.S. copyright law; provided, however, that for the purposes of this License, derivative works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work. 11 | 12 | Works, including the Software, are “made available” under this License by including in or with the Work either (a) a copyright notice referencing the applicability of this License to the Work, or (b) a copy of this License. 13 | 14 | 2. License Grants 15 | 16 | 2.1 Copyright Grant. Subject to the terms and conditions of this License, each Licensor grants to you a perpetual, worldwide, non-exclusive, royalty-free, copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense and distribute its Work and any resulting derivative works in any form. 17 | 18 | 2.2 Patent Grant. Subject to the terms and conditions of this License, each Licensor grants to you a perpetual, worldwide, non-exclusive, royalty-free patent license to make, have made, use, sell, offer for sale, import, and otherwise transfer its Work, in whole or in part. The foregoing license applies only to the patent claims licensable by Licensor that would be infringed by Licensor’s Work (or portion thereof) individually and excluding any combinations with any other materials or technology. 19 | 20 | 3. Limitations 21 | 22 | 3.1 Redistribution. You may reproduce or distribute the Work only if (a) you do so under this License, (b) you include a complete copy of this License with your distribution, and (c) you retain without modification any copyright, patent, trademark, or attribution notices that are present in the Work. 23 | 24 | 3.2 Derivative Works. You may specify that additional or different terms apply to the use, reproduction, and distribution of your derivative works of the Work (“Your Terms”) only if (a) Your Terms provide that the use limitation in Section 3.3 applies to your derivative works, and (b) you identify the specific derivative works that are subject to Your Terms. Notwithstanding Your Terms, this License (including the redistribution requirements in Section 3.1) will continue to apply to the Work itself. 25 | 26 | 3.3 Use Limitation. The Work and any derivative works thereof only may be used or intended for use with the web services, computing platforms or applications provided by Amazon.com, Inc. or its affiliates, including Amazon Web Services, Inc. 27 | 28 | 3.4 Patent Claims. If you bring or threaten to bring a patent claim against any Licensor (including any claim, cross-claim or counterclaim in a lawsuit) to enforce any patents that you allege are infringed by any Work, then your rights under this License from such Licensor (including the grants in Sections 2.1 and 2.2) will terminate immediately. 29 | 30 | 3.5 Trademarks. This License does not grant any rights to use any Licensor’s or its affiliates’ names, logos, or trademarks, except as necessary to reproduce the notices described in this License. 31 | 32 | 3.6 Termination. If you violate any term of this License, then your rights under this License (including the grants in Sections 2.1 and 2.2) will terminate immediately. 33 | 34 | 4. Disclaimer of Warranty. 35 | THE WORK IS PROVIDED “AS IS” WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR NON-INFRINGEMENT. YOU BEAR THE RISK OF UNDERTAKING ANY ACTIVITIES UNDER THIS LICENSE. SOME STATES’ CONSUMER LAWS DO NOT ALLOW EXCLUSION OF AN IMPLIED WARRANTY, SO THIS DISCLAIMER MAY NOT APPLY TO YOU. 36 | 37 | 5. Limitation of Liability. 38 | EXCEPT AS PROHIBITED BY APPLICABLE LAW, IN NO EVENT AND UNDER NO LEGAL THEORY, WHETHER IN TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE SHALL ANY LICENSOR BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATED TO THIS LICENSE, THE USE OR INABILITY TO USE THE WORK (INCLUDING BUT NOT LIMITED TO LOSS OF GOODWILL, BUSINESS INTERRUPTION, LOST PROFITS OR DATA, COMPUTER FAILURE OR MALFUNCTION, OR ANY OTHER COMM ERCIAL DAMAGES OR LOSSES), EVEN IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 39 | 40 | Effective Date – April 18, 2008 © 2008 Amazon.com, Inc. or its affiliates. All rights reserved. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Build An Alexa Quiz Game Skill 🇺🇸 2 | 3 | 4 | [![Voice User Interface](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/1-off._TTH_.png)](./instructions/1-voice-user-interface.md)[![Lambda Function](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/2-off._TTH_.png)](./instructions/2-lambda-function.md)[![Connect VUI to Code](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/3-off._TTH_.png)](./instructions/3-connect-vui-to-code.md)[![Testing](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/4-off._TTH_.png)](./instructions/4-testing.md)[![Customization](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/5-off._TTH_.png)](./instructions/5-customization.md)[![Publication](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/6-off._TTH_.png)](./instructions/6-publication.md) 5 | 6 | This Alexa sample skill is a template for a basic quiz game skill. Provided a list of interesting facts about a topic, Alexa will quiz a user with facts from the list. 7 | 8 | You can see an example of this skill in action - just enable the [United States Quiz](https://www.amazon.com/Jeff-Blankenburg-United-States-Quiz/dp/B06X9GQBRL) from the [Alexa app](http://amazon.com/skills). 9 | 10 | 11 | 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: 12 | 13 |

14 | 15 |

16 | 17 | 18 | Be sure to take a look at the [Additional Resources](#additional-resources) at the bottom of this page! 19 | 20 | 21 | ## About 22 | **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. 23 | 24 | 25 | 26 | ### Usage 27 | 28 | ```text 29 | Alexa, ask Quizgame to start a quiz. 30 | >> OK. I will ask you 10 questions about the United States. 31 | 32 | Alexa, start Quiz Game 33 | ``` 34 | 35 | ### Repository Contents 36 | * `/.ask` - [ASK CLI (Command Line Interface) Configuration](https://developer.amazon.com/docs/smapi/ask-cli-intro.html) 37 | * `/lambda/custom` - Back-End Logic for the Alexa Skill hosted on [AWS Lambda](https://aws.amazon.com/lambda/) 38 | * `/models` - Voice User Interface and Language Specific Interaction Models 39 | * `/instructions` - Step-by-Step Instructions for Getting Started 40 | * `skill.json` - [Skill Manifest](https://developer.amazon.com/docs/smapi/skill-manifest.html) 41 | 42 | ## Setup w/ ASK CLI 43 | 44 | ### Pre-requisites 45 | 46 | * Node.js (> v4.3) 47 | * Register for an [AWS Account](https://aws.amazon.com/) 48 | * Register for an [Amazon Developer Account](https://developer.amazon.com/) 49 | * Install and Setup [ASK CLI](https://developer.amazon.com/docs/smapi/quick-start-alexa-skills-kit-command-line-interface.html) 50 | 51 | ### Installation 52 | 1. Clone the repository. 53 | 54 | ```bash 55 | $ git clone https://github.com/alexa/skill-sample-nodejs-quiz-game/ 56 | ``` 57 | 58 | 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. 59 | 60 | ```bash 61 | $ cd skill-sample-nodejs-quiz-game 62 | $ ask init 63 | ``` 64 | 65 | 3. Install npm dependencies by navigating into the `/lambda/custom` directory and running the npm command: `npm install` 66 | 67 | ```bash 68 | $ cd lambda/custom 69 | $ npm install 70 | ``` 71 | 72 | 73 | ### Deployment 74 | 75 | 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. 76 | 77 | 1. Deploy the skill and the lambda function in one step by running the following command: 78 | 79 | ```bash 80 | $ ask deploy 81 | ``` 82 | 83 | ### Testing 84 | 85 | 1. To test, you need to login to Alexa Developer Console, and enable the "Test" switch on your skill from the "Test" Tab. 86 | 87 | 2. Simulate verbal interaction with your skill through the command line using the following example: 88 | 89 | ```bash 90 | $ ask simulate -l en-US -t "start quiz game" 91 | 92 | ✓ Simulation created for simulation id: 4a7a9ed8-94b2-40c0-b3bd-fb63d9887fa7 93 | ◡ Waiting for simulation response{ 94 | "status": "SUCCESSFUL", 95 | ... 96 | ``` 97 | 98 | 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 : 99 | 100 | ```text 101 | Alexa, start quiz game 102 | ``` 103 | 104 | ## Customization 105 | 106 | 1. ```./skill.json``` 107 | 108 | Change the skill name, example phrase, icons, testing instructions etc ... 109 | 110 | Remember that many information is locale-specific and must be changed for each locale (en-GB and en-US) 111 | 112 | See the Skill [Manifest Documentation](https://developer.amazon.com/docs/smapi/skill-manifest.html) for more information. 113 | 114 | 2. ```./lambda/custom/index.js``` 115 | 116 | Modify messages, and facts from the source code to customize the skill. 117 | 118 | 3. ```./models/*.json``` 119 | 120 | Change the model definition to replace the invocation name and the sample phrase for each intent. Repeat the operation for each locale you are planning to support. 121 | 122 | ## Additional Resources 123 | 124 | ### Community 125 | * [Amazon Developer Forums](https://forums.developer.amazon.com/spaces/165/index.html) - Join the conversation! 126 | * [Hackster.io](https://www.hackster.io/amazon-alexa) - See what others are building with Alexa. 127 | 128 | ### Tutorials & Guides 129 | * [Voice Design Guide](https://developer.amazon.com/designing-for-voice/) - A great resource for learning conversational and voice user interface design. 130 | * [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! 131 | 132 | ###Documentation 133 | * [Official Alexa Skills Kit Node.js SDK](https://www.npmjs.com/package/alexa-sdk) - The Official Node.js SDK Documentation 134 | * [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 135 | -------------------------------------------------------------------------------- /data/books.js: -------------------------------------------------------------------------------- 1 | //========================================================================================================================================= 2 | //This data quizzes users about the author and publication dates of well-known books. 3 | //Data for this list came from: https://en.wikipedia.org/wiki/List_of_best-selling_books 4 | //========================================================================================================================================= 5 | 6 | 7 | 8 | var data = [ 9 | {BookTitle: "Don Quixote", Author: "Miguel de Cervantes", OriginalPublicationDate:1612}, 10 | {BookTitle: "A Tale of Two Cities", Author: "Charles Dickens", OriginalPublicationDate:1859}, 11 | {BookTitle: "The Fellowship of the Ring", Author: "J. R. R. Tolkien", OriginalPublicationDate:1954}, 12 | {BookTitle: "The Two Towers", Author: "J. R. R. Tolkien", OriginalPublicationDate:1954}, 13 | {BookTitle: "The Hobbit", Author: "J. R. R. Tolkien", OriginalPublicationDate:1937}, 14 | {BookTitle: "The Little Prince", Author: "Antoine de Saint-Exupery", OriginalPublicationDate:1943}, 15 | {BookTitle: "The Return of the King", Author: "J. R. R. Tolkien", OriginalPublicationDate:1955}, 16 | {BookTitle: "Harry Potter and the Philosopher's Stone", Author: "J. K. Rowling", OriginalPublicationDate:1997}, 17 | {BookTitle: "And Then There Were None", Author: "Agatha Christie", OriginalPublicationDate:1939}, 18 | {BookTitle: "Alice In Wonderland", Author: "Lewis Carroll", OriginalPublicationDate:1865} 19 | ]; 20 | -------------------------------------------------------------------------------- /data/monarchs.js: -------------------------------------------------------------------------------- 1 | var data = [ 2 | { Name:"Queen Anne", YearOfCoronation:1707, Predecessor:"none", Successor:"King George the First", YearOfDeath:1714}, 3 | { Name:"King George the 1st", YearOfCoronation:1714, Predecessor:"Queen Anne", Successor:"King George the Second", YearOfDeath:1727}, 4 | { Name:"King George the 2nd", YearOfCoronation:1727, Predecessor:"King George the 1st", Successor:"King George the 3rd", YearOfDeath:1760}, 5 | { Name:"King George the 3rd", YearOfCoronation:1760, Predecessor:"King George the 2nd", Successor:"King George the 4th", YearOfDeath:1820}, 6 | { Name:"King George the 4th", YearOfCoronation:1820, Predecessor:"King George the 3rd", Successor:"King William the 4th", YearOfDeath:1830}, 7 | { Name:"King William the 4th", YearOfCoronation:1830, Predecessor:"King George the 4th", Successor:"Queen Victoria", YearOfDeath:1837}, 8 | { Name:"Queen Victoria", YearOfCoronation:1837, Predecessor:"King William the 4th", Successor:"King Edward the 7th", YearOfDeath:1901}, 9 | { Name:"King Edward the 7th", YearOfCoronation:1901, Predecessor:"Queen Victoria", Successor:"King George the 5th", YearOfDeath:1910}, 10 | { Name:"King George the 5th", YearOfCoronation:1910, Predecessor:"King Edward the 7th", Successor:"King Edward the 8th", YearOfDeath:1936}, 11 | { Name:"King Edward the 8th", YearOfCoronation:1936, Predecessor:"King George the 5th", Successor:"King George the 6th", YearOfDeath:1972}, 12 | { Name:"King George the 6th", YearOfCoronation:1936, Predecessor:"King Edward the 8th", Successor:"Queen Elizabeth the 2nd",YearOfDeath:1952}, 13 | { Name:"Queen Elizabeth the 2nd", YearOfCoronation:1952, Predecessor:"King George the 6th"} 14 | ] -------------------------------------------------------------------------------- /data/states.js: -------------------------------------------------------------------------------- 1 | //========================================================================================================================================= 2 | //This data quizzes users about the abbreviations, capitals, statehood years and statehood orders for the 50 United States. 3 | //========================================================================================================================================= 4 | 5 | var data = [ 6 | {StateName: "Alabama", Abbreviation: "AL", Capital: "Montgomery", StatehoodYear: 1819, StatehoodOrder: 22 }, 7 | {StateName: "Alaska", Abbreviation: "AK", Capital: "Juneau", StatehoodYear: 1959, StatehoodOrder: 49 }, 8 | {StateName: "Arizona", Abbreviation: "AZ", Capital: "Phoenix", StatehoodYear: 1912, StatehoodOrder: 48 }, 9 | {StateName: "Arkansas", Abbreviation: "AR", Capital: "Little Rock", StatehoodYear: 1836, StatehoodOrder: 25 }, 10 | {StateName: "California", Abbreviation: "CA", Capital: "Sacramento", StatehoodYear: 1850, StatehoodOrder: 31 }, 11 | {StateName: "Colorado", Abbreviation: "CO", Capital: "Denver", StatehoodYear: 1876, StatehoodOrder: 38 }, 12 | {StateName: "Connecticut", Abbreviation: "CT", Capital: "Hartford", StatehoodYear: 1788, StatehoodOrder: 5 }, 13 | {StateName: "Delaware", Abbreviation: "DE", Capital: "Dover", StatehoodYear: 1787, StatehoodOrder: 1 }, 14 | {StateName: "Florida", Abbreviation: "FL", Capital: "Tallahassee", StatehoodYear: 1845, StatehoodOrder: 27 }, 15 | {StateName: "Georgia", Abbreviation: "GA", Capital: "Atlanta", StatehoodYear: 1788, StatehoodOrder: 4 }, 16 | {StateName: "Hawaii", Abbreviation: "HI", Capital: "Honolulu", StatehoodYear: 1959, StatehoodOrder: 50 }, 17 | {StateName: "Idaho", Abbreviation: "ID", Capital: "Boise", StatehoodYear: 1890, StatehoodOrder: 43 }, 18 | {StateName: "Illinois", Abbreviation: "IL", Capital: "Springfield", StatehoodYear: 1818, StatehoodOrder: 21 }, 19 | {StateName: "Indiana", Abbreviation: "IN", Capital: "Indianapolis", StatehoodYear: 1816, StatehoodOrder: 19 }, 20 | {StateName: "Iowa", Abbreviation: "IA", Capital: "Des Moines", StatehoodYear: 1846, StatehoodOrder: 29 }, 21 | {StateName: "Kansas", Abbreviation: "KS", Capital: "Topeka", StatehoodYear: 1861, StatehoodOrder: 34 }, 22 | {StateName: "Kentucky", Abbreviation: "KY", Capital: "Frankfort", StatehoodYear: 1792, StatehoodOrder: 15 }, 23 | {StateName: "Louisiana", Abbreviation: "LA", Capital: "Baton Rouge", StatehoodYear: 1812, StatehoodOrder: 18 }, 24 | {StateName: "Maine", Abbreviation: "ME", Capital: "Augusta", StatehoodYear: 1820, StatehoodOrder: 23 }, 25 | {StateName: "Maryland", Abbreviation: "MD", Capital: "Annapolis", StatehoodYear: 1788, StatehoodOrder: 7 }, 26 | {StateName: "Massachusetts", Abbreviation: "MA", Capital: "Boston", StatehoodYear: 1788, StatehoodOrder: 6 }, 27 | {StateName: "Michigan", Abbreviation: "MI", Capital: "Lansing", StatehoodYear: 1837, StatehoodOrder: 26 }, 28 | {StateName: "Minnesota", Abbreviation: "MN", Capital: "St. Paul", StatehoodYear: 1858, StatehoodOrder: 32 }, 29 | {StateName: "Mississippi", Abbreviation: "MS", Capital: "Jackson", StatehoodYear: 1817, StatehoodOrder: 20 }, 30 | {StateName: "Missouri", Abbreviation: "MO", Capital: "Jefferson City", StatehoodYear: 1821, StatehoodOrder: 24 }, 31 | {StateName: "Montana", Abbreviation: "MT", Capital: "Helena", StatehoodYear: 1889, StatehoodOrder: 41 }, 32 | {StateName: "Nebraska", Abbreviation: "NE", Capital: "Lincoln", StatehoodYear: 1867, StatehoodOrder: 37 }, 33 | {StateName: "Nevada", Abbreviation: "NV", Capital: "Carson City", StatehoodYear: 1864, StatehoodOrder: 36 }, 34 | {StateName: "New Hampshire", Abbreviation: "NH", Capital: "Concord", StatehoodYear: 1788, StatehoodOrder: 9 }, 35 | {StateName: "New Jersey", Abbreviation: "NJ", Capital: "Trenton", StatehoodYear: 1787, StatehoodOrder: 3 }, 36 | {StateName: "New Mexico", Abbreviation: "NM", Capital: "Santa Fe", StatehoodYear: 1912, StatehoodOrder: 47 }, 37 | {StateName: "New York", Abbreviation: "NY", Capital: "Albany", StatehoodYear: 1788, StatehoodOrder: 11 }, 38 | {StateName: "North Carolina", Abbreviation: "NC", Capital: "Raleigh", StatehoodYear: 1789, StatehoodOrder: 12 }, 39 | {StateName: "North Dakota", Abbreviation: "ND", Capital: "Bismarck", StatehoodYear: 1889, StatehoodOrder: 39 }, 40 | {StateName: "Ohio", Abbreviation: "OH", Capital: "Columbus", StatehoodYear: 1803, StatehoodOrder: 17 }, 41 | {StateName: "Oklahoma", Abbreviation: "OK", Capital: "Oklahoma City", StatehoodYear: 1907, StatehoodOrder: 46 }, 42 | {StateName: "Oregon", Abbreviation: "OR", Capital: "Salem", StatehoodYear: 1859, StatehoodOrder: 33 }, 43 | {StateName: "Pennsylvania", Abbreviation: "PA", Capital: "Harrisburg", StatehoodYear: 1787, StatehoodOrder: 2 }, 44 | {StateName: "Rhode Island", Abbreviation: "RI", Capital: "Providence", StatehoodYear: 1790, StatehoodOrder: 13 }, 45 | {StateName: "South Carolina", Abbreviation: "SC", Capital: "Columbia", StatehoodYear: 1788, StatehoodOrder: 8 }, 46 | {StateName: "South Dakota", Abbreviation: "SD", Capital: "Pierre", StatehoodYear: 1889, StatehoodOrder: 40 }, 47 | {StateName: "Tennessee", Abbreviation: "TN", Capital: "Nashville", StatehoodYear: 1796, StatehoodOrder: 16 }, 48 | {StateName: "Texas", Abbreviation: "TX", Capital: "Austin", StatehoodYear: 1845, StatehoodOrder: 28 }, 49 | {StateName: "Utah", Abbreviation: "UT", Capital: "Salt Lake City", StatehoodYear: 1896, StatehoodOrder: 45 }, 50 | {StateName: "Vermont", Abbreviation: "VT", Capital: "Montpelier", StatehoodYear: 1791, StatehoodOrder: 14 }, 51 | {StateName: "Virginia", Abbreviation: "VA", Capital: "Richmond", StatehoodYear: 1788, StatehoodOrder: 10 }, 52 | {StateName: "Washington", Abbreviation: "WA", Capital: "Olympia", StatehoodYear: 1889, StatehoodOrder: 42 }, 53 | {StateName: "West Virginia", Abbreviation: "WV", Capital: "Charleston", StatehoodYear: 1863, StatehoodOrder: 35 }, 54 | {StateName: "Wisconsin", Abbreviation: "WI", Capital: "Madison", StatehoodYear: 1848, StatehoodOrder: 30 }, 55 | {StateName: "Wyoming", Abbreviation: "WY", Capital: "Cheyenne", StatehoodYear: 1890, StatehoodOrder: 44 } 56 | ]; 57 | -------------------------------------------------------------------------------- /data/videogames.js: -------------------------------------------------------------------------------- 1 | //========================================================================================================================================= 2 | //This data quizzes users about the publisher and release year of video games. 3 | //Data for this list came from: https://en.wikipedia.org/wiki/List_of_Nintendo_Entertainment_System_games 4 | //========================================================================================================================================= 5 | 6 | var data = [ 7 | {Title: "10-Yard Fight", ReleaseYear: 1985, Publisher: "Nintendo"}, 8 | {Title: "Adventure Island", ReleaseYear: 1988, Publisher: "Hudson Soft"}, 9 | {Title: "Bad Dudes", ReleaseYear: 1990, Publisher: "Data East"}, 10 | {Title: "Baseball Stars", ReleaseYear: 1989, Publisher: "SNK"}, 11 | {Title: "Castlevania", ReleaseYear: 1987, Publisher: "Konami"}, 12 | {Title: "Double Dragon", ReleaseYear: 1988, Publisher: "Tradewest"}, 13 | {Title: "Elevator Action", ReleaseYear: 1987, Publisher: "Taito"}, 14 | {Title: "Final Fantasy", ReleaseYear: 1990, Publisher: "Nintendo"}, 15 | {Title: "Gyruss", ReleaseYear: 1989, Publisher: "Ultra Games"} 16 | ]; 17 | -------------------------------------------------------------------------------- /instructions/0-intro.md: -------------------------------------------------------------------------------- 1 | # Build An Alexa Fact Skill 2 | 3 | 4 | [![Voice User Interface](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/1-off._TTH_.png)](1-voice-user-interface.md)[![Lambda Function](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/2-off._TTH_.png)](2-lambda-function.md)[![Connect VUI to Code](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/3-off._TTH_.png)](3-connect-vui-to-code.md)[![Testing](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/4-off._TTH_.png)](4-testing.md)[![Customization](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/5-off._TTH_.png)](5-customization.md)[![Publication](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/6-off._TTH_.png)](6-publication.md) 5 | 6 | 7 | ## What You Will Learn 8 | * [AWS Lambda](http://aws.amazon.com/lambda) 9 | * [Alexa Skills Kit (ASK)](https://developer.amazon.com/alexa-skills-kit) 10 | * Voice User Interface (VUI) Design 11 | * Skill Certification 12 | * State Management 13 | * [Speechcons](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speechcon-reference) 14 | 15 | ## What You Will Need 16 | * [Amazon Developer Portal Account](http://developer.amazon.com) 17 | * [Amazon Web Services Account](http://aws.amazon.com/) 18 | * The sample code on [GitHub](https://github.com/alexa/skill-sample-nodejs-quiz-game). 19 | * Simple graphical editing tool 20 | * At least 25 rows of interesting data to quiz your users with. 21 | * Examples: [U.S. States](.data/states.js), [Video Games](.data/videogames.js), [Books](data/books.js), [British Monarchs](data/monarchs.js) 22 | 23 | ## What Your Skill Will Do 24 | We all hold interesting data in our heads. Maybe it's a list of all the action figures we played with as a kid, specific details about the 50 states, or a historical list of the starting quarterbacks for our favorite football team. When we're with friends, sometimes we'll even quiz each other on these nuanced categories of information. It's a fun, interactive way to share our knowledge and learn more about our favorite topics. 25 | 26 | You can now bring that experience to Alexa using our new quiz skill template. You provide the data and the number of properties in that data, and Alexa will dynamically build a quiz game for you. In the quiz, Alexa will ask questions like: 27 | * "What is the capital of Vermont?" 28 | * "How many career home runs did Mickey Mantle hit?" 29 | * "What year was Harry Potter and the Sorcerer's Stone first published?" 30 | 31 | You get to provide the data, as well as the number of properties in that data, and Alexa will dynamically build a quiz game for you. In the quiz, Alexa will ask questions like: 32 | * "Alexa, ask United States Quiz about Ohio." 33 | * "Alexa, ask Hockey Quiz about Wayne Gretzky." 34 | * "Alexa, ask Video Game Quiz about River City Ransom." 35 | 36 | If you’re in the US, we've also included the new [speechcons](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speechcon-reference) feature for Alexa skill development. Speechcons are special words and phrases that Alexa pronounces more expressively. We use them in this quiz game to let the user know whether they gave a correct or incorrect answer during the quiz. 37 | 38 |

39 | 40 |

41 | -------------------------------------------------------------------------------- /instructions/1-voice-user-interface.md: -------------------------------------------------------------------------------- 1 | # Build An Alexa Quiz Game Skill 2 | [![Voice User Interface](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/1-on._TTH_.png)](./1-voice-user-interface.md)[![Lambda Function](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/2-off._TTH_.png)](./2-lambda-function.md)[![Connect VUI to Code](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/3-off._TTH_.png)](./3-connect-vui-to-code.md)[![Testing](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/4-off._TTH_.png)](./4-testing.md)[![Customization](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/5-off._TTH_.png)](./5-customization.md)[![Publication](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/6-off._TTH_.png)](./6-publication.md) 3 | 4 | ## Setting up Your Voice User Interface 5 | 6 | There are two parts to an Alexa skill. The first part is the [Voice User Interface (VUI)](https://developer.amazon.com/alexa-skills-kit/vui). 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 in [the next step](./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 | ![Sign in](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/1-1-developer-portal._TTH_.png) 11 | 12 | 2. **Once you have signed in, click the Alexa button at the top of the screen.** 13 | 14 | ![Alexa button](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/1-2-alexa-button._TTH_.png) 15 | 16 | 3. **On the Alexa page, choose the Get Started button for the Alexa Skills Kit.** 17 | 18 | ![Get Started](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/1-3-alexa-skills-kit._TTH_.png) 19 | 20 | 4. **Select Add A New Skill.** This will get you to the first page of your new Alexa skill. 21 | 22 | ![Amazon Developer Portal](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/1-4-add-a-new-skill._TTH_.png) 23 | 24 | 5. **Fill out the Skill Information screen.** Make sure to review the tips we provide below the screenshot. 25 | 26 | ![Skill Information](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/1-5-skill-information._TTH_.png) 27 | 28 | ### Skill Information Instructions 29 | * **Skill Type** For this skill, we are creating a skill using the Custom Interaction Model. This is the default choice. 30 | 31 | * **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 | * **Name** This is the name of the skill as it will be displayed in the [Alexa app](http://alexa.amazon.com). 34 | 35 | * **Invocation Name** This is the name spoken by your users to start the skill. Use a name like "united states quiz" for this sample skill. Some common issues that developers experience with invocation names are listed in the following table. In addition, please review the [Invocation Name Requirements](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/choosing-the-invocation-name-for-an-alexa-skill) as you consider an invocation name for your 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," "Computer," 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 | * **Audio Player** For this Quiz Game 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 | ![Launch Skill Builder](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/1-7-skill-builder-launch._TTH_.png) 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 | 61 | 11. Click on the **Save Model** button, and then click on the **Build Model** button. 62 | 63 | ![](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/1-12-skill-builder-build-save-model._TTH_.png) 64 | 65 | 66 | 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](https://github.com/alexa/skill-sample-nodejs-trivia/blob/master/instructions/3-connect-vui-to-code.md). 67 | ![](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/1-13-skill-builder-configuration.png) 68 | 69 | If you get an error from your interaction model, check through this list: 70 | 71 | * **Is your custom slot named US_STATE_ABBR?** 72 | * **Did you copy and paste the provided code into the appropriate boxes?** 73 | * **Did you accidentally add any unwanted characters to the Interaction Model or Sample Utterances?** 74 | 75 |

76 | [![Next: Lambda Function](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/buttons/button_next_lambda_function._TTH_.png)](./2-lambda-function.md) 77 | -------------------------------------------------------------------------------- /instructions/2-lambda-function.md: -------------------------------------------------------------------------------- 1 | # Build An Alexa Quiz Game Skill 2 | [![Voice User Interface](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/1-locked._TTH_.png)](./1-voice-user-interface.md)[![Lambda Function](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/2-on._TTH_.png)](./2-lambda-function.md)[![Connect VUI to Code](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/3-off._TTH_.png)](./3-connect-vui-to-code.md)[![Testing](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/4-off._TTH_.png)](./4-testing.md)[![Customization](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/5-off._TTH_.png)](./5-customization.md)[![Publication](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/6-off._TTH_.png)](./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. "QuizGame" 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 (QuizGame if you used our suggestion) and scroll down to the field called "Function code". 49 | 50 | 11. **Copy and paste the [provided code](https://github.com/alexa/skill-sample-nodejs-quiz-game/blob/master/lambda/src/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-quiz-game/blob/master/lambda/src/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 Quiz Game Skill 2 | [![Voice User Interface](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/1-locked._TTH_.png)](./1-voice-user-interface.md)[![Lambda Function](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/2-locked._TTH_.png)](./2-lambda-function.md)[![Connect VUI to Code](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/3-on._TTH_.png)](./3-connect-vui-to-code.md)[![Testing](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/4-off._TTH_.png)](./4-testing.md)[![Customization](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/5-off._TTH_.png)](./5-customization.md)[![Publication](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/6-off._TTH_.png)](./6-publication.md) 3 | 4 | 5 | 6 | ## Connecting Your Voice User Interface To Your Lambda Function 7 | 8 | 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. 9 | 10 | 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. 11 | 12 | 2. **Open the "Configuration" tab on the left side.** 13 | 14 | 15 | 16 | 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). 17 | 18 | 19 | 20 | 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). 21 | 22 | 23 | 24 | 5. **Paste your Lambda's ARN (Amazon Resource Name) into the textbox provided.** It should look similar to the screenshot above. 25 | 26 | 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) 27 | 28 | 7. **Click the "Next" button to continue to page #4 of this guide.** 29 | 30 | 31 | 32 |

33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /instructions/4-testing.md: -------------------------------------------------------------------------------- 1 | # Build An Alexa Quiz Game Skill 2 | [![Voice User Interface](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/1-locked._TTH_.png)](./1-voice-user-interface.md)[![Lambda Function](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/2-locked._TTH_.png)](./2-lambda-function.md)[![Connect VUI to Code](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/3-locked._TTH_.png)](./3-connect-vui-to-code.md)[![Testing](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/4-on._TTH_.png)](./4-testing.md)[![Customization](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/5-off._TTH_.png)](./5-customization.md)[![Publication](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/6-off._TTH_.png)](./6-publication.md) 3 | 4 | 5 | 6 | ## Testing Your Alexa Skill 7 | 8 | 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-code.md). Your skill is now ready to test. 9 | 10 | 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. 11 | 12 | 2. **Open the "Test" tab on the left side.** 13 | 14 | 15 | 16 | 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 17 | 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: 18 | 19 | ```html 20 | 12345 21 | ``` 22 | 23 | ```html 24 | 12345 25 | ``` 26 | 27 | ```html 28 | 12345 29 | ``` 30 | 31 | 32 | 33 | Return to the Voice Simulator as needed to ensure that Alexa says words and phrases as you would expect. 34 | 35 | 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" 36 | 37 | 38 | 39 | ### Service Simulator Tips 40 | * 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. 41 | * Click the **Listen** button in the bottom right corner to hear Alexa read the response. 42 | 43 | * 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. 44 | 45 | 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: 46 | 1. Enter an utterance in the service simulator, and copy the generated Lambda Request for the next step. 47 | 48 | 2. **Open your Lambda function in AWS, open the Actions menu, and select "Configure test events."** 49 | 50 | 51 | 52 | 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. 53 | 54 | 55 | 56 | 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. 57 | 58 | 59 | 60 | 5. **Click the "Create" button.** This will save your test event and bring you back to the main configuration for your lambda function. 61 | 62 | 6. **Click the "Test" button to execute the "startSession" test event.** 63 | 64 | 65 | 66 | This gives you visibility into four things: 67 | 68 | * **Your response, listed in the "Execution Result."** 69 | 70 | 71 | 72 | * **A Summary of the statistics for your request.** This includes things like duration, resources, and memory used. 73 | 74 | 75 | 76 | * **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. 77 | 78 | 79 | 80 | * **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.) 81 | 82 | 6. **Other testing methods to consider:** 83 | 84 | * [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. 85 | * [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). 86 | 87 | 7. **If your sample skill is working properly, you can now customize your skill.** 88 | 89 |

90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /instructions/5-customization.md: -------------------------------------------------------------------------------- 1 | # Build An Alexa Quiz Game Skill 2 | [![Voice User Interface](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/1-locked._TTH_.png)](./1-voice-user-interface.md)[![Lambda Function](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/2-locked._TTH_.png)](./2-lambda-function.md)[![Connect VUI to Code](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/3-locked._TTH_.png)](./3-connect-vui-to-code.md)[![Testing](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/4-locked._TTH_.png)](./4-testing.md)[![Customization](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/5-on._TTH_.png)](./5-customization.md)[![Publication](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/6-off._TTH_.png)](./6-publication.md) 3 | 4 | 5 | 6 | ## Customize the Skill to be Yours 7 | 8 | At this point, you should have a working copy of our United States Quiz Game 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: 9 | 10 | 1. **New data.** You will need to create a new dataset for your skill that *isn't* the 50 United States of America. If you are looking for an idea, check out the [Wikipedia List of Lists of Lists](https://en.wikipedia.org/wiki/List_of_lists_of_lists). 11 | 12 | 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-quiz-game/blob/master/lambda/src/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. 13 | 14 | 2. **Search for the comment "TODO: Replace this data with your own."** This is the data for our skill. You can see that there is a row for each state, represented by five data values: **StateName**, **Abbreviation**, **Capital**, **StatehoodYear**, and **StatehoodOrder**. 15 | 16 | You can provide as few or as many properties for your data as you would like, but we recommend a minimum of three to keep your skill interesting. (Two is the fewest that will make any sense for a quiz.) You should provide at least 25 rows of data for your quiz by replacing the data that we provided with your content. To see other examples of appropriate data structures for a quiz game skill, we have created a few sample data sets for you to look at. 17 | 18 | * [Video Games](https://github.com/alexa/skill-sample-nodejs-quiz-game/blob/master/data/videogames.js) 19 | * [Books](https://github.com/alexa/skill-sample-nodejs-quiz-game/blob/master/data/books.js) 20 | * [U.S. States](https://github.com/alexa/skill-sample-nodejs-quiz-game/blob/master/data/states.js) 21 | * [British Monarchs](https://github.com/alexa/skill-sample-nodejs-quiz-game/blob/master/data/monarchs.js) 22 | 23 | 3. **Consider using built-in slot values.** We recommend considering data from the built-in slot values provided by Amazon. You still need to build your entire dataset, but using values from the built-in slots will make your work in the next few steps easier. We have provided a few examples below, but you can see the [entire list of built-in slot values here](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/slot-type-reference#list-types). 24 | 25 | | Slot Name | Description | Sample Values | Supported Languages | 26 | | --------- | ----------- | ------------- | ------------------- | 27 | | [AMAZON.Actor](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/slot-type-reference#actor) | Names of actors and actresses | Alan Rickman, Amy Adams, Daniel Radcliffe, Emma Watson | US | 28 | | [AMAZON.Airline](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/slot-type-reference#airline) | Name of a variety of airlines | Alaska Airlines, British Airways, Dolphin Air, Maestro | US | 29 | | [AMAZON.Animal](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/slot-type-reference#animal) | Names of many different animals | blister beetle, common frog, moray eel, opossum, spider monkey | US | 30 | | [AMAZON.Comic](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/slot-type-reference#comic) | Titles of comic books | Justice League, Runaways, The Amazing Spiderman, Watchmen, X-Men | US | 31 | | [AMAZON.EUROPE_CITY](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/slot-type-reference#europe_city) | European and world cities | Kempten, Lourdes, Paris, London, Barcelona | US, UK, DE | 32 | | [AMAZON.Sport](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/slot-type-reference#sport) | Names of sports | basketball, college football, football, gymnastics, team handball | US | 33 | | [AMAZON.VideoGame](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/slot-type-reference#videogame) | Titles of video games | Doom Two, Lemmings, The Sims, Worms | US | 34 | 35 | 4. **Once you have your data, here are a couple of tips to remember as we move forward:** 36 | 37 | * **Alexa will read your property names, so each property name should be readable in your questions.** These names are also used in **cards** in the Alexa app, so you should capitalize the first letter of each word. The skill will automatically separate words and add spaces as necessary. 38 | * **The first property in each item is typically used in the questions.** For example, in the U.S state data, most of the questions take a form like "What is the capital of Ohio?", where "capital" came from the property name, and "Ohio" was the first property. (You can customize this for your skill.) Otherwise, the order does not matter at all. 39 | 40 | 5. **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. 41 | 42 | 43 | 44 | 2. **New Interaction Model for your AnswerIntent.** If your data is changing, then the type of data you receive from your users must change as well. 45 | 46 | 1. **Open your skill in the Developer Portal, and go to the Interaction Model tab.** 47 | 48 | 49 | 50 | 2. **Update the slot values for AnswerIntent in your Intent Schema** In our [original intent schema](https://github.com/alexa/skill-sample-nodejs-quiz-game/blob/master//speech-assets/intent-schema.json), we defined a slot for each property in our data, and they had the exact same names as the properties of our data. You should do the same with your intent schema. 51 | 52 | ### Tips for Your Intent Schema 53 | 54 | * **Make sure you have a slot for every property in your data.** 55 | * **Use built-in slot values when possible.** This will generally make your life easier, but if you need a custom slot, [they're easy to make](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interaction-model-reference#custom-slot-syntax). You should have noticed that we created one custom slot for our U.S. states quiz for US state abbreviations. 56 | 57 | 3. **Create any new custom slots you need.** You will need a custom slot for every data value that you can't use a built-in slot value for. While a custom slot doesn't need to be every possible value, it certainly helps to make the list as representative of your expected data as possible. 58 | 59 | 4. **Update your sample utterances.** There is a sample utterance for AnswerIntent for each data type we created. You need to update this list of utterances to represent your data structure instead. 60 | 61 | * **Remember that if you are creating this skill for another language other than English, your sample utterances need to be written in that language, not English. 62 | 63 | 5. **Click the "Save" button when you have completed.** 64 | 65 | 66 | 67 | 3. **New sentences to respond to your users.** There are several sentences and responses that you will want to customize for your skill. 68 | 69 | 1. **Go back to your copy of [index.js]((https://github.com/alexa/skill-sample-nodejs-quiz-game/blob/master/lambda/src/index.js)).** 70 | 71 | 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. Rather than document all of them here, we have left comments in [index.js]((https://github.com/alexa/skill-sample-nodejs-quiz-game/blob/master/lambda/src/index.js)) to help you understand the purpose of each one. 72 | 73 | 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. 74 | 75 | 4. **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. 76 | 77 | * 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. 78 | 79 | 5. **Once you have made the updates listed on this page, you can click "Next" to move on to Publishing and Certification of your skill.** 80 | 81 | 82 | 83 |

84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /instructions/6-publication.md: -------------------------------------------------------------------------------- 1 | # Build An Alexa Quiz Game Skill 2 | [![Voice User Interface](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/1-locked._TTH_.png)](./1-voice-user-interface.md)[![Lambda Function](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/2-locked._TTH_.png)](./2-lambda-function.md)[![Connect VUI to Code](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/3-locked._TTH_.png)](./3-connect-vui-to-code.md)[![Testing](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/4-locked._TTH_.png)](./4-testing.md)[![Customization](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/5-locked._TTH_.png)](./5-customization.md)[![Publication](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/navigation/6-on._TTH_.png)](./6-publication.md) 3 | 4 | 5 | 6 | ## Get Your Skill Certified and Published 7 | 8 | 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. 9 | 10 | 1. **Go to your skill's Publishing Information tab on the [Amazon Developer Portal](https://developer.amazon.com/edw/home.html#/skills/list).** 11 | 12 | 13 | 14 | 2. **Complete the Global Fields data.** These fields apply across all of the languges that your skill supports. 15 | 16 | 17 | 18 | * **For Category, we are building a quiz game, so select "Games, Trivia, and Accessories."** You will also be presented with a **Sub-Category** option. For this skill, choose "Knowledge and Trivia." 19 | 20 | * **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. 21 | 22 | * Since you are using our Quiz Game Sample, make sure to add this sentence to your Testing Instructions: 23 | 24 | ``` 25 | This was built using the Quiz Game Sample. 26 | ``` 27 | 28 | This will let the testing team understand what you're providing them, and should decrease the testing time required. 29 | 30 | * **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. 31 | 32 | 3. **Write your skill descriptions.** 33 | 34 | 35 | 36 | * **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). 37 | 38 | 4. **For your example phrases, come up with the three most exciting ways a user can talk to your skill.** 39 | 40 | 41 | 42 | * **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: 43 | 44 | | Common Failure Points for Example Phrases | 45 | | ----------------------------------------- | 46 | | 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). | 47 | | Example phrases **must** be based on sample utterances specified in your Intent Schema. | 48 | | Your first example phrase **must** include a wake word and your invocation name. | 49 | | Example phrases **must** provide a contextual response. | 50 | 51 | * **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. 52 | 53 | 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. 54 | 55 | 56 | 57 | 6. **Create your skill's icons.** You need two sizes of your icon: 108x108px and 512x512px. 58 | 59 | 60 | 61 | * **Make sure you have the rights to the icons you create.** Please don't violate any trademarks or copyrights. 62 | * **If you don't have software to make icons, try one of these free options:** 63 | 64 | * [GIMP](https://www.gimp.org/) (Windows/Mac/Linux) 65 | * [Paint.NET](http://www.getpaint.net/index.html) (Windows) 66 | * [Inkscape](http://inkscape.org) (Windows/Mac/Linux) 67 | * [Iconion](http://iconion.com/) (Windows/Mac) 68 | 69 | * To make it easier to get started, we've created blank versions of these icons in both sizes for many formats: 70 | 71 | * [PSD](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/icon-templates/psd._TTH_.zip) 72 | * [PNG](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/icon-templates/png._TTH_.zip) 73 | * [GIF](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/icon-templates/gif._TTH_.zip) 74 | * [PDF](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/icon-templates/pdf._TTH_.zip) 75 | * [JPG](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/icon-templates/jpg._TTH_.zip) 76 | * [SVG](https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/general/icon-templates/svg._TTH_.zip) 77 | * [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) 78 | * [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/) 79 | 80 | 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).** 81 | 82 | 83 | 84 | 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. 85 | 86 | 87 | 88 | * **Does this skill allow users to make purchases or spend real money?** For this quiz game, the answer is no. For future skills, make sure you answer this appropriately. 89 | 90 | * **Does this Alexa skill collect users' personal information?** Again, for this quiz game, 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. 91 | * Answering "yes" to this question will also require you to provide a link to your Privacy Policy at the bottom of the page. 92 | 93 | * **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 the United States Quiz, the answer is **no** because it doesn't target a specific age group. 94 | * Factors to consider in determining if this skill is directed to children under 13 include: 95 | * Subject matter of the skill 96 | * Presence of child-oriented activities and incentives 97 | * Type of language used in the skill 98 | * Music and other audio content in the skill 99 | * How the skill is described and marketed 100 | * Intended audience for the skill 101 | 102 | 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. 103 | 104 | 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. 105 | 106 | 10. **Privacy Policy URL.** This is an optional field, and should not be required for this Quiz Game skill sample. You can leave it blank. 107 | 108 | 11. **Terms of Use URL.** This is also optional, and you can leave it blank. 109 | 110 | 12. **Click the Save button at the bottom of the page.** 111 | 112 | 113 | 114 | 13. **Each checkmark should be green, as shown.** 115 | 116 | 117 | 118 | 14. **If you feel that your skill is ready for certification, click the "Submit for Certification" button at the bottom of the page.** 119 | 120 | 121 | 122 | 15. **You're done with your submission!** Here are a few things you might need to know: 123 | 124 | * **Certification can take several days to complete.** Please be patient. It takes time because we want to get it right. 125 | 126 | * **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. 127 | 128 | * **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). 129 | 130 | 131 | -------------------------------------------------------------------------------- /lambda/custom/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const Alexa = require('alexa-sdk'); 3 | 4 | //========================================================================================================================================= 5 | //TODO: The items below this comment need your attention 6 | //========================================================================================================================================= 7 | 8 | //Replace with your app ID (OPTIONAL). You can find this value at the top of your skill's page on http://developer.amazon.com. 9 | //Make sure to enclose your value in quotes, like this: const APP_ID = "amzn1.ask.skill.bb4045e6-b3e8-4133-b650-72923c5980f1"; 10 | const APP_ID = undefined; 11 | 12 | //This function returns a descriptive sentence about your data. Before a user starts a quiz, they can ask about a specific data element, 13 | //like "Ohio." The skill will speak the sentence from this function, pulling the data values from the appropriate record in your data. 14 | function getSpeechDescription(item) 15 | { 16 | let sentence = item.StateName + " is the " + item.StatehoodOrder + "th state, admitted to the Union in " + item.StatehoodYear + ". The capital of " + item.StateName + " is " + item.Capital + ", and the abbreviation for " + item.StateName + " is " + item.Abbreviation + ". I've added " + item.StateName + " to your Alexa app. Which other state or capital would you like to know about?"; 17 | return sentence; 18 | } 19 | 20 | //We have provided two ways to create your quiz questions. The default way is to phrase all of your questions like: "What is X of Y?" 21 | //If this approach doesn't work for your data, take a look at the commented code in this function. You can write a different question 22 | //structure for each property of your data. 23 | function getQuestion(counter, property, item) 24 | { 25 | return "Here is your " + counter + "th question. What is the " + formatCasing(property) + " of " + item.StateName + "?"; 26 | 27 | /* 28 | switch(property) 29 | { 30 | case "City": 31 | return "Here is your " + counter + "th question. In what city do the " + item.League + "'s " + item.Mascot + " play?"; 32 | break; 33 | case "Sport": 34 | return "Here is your " + counter + "th question. What sport do the " + item.City + " " + item.Mascot + " play?"; 35 | break; 36 | case "HeadCoach": 37 | return "Here is your " + counter + "th question. Who is the head coach of the " + item.City + " " + item.Mascot + "?"; 38 | break; 39 | default: 40 | return "Here is your " + counter + "th question. What is the " + formatCasing(property) + " of the " + item.Mascot + "?"; 41 | break; 42 | } 43 | */ 44 | } 45 | 46 | //This is the function that returns an answer to your user during the quiz. Much like the "getQuestion" function above, you can use a 47 | //switch() statement to create different responses for each property in your data. For example, when this quiz has an answer that includes 48 | //a state abbreviation, we add some SSML to make sure that Alexa spells that abbreviation out (instead of trying to pronounce it.) 49 | function getAnswer(property, item) 50 | { 51 | switch(property) 52 | { 53 | case "Abbreviation": 54 | return "The " + formatCasing(property) + " of " + item.StateName + " is " + item[property] + ". " 55 | break; 56 | default: 57 | return "The " + formatCasing(property) + " of " + item.StateName + " is " + item[property] + ". " 58 | break; 59 | } 60 | } 61 | 62 | //This is a list of positive speechcons that this skill will use when a user gets a correct answer. For a full list of supported 63 | //speechcons, go here: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speechcon-reference 64 | const speechConsCorrect = ["Booya", "All righty", "Bam", "Bazinga", "Bingo", "Boom", "Bravo", "Cha Ching", "Cheers", "Dynomite", 65 | "Hip hip hooray", "Hurrah", "Hurray", "Huzzah", "Oh dear. Just kidding. Hurray", "Kaboom", "Kaching", "Oh snap", "Phew", 66 | "Righto", "Way to go", "Well done", "Whee", "Woo hoo", "Yay", "Wowza", "Yowsa"]; 67 | 68 | //This is a list of negative speechcons that this skill will use when a user gets an incorrect answer. For a full list of supported 69 | //speechcons, go here: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speechcon-reference 70 | const speechConsWrong = ["Argh", "Aw man", "Blarg", "Blast", "Boo", "Bummer", "Darn", "D'oh", "Dun dun dun", "Eek", "Honk", "Le sigh", 71 | "Mamma mia", "Oh boy", "Oh dear", "Oof", "Ouch", "Ruh roh", "Shucks", "Uh oh", "Wah wah", "Whoops a daisy", "Yikes"]; 72 | 73 | //This is the welcome message for when a user starts the skill without a specific intent. 74 | const WELCOME_MESSAGE = "Welcome to the United States Quiz Game! You can ask me about any of the fifty states and their capitals, or you can ask me to start a quiz. What would you like to do?"; 75 | 76 | //This is the message a user will hear when they start a quiz. 77 | const START_QUIZ_MESSAGE = "OK. I will ask you 10 questions about the United States."; 78 | 79 | //This is the message a user will hear when they try to cancel or stop the skill, or when they finish a quiz. 80 | const EXIT_SKILL_MESSAGE = "Thank you for playing the United States Quiz Game! Let's play again soon!"; 81 | 82 | //This is the message a user will hear after they ask (and hear) about a specific data element. 83 | const REPROMPT_SPEECH = "Which other state or capital would you like to know about?"; 84 | 85 | //This is the message a user will hear when they ask Alexa for help in your skill. 86 | const HELP_MESSAGE = "I know lots of things about the United States. You can ask me about a state or a capital, and I'll tell you what I know. You can also test your knowledge by asking me to start a quiz. What would you like to do?"; 87 | 88 | 89 | //This is the response a user will receive when they ask about something we weren't expecting. For example, say "pizza" to your 90 | //skill when it starts. This is the response you will receive. 91 | function getBadAnswer(item) { return "I'm sorry. " + item + " is not something I know very much about in this skill. " + HELP_MESSAGE; } 92 | 93 | //This is the message a user will receive after each question of a quiz. It reminds them of their current score. 94 | function getCurrentScore(score, counter) { return "Your current score is " + score + " out of " + counter + ". "; } 95 | 96 | //This is the message a user will receive after they complete a quiz. It tells them their final score. 97 | function getFinalScore(score, counter) { return "Your final score is " + score + " out of " + counter + ". "; } 98 | 99 | //These next four values are for the Alexa cards that are created when a user asks about one of the data elements. 100 | //This only happens outside of a quiz. 101 | 102 | //If you don't want to use cards in your skill, set the USE_CARDS_FLAG to false. If you set it to true, you will need an image for each 103 | //item in your data. 104 | const USE_CARDS_FLAG = true; 105 | 106 | //This is what your card title will be. For our example, we use the name of the state the user requested. 107 | function getCardTitle(item) { return item.StateName;} 108 | 109 | //This is the small version of the card image. We use our data as the naming convention for our images so that we can dynamically 110 | //generate the URL to the image. The small image should be 720x400 in dimension. 111 | function getSmallImage(item) { return "https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/quiz-game/state_flag/720x400/" + item.Abbreviation + "._TTH_.png"; } 112 | 113 | //This is the large version of the card image. It should be 1200x800 pixels in dimension. 114 | function getLargeImage(item) { return "https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/tutorials/quiz-game/state_flag/1200x800/" + item.Abbreviation + "._TTH_.png"; } 115 | 116 | //========================================================================================================================================= 117 | //TODO: Replace this data with your own. 118 | //========================================================================================================================================= 119 | const data = [ 120 | {StateName: "Alabama", Abbreviation: "AL", Capital: "Montgomery", StatehoodYear: 1819, StatehoodOrder: 22 }, 121 | {StateName: "Alaska", Abbreviation: "AK", Capital: "Juneau", StatehoodYear: 1959, StatehoodOrder: 49 }, 122 | {StateName: "Arizona", Abbreviation: "AZ", Capital: "Phoenix", StatehoodYear: 1912, StatehoodOrder: 48 }, 123 | {StateName: "Arkansas", Abbreviation: "AR", Capital: "Little Rock", StatehoodYear: 1836, StatehoodOrder: 25 }, 124 | {StateName: "California", Abbreviation: "CA", Capital: "Sacramento", StatehoodYear: 1850, StatehoodOrder: 31 }, 125 | {StateName: "Colorado", Abbreviation: "CO", Capital: "Denver", StatehoodYear: 1876, StatehoodOrder: 38 }, 126 | {StateName: "Connecticut", Abbreviation: "CT", Capital: "Hartford", StatehoodYear: 1788, StatehoodOrder: 5 }, 127 | {StateName: "Delaware", Abbreviation: "DE", Capital: "Dover", StatehoodYear: 1787, StatehoodOrder: 1 }, 128 | {StateName: "Florida", Abbreviation: "FL", Capital: "Tallahassee", StatehoodYear: 1845, StatehoodOrder: 27 }, 129 | {StateName: "Georgia", Abbreviation: "GA", Capital: "Atlanta", StatehoodYear: 1788, StatehoodOrder: 4 }, 130 | {StateName: "Hawaii", Abbreviation: "HI", Capital: "Honolulu", StatehoodYear: 1959, StatehoodOrder: 50 }, 131 | {StateName: "Idaho", Abbreviation: "ID", Capital: "Boise", StatehoodYear: 1890, StatehoodOrder: 43 }, 132 | {StateName: "Illinois", Abbreviation: "IL", Capital: "Springfield", StatehoodYear: 1818, StatehoodOrder: 21 }, 133 | {StateName: "Indiana", Abbreviation: "IN", Capital: "Indianapolis", StatehoodYear: 1816, StatehoodOrder: 19 }, 134 | {StateName: "Iowa", Abbreviation: "IA", Capital: "Des Moines", StatehoodYear: 1846, StatehoodOrder: 29 }, 135 | {StateName: "Kansas", Abbreviation: "KS", Capital: "Topeka", StatehoodYear: 1861, StatehoodOrder: 34 }, 136 | {StateName: "Kentucky", Abbreviation: "KY", Capital: "Frankfort", StatehoodYear: 1792, StatehoodOrder: 15 }, 137 | {StateName: "Louisiana", Abbreviation: "LA", Capital: "Baton Rouge", StatehoodYear: 1812, StatehoodOrder: 18 }, 138 | {StateName: "Maine", Abbreviation: "ME", Capital: "Augusta", StatehoodYear: 1820, StatehoodOrder: 23 }, 139 | {StateName: "Maryland", Abbreviation: "MD", Capital: "Annapolis", StatehoodYear: 1788, StatehoodOrder: 7 }, 140 | {StateName: "Massachusetts", Abbreviation: "MA", Capital: "Boston", StatehoodYear: 1788, StatehoodOrder: 6 }, 141 | {StateName: "Michigan", Abbreviation: "MI", Capital: "Lansing", StatehoodYear: 1837, StatehoodOrder: 26 }, 142 | {StateName: "Minnesota", Abbreviation: "MN", Capital: "St. Paul", StatehoodYear: 1858, StatehoodOrder: 32 }, 143 | {StateName: "Mississippi", Abbreviation: "MS", Capital: "Jackson", StatehoodYear: 1817, StatehoodOrder: 20 }, 144 | {StateName: "Missouri", Abbreviation: "MO", Capital: "Jefferson City", StatehoodYear: 1821, StatehoodOrder: 24 }, 145 | {StateName: "Montana", Abbreviation: "MT", Capital: "Helena", StatehoodYear: 1889, StatehoodOrder: 41 }, 146 | {StateName: "Nebraska", Abbreviation: "NE", Capital: "Lincoln", StatehoodYear: 1867, StatehoodOrder: 37 }, 147 | {StateName: "Nevada", Abbreviation: "NV", Capital: "Carson City", StatehoodYear: 1864, StatehoodOrder: 36 }, 148 | {StateName: "New Hampshire", Abbreviation: "NH", Capital: "Concord", StatehoodYear: 1788, StatehoodOrder: 9 }, 149 | {StateName: "New Jersey", Abbreviation: "NJ", Capital: "Trenton", StatehoodYear: 1787, StatehoodOrder: 3 }, 150 | {StateName: "New Mexico", Abbreviation: "NM", Capital: "Santa Fe", StatehoodYear: 1912, StatehoodOrder: 47 }, 151 | {StateName: "New York", Abbreviation: "NY", Capital: "Albany", StatehoodYear: 1788, StatehoodOrder: 11 }, 152 | {StateName: "North Carolina", Abbreviation: "NC", Capital: "Raleigh", StatehoodYear: 1789, StatehoodOrder: 12 }, 153 | {StateName: "North Dakota", Abbreviation: "ND", Capital: "Bismarck", StatehoodYear: 1889, StatehoodOrder: 39 }, 154 | {StateName: "Ohio", Abbreviation: "OH", Capital: "Columbus", StatehoodYear: 1803, StatehoodOrder: 17 }, 155 | {StateName: "Oklahoma", Abbreviation: "OK", Capital: "Oklahoma City", StatehoodYear: 1907, StatehoodOrder: 46 }, 156 | {StateName: "Oregon", Abbreviation: "OR", Capital: "Salem", StatehoodYear: 1859, StatehoodOrder: 33 }, 157 | {StateName: "Pennsylvania", Abbreviation: "PA", Capital: "Harrisburg", StatehoodYear: 1787, StatehoodOrder: 2 }, 158 | {StateName: "Rhode Island", Abbreviation: "RI", Capital: "Providence", StatehoodYear: 1790, StatehoodOrder: 13 }, 159 | {StateName: "South Carolina", Abbreviation: "SC", Capital: "Columbia", StatehoodYear: 1788, StatehoodOrder: 8 }, 160 | {StateName: "South Dakota", Abbreviation: "SD", Capital: "Pierre", StatehoodYear: 1889, StatehoodOrder: 40 }, 161 | {StateName: "Tennessee", Abbreviation: "TN", Capital: "Nashville", StatehoodYear: 1796, StatehoodOrder: 16 }, 162 | {StateName: "Texas", Abbreviation: "TX", Capital: "Austin", StatehoodYear: 1845, StatehoodOrder: 28 }, 163 | {StateName: "Utah", Abbreviation: "UT", Capital: "Salt Lake City", StatehoodYear: 1896, StatehoodOrder: 45 }, 164 | {StateName: "Vermont", Abbreviation: "VT", Capital: "Montpelier", StatehoodYear: 1791, StatehoodOrder: 14 }, 165 | {StateName: "Virginia", Abbreviation: "VA", Capital: "Richmond", StatehoodYear: 1788, StatehoodOrder: 10 }, 166 | {StateName: "Washington", Abbreviation: "WA", Capital: "Olympia", StatehoodYear: 1889, StatehoodOrder: 42 }, 167 | {StateName: "West Virginia", Abbreviation: "WV", Capital: "Charleston", StatehoodYear: 1863, StatehoodOrder: 35 }, 168 | {StateName: "Wisconsin", Abbreviation: "WI", Capital: "Madison", StatehoodYear: 1848, StatehoodOrder: 30 }, 169 | {StateName: "Wyoming", Abbreviation: "WY", Capital: "Cheyenne", StatehoodYear: 1890, StatehoodOrder: 44 } 170 | ]; 171 | 172 | //========================================================================================================================================= 173 | //Editing anything below this line might break your skill. 174 | //========================================================================================================================================= 175 | 176 | const counter = 0; 177 | 178 | const states = { 179 | START: "_START", 180 | QUIZ: "_QUIZ" 181 | }; 182 | 183 | const handlers = { 184 | "LaunchRequest": function() { 185 | this.handler.state = states.START; 186 | this.emitWithState("Start"); 187 | }, 188 | "QuizIntent": function() { 189 | this.handler.state = states.QUIZ; 190 | this.emitWithState("Quiz"); 191 | }, 192 | "AnswerIntent": function() { 193 | this.handler.state = states.START; 194 | this.emitWithState("AnswerIntent"); 195 | }, 196 | "AMAZON.HelpIntent": function() { 197 | this.response.speak(HELP_MESSAGE).listen(HELP_MESSAGE); 198 | this.emit(":responseReady"); 199 | }, 200 | "Unhandled": function() { 201 | this.handler.state = states.START; 202 | this.emitWithState("Start"); 203 | } 204 | }; 205 | 206 | const startHandlers = Alexa.CreateStateHandler(states.START,{ 207 | "Start": function() { 208 | this.response.speak(WELCOME_MESSAGE).listen(HELP_MESSAGE); 209 | this.emit(":responseReady"); 210 | }, 211 | "AnswerIntent": function() { 212 | let item = getItem(this.event.request.intent.slots); 213 | 214 | if (item && item[Object.getOwnPropertyNames(data[0])[0]] != undefined) 215 | { 216 | console.log("\nMEMO's TEST\n"); 217 | if (USE_CARDS_FLAG) 218 | { 219 | let imageObj = {smallImageUrl: getSmallImage(item), largeImageUrl: getLargeImage(item)}; 220 | 221 | this.response.speak(getSpeechDescription(item)).listen(REPROMPT_SPEECH); 222 | this.response.cardRenderer(getCardTitle(item), getTextDescription(item), imageObj); } 223 | else 224 | { 225 | this.response.speak(getSpeechDescription(item)).listen(REPROMPT_SPEECH); 226 | } 227 | } 228 | else 229 | { 230 | this.response.speak(getBadAnswer(item)).listen(getBadAnswer(item)); 231 | 232 | } 233 | 234 | this.emit(":responseReady"); 235 | }, 236 | "QuizIntent": function() { 237 | this.handler.state = states.QUIZ; 238 | this.emitWithState("Quiz"); 239 | }, 240 | "AMAZON.PauseIntent": function() { 241 | this.response.speak(EXIT_SKILL_MESSAGE); 242 | this.emit(":responseReady"); 243 | }, 244 | "AMAZON.StopIntent": function() { 245 | this.response.speak(EXIT_SKILL_MESSAGE); 246 | this.emit(":responseReady"); 247 | }, 248 | "AMAZON.CancelIntent": function() { 249 | this.response.speak(EXIT_SKILL_MESSAGE); 250 | this.emit(":responseReady"); 251 | }, 252 | "AMAZON.HelpIntent": function() { 253 | this.response.speak(HELP_MESSAGE).listen(HELP_MESSAGE); 254 | this.emit(":responseReady"); 255 | }, 256 | "Unhandled": function() { 257 | this.emitWithState("Start"); 258 | } 259 | }); 260 | 261 | 262 | const quizHandlers = Alexa.CreateStateHandler(states.QUIZ,{ 263 | "Quiz": function() { 264 | this.attributes["response"] = ""; 265 | this.attributes["counter"] = 0; 266 | this.attributes["quizscore"] = 0; 267 | this.emitWithState("AskQuestion"); 268 | }, 269 | "AskQuestion": function() { 270 | if (this.attributes["counter"] == 0) 271 | { 272 | this.attributes["response"] = START_QUIZ_MESSAGE + " "; 273 | } 274 | 275 | let random = getRandom(0, data.length-1); 276 | let item = data[random]; 277 | 278 | let propertyArray = Object.getOwnPropertyNames(item); 279 | let property = propertyArray[getRandom(1, propertyArray.length-1)]; 280 | 281 | this.attributes["quizitem"] = item; 282 | this.attributes["quizproperty"] = property; 283 | this.attributes["counter"]++; 284 | 285 | let question = getQuestion(this.attributes["counter"], property, item); 286 | let speech = this.attributes["response"] + question; 287 | 288 | this.emit(":ask", speech, question); 289 | }, 290 | "AnswerIntent": function() { 291 | let response = ""; 292 | let speechOutput = ""; 293 | let item = this.attributes["quizitem"]; 294 | let property = this.attributes["quizproperty"] 295 | 296 | let correct = compareSlots(this.event.request.intent.slots, item[property]); 297 | 298 | if (correct) 299 | { 300 | response = getSpeechCon(true); 301 | this.attributes["quizscore"]++; 302 | } 303 | else 304 | { 305 | response = getSpeechCon(false); 306 | } 307 | 308 | response += getAnswer(property, item); 309 | 310 | if (this.attributes["counter"] < 10) 311 | { 312 | response += getCurrentScore(this.attributes["quizscore"], this.attributes["counter"]); 313 | this.attributes["response"] = response; 314 | this.emitWithState("AskQuestion"); 315 | } 316 | else 317 | { 318 | response += getFinalScore(this.attributes["quizscore"], this.attributes["counter"]); 319 | speechOutput = response + " " + EXIT_SKILL_MESSAGE; 320 | 321 | this.response.speak(speechOutput); 322 | this.emit(":responseReady"); 323 | } 324 | }, 325 | "AMAZON.RepeatIntent": function() { 326 | let question = getQuestion(this.attributes["counter"], this.attributes["quizproperty"], this.attributes["quizitem"]); 327 | this.response.speak(question).listen(question); 328 | this.emit(":responseReady"); 329 | }, 330 | "AMAZON.StartOverIntent": function() { 331 | this.emitWithState("Quiz"); 332 | }, 333 | "AMAZON.StopIntent": function() { 334 | this.response.speak(EXIT_SKILL_MESSAGE); 335 | this.emit(":responseReady"); 336 | }, 337 | "AMAZON.PauseIntent": function() { 338 | this.response.speak(EXIT_SKILL_MESSAGE); 339 | this.emit(":responseReady"); 340 | }, 341 | "AMAZON.CancelIntent": function() { 342 | this.response.speak(EXIT_SKILL_MESSAGE); 343 | this.emit(":responseReady"); 344 | }, 345 | "AMAZON.HelpIntent": function() { 346 | this.response.speak(HELP_MESSAGE).listen(HELP_MESSAGE); 347 | this.emit(":responseReady"); 348 | }, 349 | "Unhandled": function() { 350 | this.emitWithState("AnswerIntent"); 351 | } 352 | }); 353 | 354 | function compareSlots(slots, value) 355 | { 356 | for (let slot in slots) 357 | { 358 | if (slots[slot].value != undefined) 359 | { 360 | if (slots[slot].value.toString().toLowerCase() == value.toString().toLowerCase()) 361 | { 362 | return true; 363 | } 364 | } 365 | } 366 | return false; 367 | } 368 | 369 | function getRandom(min, max) 370 | { 371 | return Math.floor(Math.random() * (max-min+1)+min); 372 | } 373 | 374 | function getRandomSymbolSpeech(symbol) 375 | { 376 | return "" + symbol + ""; 377 | } 378 | 379 | function getItem(slots) 380 | { 381 | let propertyArray = Object.getOwnPropertyNames(data[0]); 382 | let value; 383 | 384 | for (let slot in slots) 385 | { 386 | if (slots[slot].value !== undefined) 387 | { 388 | value = slots[slot].value; 389 | for (let property in propertyArray) 390 | { 391 | let item = data.filter(x => x[propertyArray[property]].toString().toLowerCase() === slots[slot].value.toString().toLowerCase()); 392 | if (item.length > 0) 393 | { 394 | return item[0]; 395 | } 396 | } 397 | } 398 | } 399 | return value; 400 | } 401 | 402 | function getSpeechCon(type) 403 | { 404 | let speechCon = ""; 405 | if (type) return "" + speechConsCorrect[getRandom(0, speechConsCorrect.length-1)] + "! "; 406 | else return "" + speechConsWrong[getRandom(0, speechConsWrong.length-1)] + " "; 407 | } 408 | 409 | function formatCasing(key) 410 | { 411 | key = key.split(/(?=[A-Z])/).join(" "); 412 | return key; 413 | } 414 | 415 | function getTextDescription(item) 416 | { 417 | let text = ""; 418 | 419 | for (let key in item) 420 | { 421 | text += formatCasing(key) + ": " + item[key] + "\n"; 422 | } 423 | return text; 424 | } 425 | 426 | exports.handler = (event, context) => { 427 | const alexa = Alexa.handler(event, context); 428 | alexa.appId = APP_ID; 429 | alexa.registerHandlers(handlers, startHandlers, quizHandlers); 430 | alexa.execute(); 431 | }; 432 | -------------------------------------------------------------------------------- /lambda/custom/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "StatesQuiz", 3 | "version": "1.0.0", 4 | "description": "A quiz about states and their capitals.", 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.0", 18 | "voice-insights-sdk": "^1.2.2" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /models/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "interactionModel": { 3 | "languageModel": { 4 | "invocationName": "quiz game", 5 | "intents": [ 6 | { 7 | "name": "AMAZON.CancelIntent", 8 | "samples": [] 9 | }, 10 | { 11 | "name": "AMAZON.HelpIntent", 12 | "samples": [] 13 | }, 14 | { 15 | "name": "AMAZON.PauseIntent", 16 | "samples": [] 17 | }, 18 | { 19 | "name": "AMAZON.StartOverIntent", 20 | "samples": [] 21 | }, 22 | { 23 | "name": "AMAZON.StopIntent", 24 | "samples": [] 25 | }, 26 | { 27 | "name": "AnswerIntent", 28 | "samples": [ 29 | "{StateName}", 30 | "{Capital}", 31 | "{StatehoodYear}", 32 | "{StatehoodOrder}", 33 | "{Abbreviation}", 34 | "tell me about {StateName}", 35 | "tell me about {Capital}", 36 | "tell me about {StatehoodYear}", 37 | "tell me about {StatehoodOrder}", 38 | "tell me about {Abbreviation}", 39 | "what do you know about {StateName}", 40 | "what do you know about {Capital}", 41 | "what do you know about {StatehoodYear}", 42 | "what do you know about {StatehoodOrder}", 43 | "what do you know about {Abbreviation}", 44 | "{StateName} information", 45 | "{Capital} information", 46 | "{StatehoodYear} information", 47 | "{StatehoodOrder} information", 48 | "{Abbreviation} information" 49 | ], 50 | "slots": [ 51 | { 52 | "name": "StateName", 53 | "type": "AMAZON.US_STATE", 54 | "samples": [] 55 | }, 56 | { 57 | "name": "Capital", 58 | "type": "AMAZON.US_CITY", 59 | "samples": [] 60 | }, 61 | { 62 | "name": "StatehoodYear", 63 | "type": "AMAZON.FOUR_DIGIT_NUMBER", 64 | "samples": [] 65 | }, 66 | { 67 | "name": "Abbreviation", 68 | "type": "US_STATE_ABBR", 69 | "samples": [] 70 | }, 71 | { 72 | "name": "StatehoodOrder", 73 | "type": "AMAZON.NUMBER", 74 | "samples": [] 75 | } 76 | ] 77 | }, 78 | { 79 | "name": "QuizIntent", 80 | "samples": [ 81 | "start a quiz", 82 | "start a quiz game", 83 | "and start a quiz", 84 | "and quiz me", 85 | "for a quiz", 86 | "a quiz" 87 | ], 88 | "slots": [] 89 | } 90 | ], 91 | "types": [ 92 | { 93 | "name": "US_STATE_ABBR", 94 | "values": [ 95 | { 96 | "name": { 97 | "value": "AK" 98 | } 99 | }, 100 | { 101 | "name": { 102 | "value": "AL" 103 | } 104 | }, 105 | { 106 | "name": { 107 | "value": "AZ" 108 | } 109 | }, 110 | { 111 | "name": { 112 | "value": "AR" 113 | } 114 | }, 115 | { 116 | "name": { 117 | "value": "CA" 118 | } 119 | }, 120 | { 121 | "name": { 122 | "value": "CO" 123 | } 124 | }, 125 | { 126 | "name": { 127 | "value": "CT" 128 | } 129 | }, 130 | { 131 | "name": { 132 | "value": "DE" 133 | } 134 | }, 135 | { 136 | "name": { 137 | "value": "FL" 138 | } 139 | }, 140 | { 141 | "name": { 142 | "value": "GA" 143 | } 144 | }, 145 | { 146 | "name": { 147 | "value": "HI" 148 | } 149 | }, 150 | { 151 | "name": { 152 | "value": "ID" 153 | } 154 | }, 155 | { 156 | "name": { 157 | "value": "IL" 158 | } 159 | }, 160 | { 161 | "name": { 162 | "value": "IN" 163 | } 164 | }, 165 | { 166 | "name": { 167 | "value": "IA" 168 | } 169 | }, 170 | { 171 | "name": { 172 | "value": "KS" 173 | } 174 | }, 175 | { 176 | "name": { 177 | "value": "KY" 178 | } 179 | }, 180 | { 181 | "name": { 182 | "value": "LA" 183 | } 184 | }, 185 | { 186 | "name": { 187 | "value": "ME" 188 | } 189 | }, 190 | { 191 | "name": { 192 | "value": "MD" 193 | } 194 | }, 195 | { 196 | "name": { 197 | "value": "MA" 198 | } 199 | }, 200 | { 201 | "name": { 202 | "value": "MI" 203 | } 204 | }, 205 | { 206 | "name": { 207 | "value": "MN" 208 | } 209 | }, 210 | { 211 | "name": { 212 | "value": "MS" 213 | } 214 | }, 215 | { 216 | "name": { 217 | "value": "MO" 218 | } 219 | }, 220 | { 221 | "name": { 222 | "value": "MT" 223 | } 224 | }, 225 | { 226 | "name": { 227 | "value": "NE" 228 | } 229 | }, 230 | { 231 | "name": { 232 | "value": "NV" 233 | } 234 | }, 235 | { 236 | "name": { 237 | "value": "NH" 238 | } 239 | }, 240 | { 241 | "name": { 242 | "value": "NJ" 243 | } 244 | }, 245 | { 246 | "name": { 247 | "value": "NM" 248 | } 249 | }, 250 | { 251 | "name": { 252 | "value": "NY" 253 | } 254 | }, 255 | { 256 | "name": { 257 | "value": "NC" 258 | } 259 | }, 260 | { 261 | "name": { 262 | "value": "ND" 263 | } 264 | }, 265 | { 266 | "name": { 267 | "value": "OH" 268 | } 269 | }, 270 | { 271 | "name": { 272 | "value": "OK" 273 | } 274 | }, 275 | { 276 | "name": { 277 | "value": "OR" 278 | } 279 | }, 280 | { 281 | "name": { 282 | "value": "PA" 283 | } 284 | }, 285 | { 286 | "name": { 287 | "value": "RI" 288 | } 289 | }, 290 | { 291 | "name": { 292 | "value": "SC" 293 | } 294 | }, 295 | { 296 | "name": { 297 | "value": "SD" 298 | } 299 | }, 300 | { 301 | "name": { 302 | "value": "TN" 303 | } 304 | }, 305 | { 306 | "name": { 307 | "value": "TX" 308 | } 309 | }, 310 | { 311 | "name": { 312 | "value": "UT" 313 | } 314 | }, 315 | { 316 | "name": { 317 | "value": "VT" 318 | } 319 | }, 320 | { 321 | "name": { 322 | "value": "VA" 323 | } 324 | }, 325 | { 326 | "name": { 327 | "value": "WA" 328 | } 329 | }, 330 | { 331 | "name": { 332 | "value": "WV" 333 | } 334 | }, 335 | { 336 | "name": { 337 | "value": "WI" 338 | } 339 | }, 340 | { 341 | "name": { 342 | "value": "WY" 343 | } 344 | } 345 | ] 346 | } 347 | ] 348 | } 349 | } 350 | } 351 | -------------------------------------------------------------------------------- /skill.json: -------------------------------------------------------------------------------- 1 | { 2 | "skillManifest": { 3 | "publishingInformation": { 4 | "locales": { 5 | "en-US": { 6 | "summary": "Test your knowledge of the US states and their capitals.", 7 | "examplePhrases": [ 8 | "Alexa, open States Quiz", 9 | "Alexa, play States Quiz" 10 | ], 11 | "keywords": [ 12 | "quiz", 13 | "games", 14 | "geography" 15 | ], 16 | "name": "States Quiz", 17 | "description": "Test your knowledge of the US states and their capitals.\n\nMy Radio provides a high quality sound 24/7 with the best music.\n\nTo start, just say \"Alexa, launch States Quiz\" or \"Alexa, open States Quiz\" to start the game\".\n\nAt anytime, you can stop the game by saying \"Alexa, stop\"", 18 | "smallIconUri": "https://s3-eu-west-1.amazonaws.com/alexa.maxi80.com/assets/alexa-logo-108.png", 19 | "largeIconUri": "https://s3-eu-west-1.amazonaws.com/alexa.maxi80.com/assets/alexa-logo-512.png" 20 | }, 21 | "en-GB": { 22 | "summary": "Test your knowledge of the US states and their capitals..", 23 | "examplePhrases": [ 24 | "Alexa, open States Quiz", 25 | "Alexa, play States Quiz" 26 | ], 27 | "keywords": [ 28 | "quiz", 29 | "games", 30 | "geography" 31 | ], 32 | "name": "States Quiz", 33 | "description": "Test your knowledge of the US states and their capitals.\n\nMy Radio provides a high quality sound 24/7 with the best music.\n\nTo start, just say \"Alexa, launch States Quiz\" or \"Alexa, open States Quiz\" to start the game\".\n\nAt anytime, you can stop the game by saying \"Alexa, stop\"", 34 | "smallIconUri": "https://s3-eu-west-1.amazonaws.com/alexa.maxi80.com/assets/alexa-logo-108.png", 35 | "largeIconUri": "https://s3-eu-west-1.amazonaws.com/alexa.maxi80.com/assets/alexa-logo-512.png" 36 | } 37 | }, 38 | "isAvailableWorldwide": true, 39 | "testingInstructions": "Include your testing instruction (if any) here", 40 | "category": "KNOWLEDGE_AND_TRIVIA", 41 | "distributionCountries": [] 42 | }, 43 | "apis": { 44 | "custom": { 45 | "endpoint": { 46 | "sourceDir": "lambda/src" 47 | } 48 | } 49 | }, 50 | "manifestVersion": "1.0", 51 | "permissions": [], 52 | "privacyAndCompliance": { 53 | "allowsPurchases": false, 54 | "isExportCompliant": true, 55 | "containsAds": false, 56 | "isChildDirected": false, 57 | "usesPersonalInfo": false 58 | } 59 | } 60 | } 61 | --------------------------------------------------------------------------------