C# Bot as an Enabler—Azure Web App Bot (Quick Start)

This article introduces the Live Assist for Microsoft Dynamics 365Bot as an Enabler Bot C# SDK, running within the Azure Web App Bot Framework.

The examples contained here do not provide a detailed guide for developing bots within the Microsoft Azure framework. We assume that the developer has experience of C# and the Microsoft Azure Framework, and that they are able to use this quick start guide as a starting point to become familar with the Live Assist SDK.

Note: The Microsoft Web App Bot Framework is currently in development. You may need to make some changes in the steps, or the code, for your development effort. We recommend that you develop your application using Microsoft Visual Studio Professional—do not use the App Service Editor provided in the Azure web interface.

This bot receives chats initiated with Microsoft Web App Bot Service. The bot echoes any messages that a vistor sends, sending their original message back to them. When the visitor sends a message containing 'help', the Live Assist Bot SDK is invoked to escalate the call to a Live Assist Skill Group for processing. The bot, by using the Live Assist SDK, proxies messages between the Azure Web Chat service and the Agent using Live Assist.See also:BotBuilder samples repository

Step 1—Creating a C# basic Web App bot

In Azure, create a new C# Web App Bot.

Set the appropriate Storage and Billing requirements for your application. The significant parts of this process are:

Selecting a name which is unique within Azure

Selecting the C# (Basic) Application

This process may take Azure a few minutes to build.

Step 2—Downloading the Project Code from Azure

When the Web App Bot has been created, you can download the Project code: Azure prepares the source code to download—you need to unzip the archive.

Step 3—Loading the code into Visual Studio, and importing the Live Assist Reference

The unzipped archive contains the follow Solution file:Microsoft.Bot.Sample.SimpleEchoBot.sln Open this file in Visual Studio Professional.Note: We used Visual Studio 2017 for this example. Other IDEs may appear differently.

Import the CaféX Live Assist Reference file from NuGet. From the Solution Explorer, right-click References and click Manage Nuget Packages You may see a warning from NuGet saying that packages are missing. Click Restore.

Under Browse, search for Live Assistand install the LiveAssistBotSDK package.

When the NuGet package is installed, you can begin development.

Step 4—Developing your application

Based on the Microsoft SimpleEchoBot sample bot, make the following changes to the EchoDialog.cs file:

Managing Imports: The following packages are required:

using Microsoft.Bot.Builder.ConnectorEx;
using Newtonsoft.Json;
using System.Timers;
using Cafex.LiveAssist.Bot;

The beginning of the if block needs to check if the chat has already been escalated, so the echo doesn't occur

if (chatContext != null)
{
// As chatContext is not null we already have an escalated chat.
// Post the incoming message line to the escalated chat
await sdk.PostLine(activity.Text, chatContext);
}else if (activity.Text == "reset")

Add an extra trigger to handle 'help' in the MessageReceivedAsyc method

Step 6—Testing your bot

When you have published your bot, you can quickly test the new Chat Bot from Microsoft Azure > Test Web Chat tab.Important: You need an Agent logged into LiveAssist for Microsoft Dynamics 365, under the correct skill group, to receive the escalated chat.