#Tutorial – How to build an #Amazon #AlexaSkill using Visual Studio 2017, C# and #Azure (2 on N)


Well, in today’s post we will see how to create an Azure API App, which we will then use as an Alexa Skill backend that we created in the previous post.

Tommy describes in an excellent way how to create a website and prepare him to work with Alexa Skill in this post (link). This project uses the NuGet Package Alexa Skills Kit.
Net for the processing of messages with Amazon Alexa.

I have created a template for Visual Studio 2017 that can be downloaded from here (link) and that allows us to create a project already configured to work with Alexa Skills.

Note: the quick way to import this template is to copy the file [WebApi Alexa Skill.
zip] to the Visual Studio 2017 project directory. Usually in [% \ Documents \ Visual Studio 2017 \ Templates \ ProjectTemplates \ Visual C #]

We create a new project using the imported type.


We compiled the project to refresh the NuGet references, update the NuGet packages and we can start working.


The 2 main elements in the project are

  • Controllers / AlexaController.cs. This is an standard ApiController wchi will handle the Alexa requests. It uses 2 HTTP requests
    • HTTP GET mostly for testing
    • HTTP POST process Alexa requests with the class [AlexaResponseAsync]
  • Alexa / AlexaResponseAsync.cs. All the business logic is here.

So, in the Alexa Response class we will add some basic changes

  • Línea 7, change the message used on the skill activation event
  • Líneas 10 a 22, creates a message including the Intent name and the used slots.

Something similar to this

namespace AlexaSkillBrunoEvents.Alexa
public class AlexaSkillBrunoEvents : SpeechletAsync
public override Task<SpeechletResponse> OnLaunchAsync(LaunchRequest launchRequest, Session session)
return Task.FromResult(CompileResponse("Launch Event for Bruno Events"));
public async override Task<SpeechletResponse> OnIntentAsync(IntentRequest intentRequest, Session session)
var message = new StringBuilder();
message.Append($"Intent called {intentRequest.Intent}.");
if (intentRequest.Intent.Slots.Count > 0)
message.Append($" Slots used. ");
foreach (var intentSlot in intentRequest.Intent.Slots)
message.Append($"{intentSlot.Key} ");
var response = CompileResponse(message.ToString());
return await Task.FromResult(response);
public override Task OnSessionStartedAsync(SessionStartedRequest sessionStartedRequest, Session session)
return Task.FromResult(0);
public override Task OnSessionEndedAsync(SessionEndedRequest sessionEndedRequest, Session session)
return Task.FromResult(0);
public static SpeechletResponse CompileResponse(string output)
var response = new SpeechletResponse
OutputSpeech = new PlainTextOutputSpeech { Text = output },
ShouldEndSession = true
return response;

So far the creation of the web project. In the next post, we will see how to publish this website and connect it with the Alexa Skill.

Happy Coding!

Greetings @ Toronto

El Bruno



    1. You can’t do this in a private server. The Alexa skill needs to contact a public url, so you can use azure or any other public vloud services for this.


      1. Hi Bruno. Thanks for reply. That’s what I meant – publicly visible from internet but not Azure or any other cloud. Just a hosting with a domain and IP address…. so, would your code work on it?

        Liked by 1 person

        1. Hey MK, yes that will work!
          If the AWS Alexa Skill can manage to contact your public IP with the code hosted there, the skill will work.
          Let me know how this works 😀


Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: