Introduction

I’d recently been experimenting with Bots and the Microsoft Bot Framework and integrating it with Microsoft Cognitive Services LUIS (Language Understanding Intelligence Service).

Getting both the Bot Framework and LUIS applications configured and connected to each other involved copying and pasting APP-IDs, jumping between the LUIS.AI and Bot Framework sites, checking fields matches etc.  A bit of a pain.

I done some more reading, watched a few Channel 9 videos and learnt that with Azure, you can create your own Bot Service which handles most of the setup for you.

It’s seamless, shields you from the low-level configuration tasks and almost guides you through the entire process.

In the post, I run through:

  • Creating a new Azure Bot Service
  • Building a LUIS application to interpret and identify human “greetings”
  • Connecting the Azure Bot Service to the LUIS Application
  • Updating the Azure Bot Service to hook into LUIS AI
  • Validating the Bot responds to human greetings and connecting to Skype

Step 1 – Creating a new Azure Bot Service

Naturally, you need an Azure Account to create an Azure Bot Service, if you don’t already have one, you can create one here.

When logged into your Azure Portal, click on the + sign and type in “Bot Service”:

AddBotService

You’ll get prompted to create a Microsoft App ID and password which you can see in the screen shots below, the instructions are self-explanatory:

CreateAppId

CreateAppName

We’re interested in building a Language Understanding Bot that will integrate with LUIS using C#, so select C# for the language and Language Understanding for the Template when you reach this screen.

SelectBotType
As we’ve selected Language Understanding for the Template, the Bot Service needs to connect to LUIS, this can take a while as the Azure Bot Service needs to integrate both services and generate a new LUIS API Key.

Previously, you had to jump between both services copying and pasting keys so this saves you from doing that.

ConnectToLUIS

After the LUIS Application and Bot Service have been created and deployed, you get taken to the source code for your new Bot Service.  You can see this here:

BotSourceCode
The Bot doesn’t do anything exciting at the minute, this brings us into Step 2 – adding some intelligence!

Step 2 – Using LUIS to add intelligence

By this point, the Azure Bot Service and LUIS Application will have been created.  The next thing you need to do is browse to LUIS.AI and add some intelligence. Your newly created LUIS application will have a time-stamp similar to the one that’s highlighted in the screenshot below:

LUISAppsList
You can rename the LUIS app to have a more descriptive name if you wish

RenamingLUIS

Step 3 – Add Intents and Utterances

In an earlier post, I detailed the concepts of Intents and Utterances.  For the purposes of this post, we want our bot to be able to respond to simple greetings.
The Intent is “Greeting” and will contain four Utterances:

  • “How are you?”
  • “Yo”
  • “Hello”
  • “Hi”

You can see these here:

Intents

Train and test

With the Intent and related Utterances in place, the LUIS application can now be trained and tested.  Click Train and Test. This will only take a few moments as we’re working with a simple bot that has a small training dataset.

Test the LUIS application by inputting some text (your Utterance) and hit return.  You can see in the screenshot below that supplying “hi” results in the Top Scoring Intent being identified as “Greeting”.

This is what you want!

TrainingLUIS
Publish the LUIS application by clicking on the Publish App link:

PublishingLUIS

Step 4 – Integrating LUIS intelligence with you Azure Bot Service

To recap, we have completed the following:

  • Azure Bot Service created
  • LUIS Application created (and trained to identify basic “greetings”)
  • Established a connection between the Azure Bot Service and LUIS Application

The final thing you need to do is to update the Bot Service to identify when the Greeting Intent has been identified and sent from your LUIS Application.  You also need to return an appropriate response when this occurs.

So,

  • Browse back to your Bot Service in the Azure Portal and select the the source code file basicluisdialogue.csx
  • Create a new async method to handle the LUIS Intent you just created “Greeting”.
  • Decide on the response you want your Bot to post.  You can see an example of this in the screenshot below.

AddASync

Step 5 – Test your Bot

With everything in place, the Bot can now be tested.  From the Azure Portal, click on the Test button, a chat window will appear. It may take a few moments to spin up but the bot will activate.  Trying keying in some of the phrases you trained your Bot with and watch it respond to you!

WebChatTest

Optional, Testing your Bot in Skype

You can read more about Bot Channels here and I may cover them in a future post but for now, check that you Bot service has the Skype Channel added.  If not, you can select it by clicking on the Channels link, then by clicking on the Skype icon:

ChannelList

Enable the Skype Channel and the screen will refresh and contain the newly added Skype Channel:

ConnectChannels

Try out the Skype Channel (you need to add it as a contact your Skype directory) and watch your new Bot respond to basic greetings in Skype!

SkypeTesting

Summary

This was a quick run through of how to configure an Azure Bot Service and LUIS application then integrate it with Skype.  It’s a simple example and with alternate template types there are plenty of uses cases this technology can be applied to, especially when embedding technologies such as LUIS.

  • Customer service agents
  • Q and A scenarios
  • Social media agents

It’s possible to build Bots “locally” without using Azure Bot Service using a combination of the Bot Framework and NGrok.  That’s a story for another day though.

Have you built a Bot?

Are you using them in a production environment?

JOIN MY EXCLUSIVE EMAIL LIST
Get the latest content and code from the blog posts!
I respect your privacy. No spam. Ever.