C# Lambda Functions for Alexa Skills
By Mike Irving - Published: 16/8/2020

Back in 2017 I attended an Alexa Dev Day event in Salford, and whilst on-site I started hacking together two Alexa Skills relating to Grid Reference Data.

Not long after, I launched both Grid Reference Finder (to ask Alexa for GB and Irish Grid References) and Coordinates Finder (similar, but for the International UTM Grid).

At the time, I built the AWS Lambda Functions that underpinned these Skills in Node.js, as this was the main way of getting started with building skills back then, with full documentation from Amazon.

Roll on a few years, and for a while now C# has been available as a coding option in AWS Lambda.

The old Skill code was a bit convoluted too, the Node function made a web request to a web service hosted on Microsoft Azure, where I had C# Code to perform grid reference calculations.. this in turn would call the Google Maps API to turn a requested location into Latitude and Longitude values, then convert them, and send the results back to Amazon.

I have now rewritten the functions in C#, and removed the need to hop out to the additional web service. The code now calls the Google Maps API direct.

Alexa Skills in C# / .NET Core

AWS Lambda now supports .NET Core 3.1, and I brought in my Lat/Lng to Grid Ref conversion code with ease. It had already existed in C# for use in the Android versions of my popular mapping mobile apps, coded using Xamarin, and previously underpinned the Windows Phone apps too. (or still does for the few users that still wish to use it)

I am using NuGet Packages Amazon.Lambda.Core, Amazon.Lambda.Serialization.Json and Amazon.Lambda.Logging.AspNetCore along with some helper classes and constants found over on GitHub.

The functions are easily tested and uploaded to AWS using the AWS Toolkit extension for Visual Studio, which also provides a Mock Lambda Test Tool.

AWS Toolkit for Visual Studio

It is good to have everything in C# Now, and with only one set of code to worry about.

Want to know more about Alexa Skills or Lambda Functions? Please contact me, or reach out on Twitter.


View Blog Entries...
Page: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11