{"id":13798903,"url":"https://github.com/stojanovic/alexa-skill-kit","last_synced_at":"2025-07-07T12:05:21.698Z","repository":{"id":57175699,"uuid":"82442212","full_name":"stojanovic/alexa-skill-kit","owner":"stojanovic","description":"Library for effortless Alexa Skill development with AWS Lambda","archived":false,"fork":false,"pushed_at":"2017-02-21T15:50:46.000Z","size":126,"stargazers_count":279,"open_issues_count":0,"forks_count":23,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-06-04T00:17:12.999Z","etag":null,"topics":["alexa","alexa-skill","alexa-skills-kit","amazon","amazon-echo","chatbot"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/alexa-skill-kit","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stojanovic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-19T07:16:52.000Z","updated_at":"2024-11-21T21:59:11.000Z","dependencies_parsed_at":"2022-09-04T09:32:01.561Z","dependency_job_id":null,"html_url":"https://github.com/stojanovic/alexa-skill-kit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stojanovic/alexa-skill-kit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stojanovic%2Falexa-skill-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stojanovic%2Falexa-skill-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stojanovic%2Falexa-skill-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stojanovic%2Falexa-skill-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stojanovic","download_url":"https://codeload.github.com/stojanovic/alexa-skill-kit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stojanovic%2Falexa-skill-kit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260595652,"owners_count":23033788,"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":["alexa","alexa-skill","alexa-skills-kit","amazon","amazon-echo","chatbot"],"created_at":"2024-08-04T00:00:56.312Z","updated_at":"2025-07-07T12:05:21.663Z","avatar_url":"https://github.com/stojanovic.png","language":"JavaScript","funding_links":[],"categories":["Development","SDKs/Tools"],"sub_categories":["Bot Development"],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003cimg width=\"150\" src=\"alexa-skill-kit.png\" alt=\"Alexa Skill Kit\"\u003e\n  \u003cbr\u003e\n\u003c/h1\u003e\n\n# Alexa Skill Kit\n\n[![](https://travis-ci.org/stojanovic/alexa-skill-kit.svg?branch=master)](https://travis-ci.org/stojanovic/alexa-skill-kit)\n[![npm](https://img.shields.io/npm/v/alexa-skill-kit.svg?maxAge=2592000?style=plastic)](https://www.npmjs.com/package/alexa-skill-kit)\n[![npm](https://img.shields.io/npm/l/alexa-skill-kit.svg?maxAge=2592000?style=plastic)](https://github.com/stojanovic/alexa-skill-kit/blob/master/LICENSE)\n\nLibrary for effortless Alexa Skill development with AWS Lambda.\n\n| [🚀 Installation](#installation) | [🤔 How it works](#how-it-works) | [🤖 Usage](#usage) | [📕 API reference](#api-reference) | [🤘 How to contribute](#contribute) | [⚖️ License](#license) |\n| -------------------------------- | ----------------- | ----------------- | ---------------------------------- | ----------------------------------- | ---------------------- |\n\n## Installation\n\nAlexa Skill Kit is available as a Node.js module on NPM. To install it, run the following command in an existing Node.js project:\n\n```shell\nnpm install alexa-skill-kit --save\n```\n\n## How it works\n\n\u003cimg width=\"650\" src=\"flow.png\" alt=\"Alexa Skill Kit flow\"\u003e\n\n\n## Usage\n\nAlexa Skill Kit is a library that simplifies the development of Alexa Skills with Node.js and AWS Lambda. It doesn't require any specific deploy style, it can work with manually created Lambda functions, deployment via [Claudia.js](https://claudiajs.com), etc.\n\nSince I recommend [Claudia.js](https://claudiajs.com) because of it's simplicity all the following examples will use it. You can get it from NPM here: [npmjs.com/package/claudia](https://www.npmjs.com/package/claudia).\n\nAfter installing the Alexa Skill Kit from NPM, require it in your code:\n\n```javascript\nconst alexaSkillKit = require('alexa-skill-kit')\n```\n\nor with `import`* syntax:\n\n```javascript\nimport alexaSkillKit from 'alexa-skill-kit'\n```\n\n_\\* `import` syntax is not supported in Node.js, you need to use additional library like Babel to make it work._\n\nAfter requiring it, you simply need to pass event and context from Lambda function, beside `event` and `function`, you need to pass a handler function as the last param.\n\nFor Example:\n\n```javascript\nconst alexaSkillKit = require('alexa-skill-kit')\n\nexports.handler = function(event, context) {\n  alexaSkillKit(event, context, parsedMessage =\u003e {\n    // Do something\n  })\n}\n```\n\n### How to reply\n\nAlexa Skill Kit simplifies replying to Alexa requests. There's a few things you can do:\n\n| [📝 Replying with a simple text](#replying-with-a-simple-text) | [🛠 Replying with an object](#replying-with-an-object) | [💄 More complex replies](#more-complex-replies) | [⏳ Async replies](#async-replies) |\n| ----- | ----- | ----- | ----- | ----- |\n\nKeep on reading and all of them will be explained bellow.\n\n### Replying with a simple text\n\nIf you want Alexa to reply with a simple text you simply need to return the text in a handler function. Alexa Skill Kit will wrap the text in a valid object.\n\nFor example:\n\n```javascript\nconst alexaSkillKit = require('alexa-skill-kit')\n\nexports.handler = function(event, context) {\n  alexaSkillKit(event, context, parsedMessage =\u003e {\n    return 'Hello'\n  })\n}\n```\n\nAn example above will reply to Alexa with the following object:\n\n```json\n{\n  \"version\": \"1.0\",\n  \"response\": {\n    \"shouldEndSession\": true,\n    \"outputSpeech\": {\n      \"type\": \"PlainText\",\n      \"text\": \"Hello\"\n    }\n  }\n}\n```\n\nAs you can see, session will be closed by default. To keep the session opened or to answer with more complex request you can send an object instead of the text.\n\n### Replying with an object\n\nIf you want to keep the session opened or you want to return something more than a simple output speech you can send an object and Alexa Skill Kit will not modify it.\n\nFor example:\n\n```javascript\nconst alexaSkillKit = require('alexa-skill-kit')\n\nexports.handler = function(event, context) {\n  alexaSkillKit(event, context, parsedMessage =\u003e {\n    return {\n      version: '1.0',\n      response: {\n        shouldEndSession: false,\n        outputSpeech: {\n          type: 'PlainText',\n          text: 'Hello'\n        },\n        card: {\n          type: 'Simple',\n          title: 'Simple Card',\n          content: 'An example for a simple card reply'\n        }\n      }\n    }\n  })\n}\n```\n\n### More complex replies\n\nBuilding objects manually is hard and boring. I recommend using [Alexa Message Builder](https://github.com/stojanovic/alexa-message-builder) module to simplify building more complex replies.\n\n[Alexa Message Builder](https://github.com/stojanovic/alexa-message-builder) is available [on NPM](https://www.npmjs.com/package/alexa-message-builder), and you can add it to your project with following command:\n\n```shell\nnpm install alexa-message-builder --save\n```\n\nAfter that simply require it with Alexa Skill Kit like this:\n\n```javascript\nconst alexaSkillKit = require('alexa-skill-kit')\nconst AlexaMessageBuilder = require('alexa-message-builder')\n\nexports.handler = function(event, context) {\n  alexaSkillKit(event, context, parsedMessage =\u003e {\n    return new AlexaMessageBuilder()\n      .addText('Hello')\n      .addSimpleCard('Simple Card', 'An example for a simple card reply')\n      .keepSession()\n      .get()\n  })\n}\n```\n\nAn example above is the same as the example from [\"Replying with an object\"](#replying-with-an-object) section.\n\n**Why Alexa Message Builder is not the part of Alexa Skill Kit?**\n\nWell, without a real reason, Alexa Message Builder was developed before Alexa Skill Kit, and they are separate modules in case anyone needs just one of them without the other.\n\n### Async replies\n\nAlexa Skill Kit uses promises to handle async replies. To be able to reply asynchronously simply return the promise and resolve it with a text or an object and Alexa Skill Kit will apply the same rules as above.\n\nFor example:\n\n```javascript\nconst alexaSkillKit = require('alexa-skill-kit')\n\nexports.handler = function(event, context) {\n  alexaSkillKit(event, context, parsedMessage =\u003e {\n    return fetchSomethingFromTheServer()\n      .then(result =\u003e doSomethingWithTheResult(result))\n      .then(processedResult =\u003e {\n        return `Here's an info from the server: ${processedResult}`\n      })\n  })\n}\n```\n\nAlexa Skill Kit will answer with the text:\n\n```javascript\n`Here's an info from the server: ${processedResult}`\n```\n\n## API reference\n\n**Alexa Skill Kit** (`function`) receives following attributes:\n\n- Event (`object`, required) — an unmodified object received from Amazon Alexa. If your Lambda function receives an object that is not valid Amazon Alexa request it will not parse it and your handler function will never be called.\n- Context (`object`, required) — a context object received on AWS Lambda, it is recommended not to modify it, but Alexa Skill Kit will use `context.succeed` and `context.fail` functions only, so you can pass a custom object that contains those two functions from and original context object.\n- Handler (`function`, required) — a function that receives parsed event and returns a reply that will be passed to Amazon Alexa.\n\n**Handler function** is a function that receives parsed event and can return string, object or a promise that will return string or object when it is resolved.\n\nIn case you don't want Alexa to reply simply return `null` or don't return at all.\n\n**Parsed object** is an object that contains following properties:\n\n- type (_string_) - type of the request, it can be 'LaunchRequest', 'IntentRequest', 'SessionEndedRequest', or one of the 'AudioPlayer' or 'PlaybackController' requests\n- request (_object_) - full request object from Alexa request\n- intent: (_object_, can be _null_) - intent object from Alexa request, if the request does not contain intent, this property will be `null`\n- session: (_object_, can be _null_) - session object from Alexa request, if session doesn't exists in the request, this property will be `null`\n- sessionAttributes: (_object_) - an object with session attributes from Alexa request, if they does not exist, this property will be an empty object (`{}`)\n- user: (_object_) - user object from Alexa request, Alexa Skill Kit will try to load user from the context, then from the session and finally, it'll set an empty object if user info is not found\n- originalRequest: (_object_) - full Alexa request, as received from AWS Lambda and as described in an [official documentation](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#request-format).\n\n## Contribute\n\n### Folder structure\n\nThe main body of code is in the [lib](lib) directory.\n\nThe tests are in the [spec](spec) directory, and should follow the structure of the corresponding source files. All executable test file names should end with `-spec`, so they will be automatically picked up by `npm test`. Any additional project files, helper classes etc that must not be directly executed by the test runner should not end with `-spec`. You can use the [spec/helpers](spec/helpers) directory to store Jasmine helpers, that will be loaded before any test is executed.\n\n### Running tests\n\nWe use [Jasmine](https://jasmine.github.io/) for unit and integration tests. Unless there is a very compelling reason to use something different, please continue using Jasmine for tests. The existing tests are in the [spec](spec) folder. Here are some useful command shortcuts:\n\nRun all the tests:\n\n```bash\nnpm test\n```\n\nRun only some tests:\n\n```bash\nnpm test -- filter=prefix\n```\n\nGet detailed hierarchical test name reporting:\n\n```bash\nnpm test -- full\n```\n\nWe use [ESLint](http://eslint.org/) for syntax consistency, and the linting rules are included in this repository. Running `npm test` will check the linting rules as well. Please make sure your code has no linting errors before submitting a pull request.\n\n## License\n\nMIT - See [LICENSE](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstojanovic%2Falexa-skill-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstojanovic%2Falexa-skill-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstojanovic%2Falexa-skill-kit/lists"}