{"id":15619187,"url":"https://github.com/xavidop/alexa-dotnet-lambda-helloworld","last_synced_at":"2026-05-13T07:03:15.233Z","repository":{"id":44757491,"uuid":"249074817","full_name":"xavidop/alexa-dotnet-lambda-helloworld","owner":"xavidop","description":"Alexa AWS Lambda Helloworld Example in DotNetCore","archived":false,"fork":false,"pushed_at":"2022-01-26T15:16:44.000Z","size":515,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T15:32:27.802Z","etag":null,"topics":["alexa","alexa-skill","aws","aws-lambda","dotnet","dotnetcore","skill-sample"],"latest_commit_sha":null,"homepage":null,"language":"C#","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/xavidop.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"xavidop","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-03-21T22:52:15.000Z","updated_at":"2020-09-11T11:23:23.000Z","dependencies_parsed_at":"2022-09-03T03:22:00.012Z","dependency_job_id":null,"html_url":"https://github.com/xavidop/alexa-dotnet-lambda-helloworld","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xavidop/alexa-dotnet-lambda-helloworld","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xavidop%2Falexa-dotnet-lambda-helloworld","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xavidop%2Falexa-dotnet-lambda-helloworld/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xavidop%2Falexa-dotnet-lambda-helloworld/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xavidop%2Falexa-dotnet-lambda-helloworld/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xavidop","download_url":"https://codeload.github.com/xavidop/alexa-dotnet-lambda-helloworld/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xavidop%2Falexa-dotnet-lambda-helloworld/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32971672,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T06:31:55.726Z","status":"ssl_error","status_checked_at":"2026-05-13T06:31:51.336Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","aws","aws-lambda","dotnet","dotnetcore","skill-sample"],"created_at":"2024-10-03T08:03:23.947Z","updated_at":"2026-05-13T07:03:15.214Z","avatar_url":"https://github.com/xavidop.png","language":"C#","funding_links":["https://github.com/sponsors/xavidop"],"categories":[],"sub_categories":[],"readme":"﻿# Alexa Skill with .NET Core\n\nAlexa skills can be developed using Alexa Lambda functions or a REST API endpoint. \nLambda function is Amazon's implementation of serverless functions available in AWS. \nAmazon recommends using Lambda functions despite they are not easy to debug. \nWhile you can log to a CloudWatch log, you can't hit a breakpoint and step into the code. \n \nThis makes live debugging of Alexa requests a very hard task.\nThis post explains a simple but useful solution: it is to wrap code in a .NET Standard class library and stand up a REST API project for debugging and development and a Lambda function project for AWS deployment. \nThis article shows how to create an environment to debug a locally-hosted Web API that uses the same logic that is used by a Lambda function and everything written in C#.\n\n## Structuring the Solution\n \nThis approach requires a minimum of two projects in the solution:\n1. Lambda function project (.NET Core 2.1)\n2. Web API project (.NET Core 2.1)\n\n### Prerequisites\n\nHere you have the technologies used in this project\n1. .NET Core 2.1\n2. Visual Studio Community 2019\n3. Nugget Package Manager\n4. Alexa .NET (Version 1.13.0)\n5. ngrok\n\nThe [AWS Toolkit for Visual Studio](https://aws.amazon.com/visualstudio/) includes Lambda function projects and can be used to create .NET Core Lambda functions. \nAll meaningful logic should be contained in the `BusinessLogic` folder and referenced by both the Lambda function project and the Web API project. \n\nInstall Amazon.Lambda.Tools Global Tools if not already installed.\n```\n    dotnet tool install -g Amazon.Lambda.Tools\n```\n\nIf already installed check if new version is available.\n```\n    dotnet tool update -g Amazon.Lambda.Tools\n```\n\n### Project Files \n\nThese are the main files of the project:\n\n![image](img/structure.png)\n\n* serverless.template - an AWS CloudFormation Serverless Application Model template file for declaring your Serverless functions and other AWS resources\n* aws-lambda-tools-defaults.json - default argument settings for use with Visual Studio and command line deployment tools for AWS\n* Function.cs - class that derives from **Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction**. The code in \nthis file bootstraps the ASP.NET Core hosting framework. The Lambda function is defined in the base class.\n* LocalEntryPoint.cs - for local development this contains the executable Main function which bootstraps the ASP.NET Core hosting framework with Kestrel, as for typical ASP.NET Core applications.\n* Startup.cs - usual ASP.NET Core Startup class used to configure the services ASP.NET Core will use.\n* web.config - used for local development.\n* Controllers\\AlexaController.cs - Alexa API controller that will receive all the requests from the cloud. This controller allow us to debug our skill locally.\n* BsuinessLogic\\AlexaProcessor.cs - The code that will process all the Alexa requests from the Lambda Function in Function.cs and from POST controller in AlexaController.cs\n\nOnce the structure has been explained, it is time to understand how it works the entire project:\n\n![image](img/works.png)\n\n\n### Alexa Request Processor \n\nAlexa.NET is a helper library for working with Alexa skill requests/responses in C#. \nWhether you are using the AWS Lambda service or hosting your own service on your server, this library aims just to make working with the Alexa API more natural for a C# developer using a strongly-typed object model.\n\nYou can find all the documentation in their official [GitHub repository](https://github.com/timheuer/alexa-skills-dotnet)\n\nBelow you have the class that will manage all the Alexa requests using Alexa.NET Nugget package showing up how easy is to develop these kind of voice apps in .NET:\n\n```csharp\n    public class AlexaRequestProcessor\n    {\n        public async Task\u003cSkillResponse\u003e ProcessAsync(SkillRequest input)\n        {\n\n            String currentLocale = input.Request.Locale.Split('-')[0];\n            LocalizationManager.Init(currentLocale);\n            var request = new AlexaRequestPipeline();\n            request.RequestHandlers.Add(new LaunchRequestIntentHandler());\n            request.RequestHandlers.Add(new SessionEndedRequestIntentHandler());\n            request.RequestHandlers.Add(new CancelIntentHandler());\n            request.RequestHandlers.Add(new HelpIntentHandler());\n            request.RequestHandlers.Add(new HelloWorldIntentHandler());\n            request.ErrorHandlers.Add(new ErrorHandler());\n            return await request.Process(input);\n\n        }\n    }\n\n```\n\n\n## Build the Skill with Visual Studio\n\nVisual Studio offers a lot of built-in functionality. If you want to build the whole solution within the IDE you can do it interactively:\n\n![image](img/build.png)\n\n## Run the Skill with Visual Studio\n\nRun the Alexa Skill is as easy as click on the play button in Visual Studio. Using the configuration `alexa_dotnet_lambda_helloworld`:\n\n![image](img/run.png)\n\nAfter executing it, you can send Alexa POST requests to http://localhost:5000/api/alexa.\n\nThis execution will run the web API project. If you want to run the Lambda function you have to run the configuration `Mock Lambda Test Tool`:\n\n![image](img/run-lambda.png)\n\nThis execution will run a browser with the Mock Lambda Test Tool and you can execute there all requests directly towards your Function.cs:\n\n![image](img/lambda-tool.png)\n\n## Debug the Skill with Visual Studio\n\nFollowing the steps before, now you can set up breakpoints wherever you want inside all C# files in order to debug your skill:\n\n![image](img/debug.png)\n\n## Test requests locally\n\nI'm sure you already know the famous tool call [Postman](https://www.postman.com/). REST APIs have become the new standard in providing a public and secure interface for your service. Though REST has become ubiquitous, it's not always easy to test. Postman, makes it easier to test and manage HTTP REST APIs. Postman gives us multiple features to import, test and share APIs, which will help you and your team be more productive in the long run.\n\nAfter run your application you will have an endpoint available at http://localhost:5000/api/alexa. With Postman you can emulate any Alexa Request. \n\nFor example, you can test a `LaunchRequest`:\n\n```json\n  {\n    \"version\": \"1.0\",\n    \"session\": {\n      \"new\": true,\n      \"sessionId\": \"amzn1.echo-api.session.[unique-value-here]\",\n      \"application\": {\n        \"applicationId\": \"amzn1.ask.skill.[unique-value-here]\"\n      },\n      \"user\": {\n        \"userId\": \"amzn1.ask.account.[unique-value-here]\"\n      },\n      \"attributes\": {}\n    },\n    \"context\": {\n      \"AudioPlayer\": {\n        \"playerActivity\": \"IDLE\"\n      },\n      \"System\": {\n        \"application\": {\n          \"applicationId\": \"amzn1.ask.skill.[unique-value-here]\"\n        },\n        \"user\": {\n          \"userId\": \"amzn1.ask.account.[unique-value-here]\"\n        },\n        \"device\": {\n          \"supportedInterfaces\": {\n            \"AudioPlayer\": {}\n          }\n        }\n      }\n    },\n    \"request\": {\n      \"type\": \"LaunchRequest\",\n      \"requestId\": \"amzn1.echo-api.request.[unique-value-here]\",\n      \"timestamp\": \"2020-03-22T17:24:44Z\",\n      \"locale\": \"en-US\"\n    }\n  }\n```\n\nYou can execute unit tests as well\n```\n    cd \"alexa_dotnet_lambda_helloworld/test/alexa_dotnet_lambda_helloworld.Tests\"\n    dotnet test\n```\n\n## Deploy your Alexa Skill\n\nYou can do it directly from Visual Studio or from your CLI:\n\n### Here are some steps to follow from Visual Studio:\n\nTo deploy your Serverless application, right click the project in Solution Explorer and select *Publish to AWS Lambda*.\n\nTo view your deployed application, open the Stack View window by double-clicking the stack name shown beneath the AWS CloudFormation node in the AWS Explorer tree. The Stack View also displays the root URL to your published application.\n\n![image](img/deploy.png)\n\n### Here are some steps to follow to get started from the command line:\n\nOnce you have edited your template and code you can deploy your application using the [Amazon.Lambda.Tools Global Tool](https://github.com/aws/aws-extensions-for-dotnet-cli#aws-lambda-amazonlambdatools) from the command line.\n\nDeploy application\n```\n    cd \"alexa_dotnet_lambda_helloworld/src/alexa_dotnet_lambda_helloworld\"\n    dotnet lambda deploy-serverless\n```\n## Test requests directly from Alexa\n\nngrok is a very cool, lightweight tool that creates a secure tunnel on your local machine along with a public URL you can use for browsing your local site or APIs.\n\nWhen ngrok is running, it listens on the same port that you’re local web server is running on and proxies external requests to your local machine\n\nFrom there, it’s a simple step to get it to listen to your web server. Say you’re running your local web server on port 5000. In terminal, you’d type in: `ngrok http 5000`. This starts ngrok listening on port 5000 and creates the secure tunnel:\n\n![image](img/tunnel.png)\n\nSo now you have to go to [Alexa Developer console](https://developer.amazon.com/alexa/console/ask), go to your skill \u003e endpoints \u003e https, add the https url generated above followed by /api/alexa. Eg: https://fe8ee91c.ngrok.io/api/alexa.\n\nSelect the My development endpoint is a sub-domain.... option from the dropdown and click save endpoint at the top of the page.\n\nGo to Test tab in the Alexa Developer Console and launch your skill.\n\nThe Alexa Developer Console will send a HTTPS request to the ngrok endpoint (https://fe8ee91c.ngrok.io/api/alexa) which will route it to your skill running on Web API server at http://localhost:5000/api/alexa.\n\n## Conclusion \n\nThis example can be useful for all those developers who do not want to write their code in Java, NodeJS or Pyhton. \nThese are the official languages supported by Alexa.\nWe have to take into account that Alexa.NET nugget package is not an Official Alexa Skill Kit (ASK). \nThis implies that you can find bugs or functionality that is not available despite it is in constantly changing.\nI recommend you to access its official [GitHub repository](https://github.com/timheuer/alexa-skills-dotnet) to check the status of the project, bugs, updates, etc.\nAs you have seen in this example, the community of Alexa developers gives you the possibility to create skills in different ways. \nI hope this example project is useful to you.\n\nThat's all folks!\n\nHappy coding!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxavidop%2Falexa-dotnet-lambda-helloworld","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxavidop%2Falexa-dotnet-lambda-helloworld","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxavidop%2Falexa-dotnet-lambda-helloworld/lists"}