i:0#.w|Ali.Mazaheri

Azure, Open Source and ...

Building a simple Azure Function using Visual Studio Code and Bot framework Direct Line for a custom Alexa skill

Here at MTC we are seeing growing interest in leveraging intelligent chatbots build on top of Microsoft Bot framework and using it’s out of box channels like Skype, Teams, Facebook Messenger, etc. to make these bots available to a larger customer base!

While we do have built-in support for Cortana a common ask is to connect the very same chat bot implementation running on Azure to home devices such as Alexa or Google home. Answer? Direct Line!

In part one (This post) I am going to build a very simple Azure Function using Visual Studio Code on Mac using .net core and Direct Line library to connect to an existing bot (Powered by our QnA Maker engine) to be used in part 2 for building a custom Alexa skill.

  • Step 1
    From Visual Studio Code under Azure Functions tab select “Create Project” call it Alexafunc, add required references to your csproj as bellow:
  • Step 2
    Next create a new function and implement the plumbing for Direct Line integration (I used the sample code here as a base), save and run it locally to validate:

  • Step 3
    From Visual Studio Code publish your Azure Function to your desired subscription and let the magic happens:
  • Step 4
    In no time your Azure Function should be up and running and connected to your QnA instance via Azure!

In the next post we will be using this to power our custom Alexa skill to connect the device to the same QnA instance.

Happy coding!