Getting Started with Azure Bot Service– Part 3 – Configuration

July 23, 2017

In the previous posts, I gave an introduction to the solution that we are working on and then provisioned an Azure Bot service based on a sample template given my Microsoft. In this post, we will be customizing the Bot application and integrating it with LUIS.

Before you start configuring your bot, you need to train LUIS for your intentions.

LUIS configuration

In this tutorial, I treat LUIS with only one use case. It is – help desk bot can assist with password reset requests. Therefore, I’m going to train LUIS to identify password reset requests.

Go to luis.ai and login with your credentials. Create the following two intents in the LUIS application. (sspr – Self service password reset)

In each of this intents, add as much as utterances.

There will be no entities used in this example. Therefore, leave the entities section empty.

Now you need to train your LUIS application. Click Train & Test, then type as much as wordings in the interactive testing. Finally click Train Application button.

To finish LUIS configuration, go to Publish App section and publish the application.

Bot Configuration

In terms of bot configuration, you have two options for the configuration. You can modify the code in the portal itself or you can configure continuous integration and use your favourite editor. In this post, I’m going to modify the code on the portal itself.

The file that I’m going to modify in this demo is BasicLuisDialog.csx. It’s includes all the interaction with the LUIS service. Add the following code to the file.

// For more information about this template visit http://aka.ms/azurebots-csharp-luis

[Serializable]

public class BasicLuisDialog : LuisDialog<object>

{

public BasicLuisDialog() : base(new LuisService(new LuisModelAttribute(Utils.GetAppSetting("LuisAppId"), Utils.GetAppSetting("LuisAPIKey"))))

{

} [LuisIntent("None")]

public async Task NoneIntent(IDialogContext context, LuisResult result)

{

await context.PostAsync($"You have reached the none intent. You said: {result.Query}"); //

context.Wait(MessageReceived);

}



[LuisIntent("sspr")]

public virtual async Task ssprIntent(IDialogContext context, LuisResult result)

{

PromptDialog.Confirm(

context,

AfterResetAsync,

"Ok, not a problem. I can help you with that. Have you tried resetting your password from the password reset portal? https://passwordreset.microsoftonline.com/",

"Didn’t get that! please answer yes or no",

promptStyle: PromptStyle.None);

} [LuisIntent("greet")]

public async Task greetIntent(IDialogContext context, LuisResult result)

{

await context.PostAsync($"Hi There, how can I help you ?"); //

context.Wait(MessageReceived);

}



public async Task AfterResetAsync(IDialogContext context, IAwaitable<bool> argument)

{

var confirm = await argument;

if (confirm)

{



await context.PostAsync("Ok, then I’ll direct you to the next available person for manual password reset");

// redirect to a service desk person.

}

else

{

await context.PostAsync("Please go to – https://passwordreset.microsoftonline.com/ and try to do the self service password reset.");

}

context.Wait(MessageReceived);

}

}

These code blocks will detect the intensions greet and sspr what we defined in LUIS. Greet will react a single response while the sspr will open a dialog.

Click save and start testing.

Summary

In this post, we talked about how you can customize the bot application in Azure Bot Service. Moreover, how you can configure it to integrate with LUIS.

In the next post, we will talk about how you can hook the bot service to the Skype for Business Channel.