Skip to content

A Chat Bot based on Microsoft Chat Bot Framework and actively used in our website to answer queries about what we do and how we can help

Notifications You must be signed in to change notification settings

DaltonDayKandola/DDKBot-Recipe

Repository files navigation

DDKBot-Recipe

The DDKBot is DDK's chat bot, currently used in the Contact Me page on our web site and is based on Microsoft's Bot Framework, Azure Infrastructure and Azure cognitive Services, LUIS and QnA Maker.

We make use of the Bot Framework v4 NLP with Dispatch bot sample.

This bot has been created using Bot Framework, it shows how to create a bot that relies on multiple LUIS.ai and QnAMaker.ai models for natural language processing (NLP).

The structure of the Git repository is as follows:

Code/Application: Application Code

Path File Description
.github/workflows Main.yml This is a Github workflow file that automates deployment.
It checks out the code from git, build and runs the .net app from the code and deploys to the Azure Web App (created with the infrastructure scripts).
Code/Application/ This folder contains all the code and configuration files for the DDK Bot.
Code/Application/ AdapterWithErrorHandler.cs Error Handler for the bot.
Code/Application/ appsettings.json Application config settings referenced in the code. We don't make use of the settings here as we use environmental variables on the relevant Azure service or the Azure Key Vault for more sensitive information. In the VSCode, environment variables can be simulated in the .vscode/launch.json file.
Code/Application/ BotDispatch-knowledge-1.dispatch Dispatch configuration file generated by the dispatch command line tool and used in the generation of the Dispatch LUIS model, BotDispatch-knowledge-1 and supporting config files that reside in the data folder. Serious faff involved in getting the correct app id and key for the endpoints!
Code/Application/ BotServices.cs Sets up the services used by the bot; QnA Maker, LUIS and the Key Vault(to get access to the secrets for connectivity).
Code/Application/ ConversationData.cs Used to maintain the state of data during a conversation.
Code/Application/ DDKBot.csproj C# Project file
Code/Application/ getmysecret.cs Returns the specified secret from the Azure Key Vault
Code/Application/ IBotServices.cs A Bot Services Interface. The BotServices class implements this interface and provides an implementation of its members.
Code/Application/ Program.cs ASP.NET Core web application is actually a console project which starts executing from the entry point public static void Main() in Program class where we can create a host for the web application. dotnet new webapp creates this file.
Code/Application/ Startup.cs ASP.NET Core application must include a Startup class. It is like Global.asax in the traditional .NET application. As the name suggests, it is executed first when the application starts. This startup file use the Dependency Injection pattern to avoid direct dependencies and dependency chains to the Bot Service, Framework and other classes. dotnet new webapp creates this file.
Code/Application/ UserProfile.cs Defines a state property used to track information about the user as part of the User Dialog
Code/Application/ web.config The web.config is a file that is read by IIS and the ASP.NET Core Module to configure an app hosted with IIS. A a bit of a legacy file.
/Bots DispatchBot.cs The file controls the flow of the conversation, accesses state to help remember where it is in the conversation and what has already been said and dispatches the request to the best matched intent, served by either LUIS or the QNA Maker. The bots makes use of Turns and context, so have a look at How Bots Work for more insight into this.
/Controller BotController.cs A MVC controller file used routing POST requests to the relevant REST service.
/data This folder contains the data to allow the bot to match the users utterance with a best matched intent to then subsequently route to the appropriate intent in LUIS and/or QnA maker or deal with it internally. The data is generated by using the Dispatch Command Line tool
/Dialogs UserProfileDialog.cs A waterfall sequence of steps the bot runs through with the user. In our case we use the waterfall dialog to capture the users contact details.
/wwwroot default.htm The default web page that is served when you run the DDK Bot application. Its merely an information page that lets you know how to connect to the DDK Bot REST service wne running in development and test setup.
/properties LaunchSettings.json How your project should be started in development scenarios. dotnet new webapp creates this file.

Code/Infrastructure: Infrastructure Code

Path File Description

Language and QnA Maker cognitive services

There are 4 LUIS and 1 QnAmaker models that have been trained and published. The QnA maker deals with question people have about the organisation and what we do and sell. The 4 LUIs model deals with greetings and contacts There is 1 LUIS Model that is created by the dispatcher to understand what model to route requests too.

VsCode Extensions

  • NuGet Package Manager
  • C#
  • Code Spell Checker
  • GitHub

Package Dependencies

Useful References

How Bots Work
use multiple LUIS and QnA Models
Dispatch Command Line tool
Waterfall Dialogs

About

A Chat Bot based on Microsoft Chat Bot Framework and actively used in our website to answer queries about what we do and how we can help

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Packages

No packages published