Please follow the following steps to setup the project
Please install Eslint extension for VS Code. A .eslintrc is already provided in the project repo so just add the following settings to your settings.json file in VS Code.
// These are all my auto-save configs
"editor.formatOnSave": true,
// turn it off for JS and JSX, we will do this via eslint
"[javascript]": {
"editor.formatOnSave": false
},
"[javascriptreact]": {
"editor.formatOnSave": false
},
// tell the ESLint plugin to run on save
"eslint.autoFixOnSave": true,
// Optional BUT IMPORTANT: If you have the prettier extension enabled for other languages like CSS and HTML, turn it off for JS since we are doing it through Eslint already
"prettier.disableLanguages": ["javascript", "javascriptreact"],
Please follow this repo by Wesbos in case of any confusion
npm install
You will need an Amazon Developer Account and AWS Credentials to install ask-cli. Install and initialize ask-cli on your machine using the instructions on the official documentation.
Make sure you run the following command in the same directory as the skill.json file
cd soft-widget-assistant
ask deploy
Easy!
For a developer build, you also need to configure your DynamoDB on AWS console. Follow the following steps:
- Open the IAM console
- Go to Roles tab from the sidebar
- Click on the role name for your app. (Should be ask-lambda-soft-widget-assistant)
- Click on Attach Policies
- Filter for DynamoDB Policies
- For a developer build, we can select AmazonDynamoDBFullAccess policy
- Click on Attach Policy
Next, you need to create a table named sw-orders with primaryKey as userId on the DynamoDB console
All done!
Follow the next steps if you're interested in running unit tests as well.
To get started, you need to install Bespoken Tools, please follow the next steps:
-
Install Bespoken Tools by running
npm install -g bespoken-toolson your command line. -
Create the main testing folder. We recommend to name it
test; it should be under the root of your skill's directory. -
Create a folder named
unitundertest\, this folder will store your unit test script files. -
Add the test configuration file
testing.json. This file should be located under yourtest\unitdirectory. It might look like this:{ "handler": "../../src/index.js", "locale": "de-DE", "trace": true, "jest": { "silent": false } }The most important parameter is the handler where you indicate Bespoken's Skill Tester where the source code of your skill is. These parameters can be overwritten on each test script file under their configuration section.
-
Add your test scripts. We recommend to use next convention when naming your test script files:
- If you have only one test script:
index.test.yml - If you want to create more than one test script:
functionalityName.test.yml.
The yml extension indicates this is a YAML file, which is the syntax we use to create test scripts;
testmeans that is a unit test script file. A test script looks like this:--- configuration: # Here you define your locales and mocks locale: en-US --- # Three dashes start a new YAML document - test: Launch request, no further interaction. # Some metadata about this test sequence - LaunchRequest: # LaunchRequest is not an utterance but a request type and reserved word - response.outputSpeech.ssml: Here's your fact - response.card.type: Simple - response.card.title: Space Facts - response.card.content: "*" # Any text will match
A typical YAML sentence is composed of 2 parts separated by a colon; in the left part we have the intent name we want to test; in the right part we have the expected result. You can also access any element on the JSON response object like the session attributes.
- If you have only one test script:
-
To execute the scripts go to the root of your project and run
bst test. That will find and run all the unit test scripts files.
For more information about skill unit testing please read here.