Azure QnA Bot Knowledge base filter using metadata - botframework

I've created a bot after publishing the Azure QnA service knowledge base. I've added the metadata to each question answer pairs to denote the source of information. Now, I want to change the bot code to limit the knowledge base search using the metadata filter. Basically, Bot would initially prompt users to input source (for eg HR, Finance, Legal) and use that input further to only search through question answers pairs tagged to it.
bot source code that is used ->
https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/javascript_nodejs/48.customQABot-all-features
How can I change this code to return answers linked to specified metadata/user input dynamically?
please note README.md does provide information about how to filter answers by passing metadata but it has used static value ({ key: 'Language', value: 'Javascript' }).
I want to pass user input from CustomQABot.js to rootDialog.js so that it will be used in rootDialog.js to filter answers.
any input would be greatly appreciated. Thanks.
ps - I don't know much about node.js so it's very hard for me to understand the program flow.

Here's some documentation that explains how MSFT Bot Framework bots work.
Essentially, the bot invokes dialogs based on the user's input. Each dialog contains some form of conversation on a specific topic. Once a dialog is complete it exits and the user can ask for a new dialog, or just leave.
For example, a travel booking bot may have multiple dialogs, one for each activity. They might have one for booking airlines, one for cruise lines, and one for long distance buses, plus another for modifying or cancelling tickets.
In the example bot you have, there is just one dialog called rootDialog. You could start by trying to modify this dialog to ask the user what filter they wish to use and use that for the rest of the dialog. The user would be asked this question every time the dialog starts.
I'd highly recommend you read through some of the documentation and play with some of the other samples to understand how bots work first.

Related

How to create dynamic dialogs from REST API in botframework

I wan't to build a bot that gather its answers and questions from a rest API.
Bot: How are you?
User: I'm fine, how are you?
Bot: I'm fine, also.
So the questions from the bot (even the first one) is gathered via REST API from an external service. Also the answer of the user is sent to this service and the Bots answer "I'm fine, also" is the result of a REST request.
I've first implemented it without using dialog feature at all. Works great, but without a dialog it's impossible to finish a dialog.
Looking around for some example I could only find some with WaterfallDialog. WatefallDialogs are build with steps - and I don't know the number of steps.
Is it possible to build such a dialog or isn't botframework not designed for such things?
In bot framework V4, the dialog/conversation flow you pick for conversations is optional, and you don't need to use them (https://learn.microsoft.com/en-us/azure/bot-service/bot-service-design-conversation-flow?view=azure-bot-service-4.0). All you NEED to do is implement bot state (https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-howto-v4-state?view=azure-bot-service-4.0), so you can store either conversation data (or user data - depends on what state you need.)
I implemented conversational flow using a single activity handler and an FSM (https://en.wikipedia.org/wiki/Finite-state_machine) - I use recognizers for common dialogs (help) but for the most part, my transition handler does regex comparisons to extract keywords and then hit the next state. So, if you can graph out your FSM, and list out all your dialog options, you can build a dialog that appears conversational and natural.
I can't share code at this time, but hopefully you don't need it.

How to extend MS Health Bot existing scenarios?

I am evaluating MS Health Bot service and able to create and test custom scenarios. However, I was looking at extending existing in-built scenario like "I have a headache" and customize based on my need. I could see product features say we can extend existing scenarios but I don't see any documentation on how to do it. Anyone aware of how to extend existing scenario?
Thanks
Monu
Additional Information:
Health Bot Service provided three templates in the catalog - Provider Lookup, File a claim, Handoff to a human. There are few others with Coming Soon tag.
Scenarios template catalog
However, I thought, I can use any of the already trained bot scenario to handle medical conditions like "I have a headache" as shown in the diagram below.(which shows up in empty designer page on the right chat widget)
Demo chat for "I have a headache"
So my revised question is "we will be able to extend only scenario that is part of template catalog and our own created scenario". Is that correct understanding?
Thanks in advance
You can customize pre-built scenarios in the Healthcare Bot through the Scenario Designer. In the Healthcare bot service you created, click on Manage Account. If you do not have any scenarios configured, either select a template scenario or create a new blank scenario. Otherwise, click on the name of the scenario to open the designer. From here, you can customize the scenario as needed by either adding more scenario elements from the top pane or modifying elements in the scenario.
At the moment it appears that you are only able to modify the three provided templates. You do not have access to the other scenarios like 'I have a headache' in the healthcare manager. The Healthcare Bot Service is relatively new so that might change in future updates.
I would recommend looking at the topics under Scenario Authoring in the Healthcare Bot Documentation for more details on creating and editing scenarios.
Hope this helps!

getStream - Flat Feed where multiple users can post

we are implementing stream in our application and so far we love the out of the box react components as well as the backend implementation stream ruby - this is our setup currently.
We are close to deploying a first MVP but found that it seems to be not possible to post activities to a flat feed from multiple users by default.
Our use case is that we have a group of people that want to post activities about a certain topic (think facebook groups). Therefore we create a feed for the object (lets say a company) and want each user to be able to post activities there. Our current workaround is to add the author id as additional data and add a custom header to a activity - obviously not the best solution as reactions won't work that way.
Looking around we found that this seems to not work out of the box see this issue and this question.
Is this a feature that is only available to paying customers or how can we activate it?
Thank you in advance!
When using Stream with React users can only post to their own user feed, this is a default permission policy that can be changed by Stream.
I suggest reaching to Stream support by email and ask to change the permission policy.

Microsoft teams add custom text handlers

Is there a way to add custom text handlers in Microsoft Teams? For example when I Type # in chat then I can pick from users. Similarly want to bind a key to another option when I can lookup something from our web service and add it to the chat window. Following documentation describes how to write connectors for Microsoft Teams but doesn't say anything about what I am looking for.
https://msdn.microsoft.com/en-us/microsoft-teams/connectors
mayank, the closest direct thing to what you want is what we call compose extensions. That feature is in preview and is available here. That will let you call a web service and interactively show results from a search in a popup list, not unlike our Giphy integration.
Under the covers, it's a special kind of bot as mark-lafleur-msft described. With a bot, the difference is that the results from the web service don't appear in a popup window.
Last but not least, the simplest way of all, if all you want to do is execute commands from within a channel and return information, is to create a "Custom Bot" (similar to an "Outgoing webhook" in Slack). Details here.
Hope that helps.
What you're describing here is what Bots in Teams are intended for. Once built, you simply reference the bot by #botname and your query: #botname look up something from web service.

How can the performance of LUIS models be improved?

If you have used the Language Understanding Service (LUIS) which is part of Cognitive Services suite from Microsoft, you probably have come to the point where you needed to improve the performance of your models at predicting intents.
LUIS allows you to train models based on sample utterances which you supply either interactively or in batches. In addition, I would like to have the chat logs showing utterances which are wrongly classified by the model so I can use them as a basis for new training data-sets.
I would imagine that such feature would be released in future but in the meantime, does anyone have a work-around for this scenario?
I think a good way to implement this (by hand), would be to route all the messages that were wrongly classified to some kind of storage or log so you could in the future use them to retrain your LUIS model. In fact, you could use LUIS API to make calls dynamically and easily with the data in your log.
So, the flow would be something like this:
1) User send message to bot.
2) Bot logic tries to match message's intent using LUIS model.
3) An intent isn't found or the value associated to the result is really low.
4) Grab that message and store it somewhere (from a simple txt file stored in an Azure Blob Storage), or in in a Database (Table Storage, DocumentDB or SQL Server).
5) Make a simple program that for each line in your log makes you choose an intent and then it calls LUIS Api to retrain.
So, I found the closest thing to what I had in mind when I asked the question.
Right on the "MyApps" page on luis.ai there's the possibility to download the chat logs in which one can see the entire set of interactions between users and the bot. It could be a good starting point for picking out intents which were wrongly classified.
I attached a screenshot to indicate the link
The only caveat is that the log chat format is currently in .csv which isn't so readable. Hopefully LUIS supports json formatted logs soon.

Resources