Customer Support Chatbot | Part 1 | Setup the Development Environment | Microsoft Bot Framework

At the request of one of the visitors on the site, we are bringing to you the Customer Support Chatbot. This bot will help you track orders, raise complaints, get bills/invoices, and cancel orders.

In this part, we will set up our development environment.

Pre-requisites

  1. Visual Studio
  2. Bot Framework v4 Templates
  3. Bot Emulator

The above requirements links are available on the Downloads page.

Video

Creating a Core Bot project in Visual Studio

Kindly watch the below video or refer to the blog to create a Core Bot project using the templates. Will be continuing from the created core bot project. I have used the Core Bot template with .NET Core 3.1 version.

I will be giving the project name as CustomerSupportBot. You can give any name you like for your requirement.


Editing the Project Structure

Remove the following files and folders which are not required for our requirement –

  • BookingDetails.cs
  • FlightBookingRecognizer.cs
  • BookingDialog.cs
  • CancelAndHelpDialog.cs
  • DateResolverDialog.cs
  • CognitiveModels Folder

Remove the following lines of code from Startup.cs

// Register LUIS recognizer
services.AddSingleton<FlightBookingRecognizer>();
 
// Register the BookingDialog.
services.AddSingleton<BookingDialog>();

Remove all the method content from all methods in MainDialog.cs. Also, remove the imports which are showing errors. Ignore the error for methods where return statements are missing. Below is what the MainDialog class will look like after the above removal.

public class MainDialog : ComponentDialog
    {
        protected readonly ILogger Logger;
 
        // Dependency injection uses this constructor to instantiate MainDialog
        public MainDialog(ILogger<MainDialog> logger)
            : base(nameof(MainDialog))
        {
            Logger = logger;
 
            AddDialog(new TextPrompt(nameof(TextPrompt)));
            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                IntroStepAsync,
                ActStepAsync,
                FinalStepAsync,
            }));
 
            // The initial child Dialog to run.
            InitialDialogId = nameof(WaterfallDialog);
        }
 
        private async Task<DialogTurnResult> IntroStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
             return null;
        }
 
        private async Task<DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
             return null;
        }
 
        private async Task<DialogTurnResult> FinalStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
             // Restart the main dialog with a different message the second time around
            var promptMessage = "What else can I do for you?";
            return await stepContext.ReplaceDialogAsync(InitialDialogId, promptMessage, cancellationToken);
        }
    }

Have a look at the starter template for any use case on GitHub. In the next part, we will create a welcome card for our bot.

Thank you All!!! Hope you find this useful.


One thought on “Customer Support Chatbot | Part 1 | Setup the Development Environment | Microsoft Bot Framework

Add yours

Up ↑

%d bloggers like this: