{"id":21833407,"url":"https://github.com/bencodezen/alexa-hello-world-skill","last_synced_at":"2026-05-13T05:39:51.197Z","repository":{"id":83449187,"uuid":"96897029","full_name":"bencodezen/alexa-hello-world-skill","owner":"bencodezen","description":null,"archived":false,"fork":false,"pushed_at":"2017-07-11T14:53:56.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-26T09:28:55.672Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bencodezen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-11T13:36:58.000Z","updated_at":"2024-04-02T17:43:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"22ab9e69-9a37-4018-943a-9ebe79893284","html_url":"https://github.com/bencodezen/alexa-hello-world-skill","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bencodezen%2Falexa-hello-world-skill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bencodezen%2Falexa-hello-world-skill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bencodezen%2Falexa-hello-world-skill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bencodezen%2Falexa-hello-world-skill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bencodezen","download_url":"https://codeload.github.com/bencodezen/alexa-hello-world-skill/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244807620,"owners_count":20513670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-27T19:30:44.792Z","updated_at":"2026-05-13T05:39:51.171Z","avatar_url":"https://github.com/bencodezen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#### Alexa Cookbook\n## Hello World \u003ca id=\"title\"\u003e\u003c/a\u003e\n\u003chr /\u003e\n\n### Intro \u003ca id=\"intro\"\u003e\u003c/a\u003e\n\n\n### This is a simple tutorial to introduce a simple Alexa skill and code.\n\n### Tutorial Steps\n#### Code\n1. Login to AWS and verify the region at the top right is set to the **Ireland** or **N. Virginia** Region region.\n1. Click [Lambda](https://console.aws.amazon.com/lambda/home) and then **Create a Lambda function**  Do not select the default **Blank** blueprint.\n1. Locate and click on the ```alexa-skill-kit-sdk-factskill``` skill template (hint: search for **fact** )\n1. Click in the empty square and choose the trigger *Alexa Skills Kit* and click Next.\n1. Give your function the name *HelloWorld*\n1. Paste in the source code from [src/index.js](./src/index.js) :\n\n```\n        var Alexa = require('alexa-sdk');\n\n        exports.handler = function(event, context, callback) {\n            var alexa = Alexa.handler(event, context);\n\n            // alexa.dynamoDBTableName = 'YourTableName'; // creates new table for userid:session.attributes\n\n            alexa.registerHandlers(handlers);\n            alexa.execute();\n        };\n\n        var handlers = {\n            'LaunchRequest': function () {\n                this.emit('MyIntent');\n            },\n\n            'MyIntent': function () {\n                this.emit(':tell', 'Hello World from Alexa!');\n            }\n        };\n```\n\n1. Just below the code editor, create or re-use an execution role, such as ```lambda_basic_execution```\n1. Click Next and create the function.\n1. Make note of the Lambda ARN, shown near the top right, such as\n *  ``` arn:aws:lambda:us-east-1:333304287777:function:HelloWorld ```\n\n\n#### Skill\n1. Login to [developer.amazon.com](https://developer.amazon.com) and click Alexa, then Alexa Skills Kit\n1. Create a new Skill called HelloWorld with invocation name ```hello world```.\n1. Paste in the [IntentSchema.json](./speechAssets/IntentSchema.json) :\n\n```\n{\n  \"intents\": [\n    {\n      \"intent\": \"MyIntent\",  \"slots\":[]\n    },\n\n    {\n      \"intent\": \"AMAZON.HelpIntent\"\n    },\n    {\n      \"intent\": \"AMAZON.StopIntent\"\n    },\n    {\n      \"intent\": \"AMAZON.CancelIntent\"\n    }\n  ]\n}\n\n```\n\n1. Paste in the [SampleUtterances.txt](speechAssets/SampleUtterances.txt) :\n\n```\nMyIntent hello\n```\n\n1. Configure the skill endpoint with the AWS Lambda ARN previously created.\n\n#### Test\n* Type or say \"open hello world\" and Alexa should reply with \"hello world from Alexa\"\n* Modify code within the Lambda function editor to have Alexa say something besides Hello World.\n* Test and hear Alexa say the new response.\n\n\n# Labs \u003ca id=\"labs\"\u003e\u003c/a\u003e\n\n## Lab 1 - New Intents\n\nThis lab will have you extend your skill by adding new Intents.  First we will add the intent to the skill definition.\n\n1. Within the [Dev Portal](https://developer.amazon.com/edw/home.html#/skills/list) skill definition, click on the Interaction Model page.\n1. Review the Intent Schema panel, notice the three lines that define the MyIntent schema.\n1. Create a new intent definition, similar to MyIntent called WhatsUpIntent\n1. Within the Sample Utterances box, add a sample for the new intent, such as ```WhatsUpIntent what is up```\n\nNext, we will add a handler to the AWS Lambda function\n\n1. Within the AWS Lambda Console console, review your function code\n1. Within the handlers section, notice the three lines of code that handle the MyIntent event.\n1. Create a new handler function for the WhatsUpIntent (hint: copy \u0026 paste the MyIntent function and change MyIntent to WhatsUpIntent)\n1. Customize the message Alexa will say\n1. Change the emit from a :tell to an :ask. This :ask will keep the session open after Alexa responds.\n1. Test your new skill by opening the skill and saying \"what is up\"\n\nFinally, we will add handlers for default requests such as Help, Stop, and Cancel\n\n1. Within the Lambda code, add handlers for each of the following three events:\n + ```AMAZON.HelpIntent```  ```AMAZON.StopIntent```  ```AMAZON.CancelIntent```\n\n1. Customize the say message in each handler.\n1. Ensure the Help handler action is ```:ask```, while the Cancel and Stop handlers are ```:tell```.\n\n* ```:tell``` will stop the skill after Alexa speaks.  ```:ask``` will cause Alexa to listen again for the next question or command. *\nFeel free to add additional intents and handlers to make your skill unique.\n\n## Lab 2 - Intents with Slots\n\nThis lab will have you add Intents with Slots.\nClick to your skill's Interaction Model, Intent Schema box.\nReview your existing Intent Schema.  The final two characters in this JSON are ```] }```\nClick your cursor just before these two characters.  Type a comma, then press Enter three times.\n\nWe will add a new Intent called ```MyNameIsIntent``` and define a slot with the intent.\n\nCopy and paste in the following new Intent definition:\n\n```\n    {\n      \"intent\": \"MyNameIsIntent\",\n      \"slots\":[\n        {\n          \"name\":\"firstname\",\n          \"type\":\"AMAZON.US_FIRST_NAME\"\n        }\n      ]\n    }\n```\n\nAlso add the following line to your Sample Utterances:  ```MyNameIsIntent my name is {firstname}```\n\n * Create another handler within your AWS Lambda function for MyNameIsIntent that stores the firstname slot value in a local variable:\n * Be sure this line of code exists *inside* the scope of this new Intent Handler.\n\n```var myName = this.event.request.intent.slots.firstname.value;```\n\n * Repeat the name back to the user as part of the MyNameIsIntent handler.\n\n For example, you could have the MyNameIsIntent handler do this :\n\n ``` this.emit(':ask', 'hello, ' + myName, 'try again');  ```\n\n## Lab 3 - Session Attributes\n\nAdd session attributes to your skill to remember things.\n\nBased on your work in the previous lab, your lambda function now has a MyNameIsIntent handler.\n\nAdd the following line of code after you have retrieved the firstname slot value into the myName variable:\n\n```this.attributes['name'] = myName;```\n\nNow, locate the handler for the AMAZON.StopIntent that you defined in Lab 1.\nWithin this handler, replace the code with the following:\n\n```\nvar myName = '';\nif (this.attributes['name']) {\n    myName = this.attributes['name'];\n}\nthis.emit(':tell', 'goodbye, ' + myName, 'try again');\n\n```\n\nTest your skill.  Say \"my name is sam\".  Then say \"stop\".  You should hear a personalized goodbye message.\n\n## Lab 4 - Calling Web Services\nYour skill can make calls to external web services, APIs and REST services.\n\nRead and follow the tutorial in the [external-calls/httpsGet](../../external-calls/httpsGet) folder, to create a starter skill that calls a web service.\n\nOnce you have this skill working:\n + Review the Lambda code.\n + Change the value of the myRequest from 'Florida' to 'California' or any other state.\n + Recalling what you have learned so far, try to add an Intent and Slot so that the user can say which state they want.\n\n\nFor example, you can repeat the steps from Lab 2, to add a new Intent to the Intent Schema, with the following slot:\n\n```\n        {\n          \"name\":\"usstate\",\n          \"type\":\"AMAZON.US_STATE\"\n        }\n```\n\nBe sure to add a corresponding Sample Utterance line, such as:\n\n```NewIntent go to {usstate}```\n\nThen, within your Lambda code, you can get the value of the slot via:\n\n```var myState = this.event.request.intent.slots.usstate.value;```\n\n\n## Lab 5 - SSML Audio\n\nAdd short MP3 audio clips to your output via SSML.\n\nSSML markup tags can be interspersed directly within normal speech output text.\n\nYou can test these within the **Voice Simulator** textbox, just above the Service Simulator textbox on the skill TEST page.\n\n\nExamples:\n```\nThere is a three second pause here \u003cbreak time=\"3s\"/\u003e  then the speech continues.\n\n\u003caudio src='https://s3.amazonaws.com/my-ssml-samples/Flourish.mp3' /\u003e\n\u003caudio src='https://s3.amazonaws.com/my-ssml-samples/cheap_thrills.mp3' /\u003e\n\u003caudio src='https://s3.amazonaws.com/my-ssml-samples/this_is_what_you_came_for.mp3' /\u003e\n```\n\nFor example, you could make Alexa say words and sound effects by preparing an output string like this:\n\n```\nvar say = \" news flash \u003caudio src='https://s3.amazonaws.com/my-ssml-samples/Flourish.mp3' /\u003e , i can create Alexa skills!\";\nthis.emit(':ask',say, 'try again');\n```\n\nRead the [documentation page](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference#audio) on how to prepare and host MP3 audio clips in the required format.\nYou can use a tool such as \"ffmpeg\" or \"vlc\" to down-sample your existing MP3 content.  You can host the MP3s on your own website, or within the AWS S3 service.  Simply create an S3 bucket, upload your files, and set the files to be public, and note file properties which contain the public URL to the file.\n\n\n## Lab 6 - Locale\nYour skill code can create a custom response based on the geographic region of the user, whether they are in US, GB, or DE.\n\nYou can add conditional logic like this:\n\n```\n    var locale = this.event.request.locale;\n\n    var say = \"\";\n\n    if (locale == 'en-GB'){\n            say = 'hiya';\n\n    } else if (locale == 'de-DE') {\n            say = 'guten tag';\n\n    } else {\n            say = 'hello';\n    }\n    this.emit(':ask', say, 'try again');\n\n```\n\nBased on Dean Bryen's post [How to Build a Multi-Language Alexa Skill](https://developer.amazon.com/blogs/post/Tx2XUAQ741IYQI4/how-to-build-a-multi-language-alexa-skill)\n\n\n## Lab 7 - IOT Updates\nControlling IOT Devices\n\nRead and follow the tutorial in the [aws/Amazon-IOT](../../aws/Amazon-IOT) folder.  You will:\n\n + Create a new virtual IOT device\n + Update it via a skill Lambda function\n + Build a web app to simulate a device and show updates happening\n\n\n## Lab 8 - Session in DynamoDB\n\nSkills written with the Node.JS ```alexa-sdk``` can easily store their session attributes in DynamoDB when the skill terminates.\n\nWhen the user re-launches the skill at a later time, the session attributes are reloaded and available to the skill.\n\n#### Pre-requisites:\nComplete the lab exercises 1-3.  You should have a Hello World skill that recalls the user's name upon exit.\nReview the [Lab 3 solution](https://gist.github.com/robm26/aec28e68137e776aea9722a9fa7b4d56) to quickly create this skill.\n\n\n#### Lab Steps:\n\nWithin your Lambda function's ```exports.handler``` block, add one new line:\n\n\n```\nexports.handler = function(event, context, callback) {\n    var alexa = Alexa.handler(event, context);\n\n\n    alexa.dynamoDBTableName = 'YourTableName'; // creates new table for userid:session.attributes\n\n    alexa.registerHandlers(handlers);\n    alexa.execute();\n};\n```\n\nAdd permissions for your Lambda function to access DynamoDB\n\n1. From within AWS Console, click on IAM, then Roles, then ```lambda_basic_execution```:\n1. Click \"Attach Policy\" and select a DynamoDB policy such as **AmazonDynamoDBFullAccess**\n1. Test your skill by executing a unit test from the AWS Lambda console.\n1. You may see an error such as ```\"errorMessage\": \"Requested resource not found\"```.  This is okay.\n1. Wait 60 seconds, then navigate to [AWS DynamoDB](https://console.aws.amazon.com/dynamodb/home) and click on Tables.\n1. You should see a table called ```YourTableName```.\n1. Return to the Lambda console, and test your function again.  It should now succeed.\n1. Return to DynamoDB, and click on Tables, then ```YourTableName```\n1. Click on ```Items``` and you should now see a record that has \"amzn1.ask.account\" in the ```userId``` column\n1. Click on this record to review the data stored for this userId.  You should see a mapAttr object that stores the state of your session.attributes.\n\n\nNote:\n * The session.attribute state is persisted in Dynamo only when your skill ends.\n * The previous session.attributes is loaded again when the user starts the skill again.\n * The first 25GB of data stored in DynamoDB is always free.\n\n#### Lab Demo\nTest the full lifecycle of your skill to verify your name is remembered.\n\n1. Launch your skill or begin testing in the Skill Test page.\n1. Say \"my name is sam\"\n1. Say \"stop\"\n + Your session has now ended and the \"name\" attribute should be stored in the DynamoDB table.  This is equivalent of an Echo user allowing the session to end and waiting for some time.\n1. Begin testing the skill again.  Say \"help\"\n + You should hear \"here is the help for you, sam\"\n\n\n## Lab 9 (optional)\nAccount Linking allows your users to enable your skill, and then enter their credentials to your existing website or directory.\nThis is how Uber and Domino's Pizza links an Alexa user to a user within their service.  The skill can gain access to user attributes, and the skill can make authenticated calls into the service using an OAuth token that is automatically kept for the user with their enabled skill.\n\nAccount linking is required as a component of a Smart Home skill.\n\n * Review the blog post about Account Linking: [Linking your Skill with LWA in Five Steps](https://developer.amazon.com/blogs/post/Tx3CX1ETRZZ2NPC/Alexa-Account-Linking-5-Steps-to-Seamlessly-Link-Your-Alexa-Skill-with-Login-wit)\n\nSetup Account Linking to \"Login with Amazon\" as in the blog post.  Welcome the user by saying their full name.\n\n## Lab 10\n\nUsing the **alexa-sdk**\n\n1. Search the internet for ```npm alexa sdk```\n1. Click the first link to open the alexa-sdk node module project page\n1. Read and scroll through the documentation and try out the code snippets in your skill.\n1. See if you can implement the Hi-Low guessing game described in the documentation.\n\n\n\n[Back](../../README.md#title) - [Cookbook Home Page](../../README.md#title)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbencodezen%2Falexa-hello-world-skill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbencodezen%2Falexa-hello-world-skill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbencodezen%2Falexa-hello-world-skill/lists"}