This is a Microsoft Bot Framework v4.3 bot written in C#.
This bot is designed to demonstrate several scenarios around guiding users to specific links via either QNA, Link Mapping or Search.
You can see a published version of the bot (published from the Deployment branch) here.
The bot makes use of several online services:
- Microsoft Azure Bot Service
- Microsoft Azure QNA Maker (Cognitive Services)
- Microsoft Azure Language Understanding Intelligence Service - LUIS (Cognitive Services)
- Microsoft Azure Table Storage
- Microsoft Dispatch Bot CLI tool
In terms of bot code, this is a good example of the following (all based on v4.3 patterns):
- General v4.3 patterns and practices
- Welcoming the user
- Using Dispatch
- Using QNAMaker
- Using Luis
- Getting data from Table Storage
- Bot services (without .BOT file)
- Dialogs, including
- Root dialogs
- Component dialogs
- Waterfall steps
- Passing data between dialogs
- Dialog State
- Prompts
This bot uses several invented concepts which help control the flow and data required by the bot.
This bot is built around helping users find items on the Microsoft store, but could be applied to any scenario that requires a bot that guides users to an online location either on the internet or internal locations such as SharePoint.
This bot will help users locate and learn about items on the Microsoft store by providing values to categories via natural language.
A category is analogous to a piece of metadata for a search result and are used to determine which links (if any) are shown to the user.
In the Microsoft store scenario, there are several categories:
ProductFamily
: i.e. Surface, Xbox, Office, WindowsProduct
: i.e. Surface Pro 6, Surface Go, Windows 10 professional, Xbox One XMemory
: i.e. 16gbStorage
: i.e. 512gbConnectivity
: i.e. Wifi, LTECPU
: i.e. I3, I5, I7Colour
: i.e. Black, Silver
Mandatory categories exist so that if the user provides a particular value for a particular category, the bot will require values for other categories that are mandatory for the one provided by the user.
For example, if the user asks for a Surface (which is a value for the ProductFamily
category), the bot will also require the user to provide values for the Memory
, Storage
, and Product
categories because they are all mandatory categories for ProductFamily
.
Mandatory categories are maintained in an Azure Storage Table Container called mandatorycategories
.
They are inserted, updated and queried in code via the TableStore
repository.
Link mappings are used to map a set of specific category values to a link.
The link could be any URL addressable resource, such as website, search query or SharePoint Url.
For example, if the user defines these categories:
Product
= "Surface Pro 6"Memory
= "16Gb"Storage
= "512Gb"- Then the link mapping system would provide the following link: https://www.microsoft.com/en-gb/store/d/surface-pro-6/8zcnc665slq5/06rv
Link mappings are maintained using a QNAMaker knowledge base where the metadata tags are used to define category values for a specific link. The link is the answer as stored in the knowledge base.
This bot supports 4 main user flows.
This flow is designed to give the users natural language querying capabilities over pre-existing FAQs.
For this flow, we've used the following websites as a source of content for a QNAMaker knowledge base:
To try it out, ask these questions on the published version of the bot:
- "What is the weight of a Surface Go?"
- "Does Surface Go include a pen?"
- "Can I charge just the base of my Surface Book 2?"
This flow is for when the user asks something that is not answerable by QNAMaker but the user has provided all mandatory categories in the initial question.
To try it out, ask this questions on the published version of the bot:
- "I want a Surface Pro 6 with 8gb Memory"
This flow is where the user asks something that is not answerable by the QNAMaker but has also provided information about a category that has other mandatory categories where the details are not provided in the initial utterance.
The bot will prompt the user to provide details for the mandatory categories.
An example of this using the Microsoft store is that if the user asks for a "Surface with 16Gb memory", the bot identifies the following from the utterance:
ProductFamily
= "Surface"Memory
= "16Gb"
The mandatory categories for ProductFamily
= "Surface" also require that the user provides values for Storage
and Product
categories before executing the search so the bot will ask the user for values to ths categories.
To try it out, ask these questions on the published version of the bot:
- "I want a Surface with 16Gb memory"
- The bot will ask "Which specific product would you like?", answer "Surface Pro 6"
- The bot will ask "How much storage would you like?", answer "512gb"
This flow is where the user asks something that is not answerable by the QNAMaker but there are no link mappings for the categories that the user has either defined in the initial utterance or through mandatory category drill-down.
In this case, the bot prompts the user to try a search using the categories that have been identified.
To try it out ask these questions on the published version of the bot:
- "I want a copy of Windows 10"
In order to run locally, follow these high level steps:
- Create an Azure Bot Service using the
EchoBot
template with C# - Create a Luis model by importing
GuidedSearchBot-a4a3.json
- Create a QNAMaker model for FAQ's by importing
MicrosoftStoreFAQ-KB.tsv
- Create a QNAMaker model by for link mapping importing
LinkMappings-KB.tsv.tsv
- Create a Dispatch model which includes the main Luis model and the FAQ QNAMaker model. Refer to Dispatch Command Line tool.
- Create an Azure Storage Table container called
MandatoryCategories
beneath the Azure Storage Account that was created as part of step 1 - Add all the relevant values from steps 1-6 to
AppSettings.json
orSecrets.json
if you are using open source and want to protect your secrets. - Run and debug the bot as usual