{"id":22036005,"url":"https://github.com/ashokdey/test_alexa","last_synced_at":"2025-05-07T20:05:45.867Z","repository":{"id":123496163,"uuid":"158162931","full_name":"ashokdey/test_alexa","owner":"ashokdey","description":"REST API for making Alexa skills instead of using AWS Lambda","archived":false,"fork":false,"pushed_at":"2018-11-30T09:32:11.000Z","size":134,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-07T20:03:04.534Z","etag":null,"topics":["alexa","alexa-skill","express-js","nodejs","rest-api"],"latest_commit_sha":null,"homepage":"","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/ashokdey.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":"2018-11-19T04:41:35.000Z","updated_at":"2020-04-29T19:51:57.000Z","dependencies_parsed_at":"2023-04-09T22:49:29.181Z","dependency_job_id":null,"html_url":"https://github.com/ashokdey/test_alexa","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/ashokdey%2Ftest_alexa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashokdey%2Ftest_alexa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashokdey%2Ftest_alexa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashokdey%2Ftest_alexa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ashokdey","download_url":"https://codeload.github.com/ashokdey/test_alexa/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252949272,"owners_count":21830151,"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","express-js","nodejs","rest-api"],"created_at":"2024-11-30T10:31:21.835Z","updated_at":"2025-05-07T20:05:45.854Z","avatar_url":"https://github.com/ashokdey.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# REST API implementation for Alexa Skill\n\nThe RESPT API implementation contains both the v1 (`alexa-sdk`) and v2 (`ask-sdk`).\n\n## Migrate from AWS-Lambda to REST\n\nIf you already have a `aws-lambda` code and you want to migrate it to your own express/etc server implementation then simply have a look into the following files:\n\n- `src/handlers/v2handlers.js`\n- `src/routes/alexa-v2-latest.js`\n\nBasically, you have to remove `.lambda()` with `.create()` inside `handlers(containg your aws-lambda code)` and inside the route, you can invoke the `skillBuilderInstance` imported from `/handlers` with the `req.body`. Have a look at the code snippet\n\n### Instance of Alexa skill builder\n\n```javascript\nconst Alexa = require('ask-sdk');\n// import handlers\nconst skillBuilder = Alexa.SkillBuilders.custom();\n\nmodule.exports = skillBuilder\n  .addRequestHandlers(\n    GetNewFactHandler,\n    HelpHandler,\n    ExitHandler,\n    SessionEndedRequestHandler,\n    NameIntentHandler\n  )\n  .addErrorHandlers(ErrorHandler)\n  .create();\n```\n\n### Sample request handler\n\n```javascript\nconst GetNewFactHandler = {\n  canHandle(handlerInput) {\n    const request = handlerInput.requestEnvelope.request;\n    return (\n      request.type === 'LaunchRequest' ||\n      (request.type === 'IntentRequest' \u0026\u0026\n        request.intent.name === 'GetNewFactIntent')\n    );\n  },\n  handle(handlerInput) {\n    const factArr = data;\n    const factIndex = Math.floor(Math.random() * factArr.length);\n    const randomFact = factArr[factIndex];\n    const speechOutput = LAUNCH_MESSAGE;\n\n    return handlerInput.responseBuilder\n      .speak(speechOutput)\n      .withSimpleCard(SKILL_NAME, randomFact)\n      .getResponse();\n  }\n};\n```\n\n### Notes:\n\n- By default, `ask-sdk` ends the session after you send response hence to avoid this add `.withShouldEndSession(false)` in the response chain [here](#Sample-request-handler)\n\n- If you want to use 3rd party services, add `.withApiClient(new Alexa.DefaultApiClient())` in the instance building chain for Alexa skill builder [here](#Instance-of-Alexa-skill-builder)\n\n### Inside the route\n\n```javascript\nconst alexaRoute = require('express').Router();\n// Set-Up Alexa Skill and it's handlers\nconst skillBuilderInstance = require('../handlers/v2/index');\n\nalexaRoute.post('/alexa/v2', (req, res) =\u003e {\n  console.table(req.body);\n  skillBuilderInstance\n    .invoke(req.body)\n    .then(responseBody =\u003e res.json(responseBody))\n    .catch(error =\u003e {\n      console.error(error);\n      return res.status(500).send('Error during the request');\n    });\n});\n\nmodule.exports = alexaRoute;\n```\n\n## Repo Structure\n\n- **src** : contains all the code\n  - **handlers** : contains the event/intent handlers for your Alexa skill\n  - **routes** : contains the routes for the app\n\n**src/server.js** is the entry point for the application\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashokdey%2Ftest_alexa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fashokdey%2Ftest_alexa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashokdey%2Ftest_alexa/lists"}