garypretty / botframework Goto Github PK
View Code? Open in Web Editor NEWMicrosoft Bot Framework helpers and additional dialogs
License: MIT License
Microsoft Bot Framework helpers and additional dialogs
License: MIT License
I was hoping originally to get the version that has the youtube video, but I can't seem to find that. So downloaded the more complex version, and I'm not sure where to look in debug. QnA Maker doesn't show you how many times the endpoint has been hit, so I don't know if I'm even connecting. I do know I put in the right ID and Subscription. How do I move forward?
Hello,
QnA Maker service supports active learning in run-time by providing best n matches to the user and allowing the end user to select the right question. How do we support that using QnAMakerDialog nuget package?
Hi Gary,
Could you add the "questions" property in the qna maker call response. It will be very useful for a development I am doing.
Many thanks,
i have a requirement to catch all the unanswered questions. please suggest me an idea to find unanswered questions. i have to store unanswered questions into a database.
Hi, when using the dialog as in the example:
[LuisIntent("")]
public async Task None(IDialogContext context, LuisResult result)
{
var dialog = new CommonResponsesDialog();
dialog.InitialMessage = result.Query;
context.Call(dialog, AfterCommonResponseHandled);
}
public async Task AfterCommonResponseHandled(IDialogContext context, IAwaitable<bool> result)
{
var messageHandled = await result;
if (!messageHandled)
{
await context.PostAsync("Iām not sure what you want");
}
context.Wait(MessageReceived);
}
I get
Error CS1503 Argument 2: cannot convert from 'method group' to 'ResumeAfter'
In: context.Call(dialog, AfterCommonResponseHandled);
Any clues about this?
Thanks
Hi Gary, super helpful code, I'm using it for a LUIS+QNA dialog. I noticed when attempting to use this line:
private async Task AfterQnADialog(IDialogContext context, IAwaitable result)
that it would not accept a type of < bool >. To get it to work I had to use this with < object > and then cast to bool:
private async Task AfterQNADialog(IDialogContext context, IAwaitable<object> result)
{
var messageHandled = await result;
bool b_messageHandled = true;
if (messageHandled is bool)
{
b_messageHandled = (bool)messageHandled;
}
if (!b_messageHandled)
{
string message = $"Sorry, I did not understand. Type 'help' if you need assistance.";
await context.PostAsync(message);
}
context.Wait(MessageReceived);
}
Have you seen that issue?
Thanks,
Rick
When trying to send a message with an attachment, im getting an error exception, how can i handle this?
` if (activity.Type == ActivityTypes.Message)
{
try
{
await Conversation.SendAsync(activity, MakeRoot);
}
catch (Exception ex)
{
}
}`
Exception: The remote server returned an error: (400) Bad Request.
[File of type 'text/plain']
Hi, I have been using QnAMakerDialog for handing some of my botframework questions and I just updated the Nuget package to 3.0.0 and am getting 2 compile errors in QnaDialog.cs. They are:
Error CS0246 The type or namespace name 'QnAMakerResult' could not be found (are you missing a using directive or an assembly reference?)
Error CS0115 'QnADialog.DefaultMatchHandler(IDialogContext, string, QnAMakerResult)': no suitable method found to override
My code behind is this which was working before the upgrade:
`using System;
using System.Threading.Tasks;
using Microsoft.Bot.Builder.Dialogs;
using Newtonsoft.Json.Linq;
using QnAMakerDialog;
namespace LuisBot.Dialogs
{
[Serializable]
[QnAMakerService("c355bee79baa424c8bc4c85f14b31892", "41918fa1-2f6a-4ebd-a9ec-682265481121")]
public class QnADialog : QnAMakerDialog
{
public override async Task NoMatchHandler(IDialogContext context, string originalQueryText)
{
string message = $"Sorry, I did not understand '{originalQueryText}'. Type 'help' if you need assistance.";
context.Done(false);
}
public override async Task DefaultMatchHandler(IDialogContext context, string originalQueryText, QnAMakerResult result)
{
await context.PostAsync($"{result.Answer}");
context.Done(true);
}
}
}`
The errors are occurring on the 2 override lines. Can you spot what the issues are? I looked at your sample project and the lines seem to match.
Thanks,
Rick
In BestMatchDialog.cs, InitialMessage is set to protected instead of public and cannot be set outside of the class. Not sure how this works as per your LUIS example on your blog: http://www.garypretty.co.uk/2016/08/01/give-your-bot-some-manners-with-the-bestmatchdialog/
Hi Gary,
Thank you for your nice projet ! very usefull ;)
Do you have an idea how to get the list of strings ( BestMatch(new string[] { "Hi", "Hi There", "Hello.. ) from multiple resources Files (.resx) (ex FR, US,...) we can imagine having a row :
BestMatchHelloKeyRow : Hi|Hi There|Hello|... in the US.resx file
BestMatchHelloKeyRow : Bonjour|Salut|... in the FR.resx file
If you have an idea ;)
Thanks in advance,
I created a new knowledge base now that QnA Maker is out of preview and in general availability.
It looks like subscription key is obsolete, now you need to use Endpoint Keys. Also, you provision your own azure service instance, so you need to give it a url to that service, not the westus url.
I'm working on updates now, hopefully I get a PR over tonight.
Hi Gary, this is way off topic but in case you know as you have deep knowledge in this area; I am using your combined LUIS+QnA handler technique within the None intent to handle phrases not picked up by the LUIS intent handlers. But every now and then my intent handlers will pick up a user's phrase that shouldn't have gone there and likely has a very low score for an entity. Do you by chance know of a way within an intent to check the score and if the score for an entity found in an intent is below a threshold, let's say < .75, that it could be rerouted to the None handler instead?
Thanks,
Rick
When will this be compatible to the new version of QnAMaker?
According this , it seems it's possible to connect multiple QnA Service. But can't figure it out. Any suggestions?
The version 2.0 api documentation has some really nice features I would like to use such as:
I have a feeling this will not be backwards compatible, but would love to lend a hand if possible.
This is also a partial duplicate of #9
I just updated my QNADialog NuGet package to the more recent one, and now for no reason that I can see I started getting a "No suitable method method found to override" error on the overriding DefaultMatchHandler method, which I didn't have beforehand.
My code:
using System;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.Bot.Builder.CognitiveServices.QnAMaker;
using Microsoft.Bot.Builder.Dialogs;
using QnAMakerDialog;
using QnAMakerDialog.Models;
namespace Wegho_BOT.Dialogs
{
[Serializable]
[QnAMakerService("", "")]
public class QnADialog : QnAMakerDialog<bool>
{
/// <summary>
/// Goes back to the MainLUISDialog with a false boolean value when no answer is found in the QnAMaker knowledge base.
/// </summary>
#pragma warning disable CS1998
public override async Task NoMatchHandler(IDialogContext context, string originalQueryText)
{
context.Done(false);
}
#pragma warning restore CS1998
/// <summary>
/// Sends the user an answer to the user's question, and goes back to the MainLUISDialog with a true boolean value, after the QnAMaker calculates it..
/// </summary>
/// <param name="originalQueryText">The original question asked by the user</param>
/// <param name="result">The answer calculated by the QnAMaker</param>
public override async Task DefaultMatchHandler(IDialogContext context, string originalQueryText, QnAMakerResult result)
{
var answerSeparated = SplitAnswer(result.Answer);
foreach (var item in answerSeparated)
{
await context.PostAsync($"{item}");
}
context.Done(true);
}
/// <summary>
/// Splits an answer into an array of strings, separated by phrases.
/// </summary>
/// <param name="answer">The string to separate</param>
/// <returns>Array of strings of the separated answer</returns>
public string[] SplitAnswer(string answer)
{
string pattern = @"([^\d][.!?][^a-z])";
string pattern2 = @"([\d][.])";
string substitution = @"$1|";
string substitution2 = @"|$1";
Regex regex = new Regex(pattern, RegexOptions.IgnoreCase);
Regex regex2 = new Regex(pattern2, RegexOptions.IgnoreCase);
string answerSeparated = System.Net.WebUtility.HtmlDecode(regex.Replace(answer, substitution));
answerSeparated = System.Net.WebUtility.HtmlDecode(regex2.Replace(answerSeparated, substitution2));
return answerSeparated.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
}
}
}
I've even tried copying and pasting the method signature from the sample in the repository and still I get this error.
The way that QnAMakerServiceAttribute works means this isn't intuitive, as you must use constant expressions for the keys.
When can we expect the newest commit that added changes to QnADialog so it would work with services on Azure to be updated on the nuget package? Wanted to change my code to use that service instead of the preview, but without what was changed on that commit I can't do it.
(I don't know what involves updating on nuget, if it takes much time or effort, asking so I can get a sense of when it will be available).
Hi ,
Is qnamker questins are unique?can i give same question twice with metadata to differentiate it?
can anyone help me in this?
Hi,
Can "" in a question be a problem?
Because for me it's not working with quotation marks in a question
"NoMatchHandler" not getting triggered when no match is found in QnA KB.
Instead "DefaultMatchHandler" is called with response as "No good match found in KB."
This behaviour started on updating the package to 3.1.2.
Any ideas on what would be going wrong over here?
I had one method which did not exactly match the delegate, took me some time to find because there is no clear exception or debug message in the catch.
Please make the throwOnBindFailure configurable or at least add some trace information via System.Diagnostics.Trace.TraceWarning(ex.message).
Hi, I tested this part: The dialog will take the incoming message and find the Best Match in the list of strings, according the a threshold that you set (0.5 by default). For example, if the incoming message was "hello", it would match be a match (matched with "hello there"), but "greetings" would not match at all.
and it does not seem to work at all.
For example if you try to put Hello in the list below:
[BestMatch(new string[] { "Hi", "Hi There", "Hello there", "Hey",
"Hey there", "Greetings", "Good morning", "Good afternoon", "Good evening", "Good day" },
Its not working. How to adjust? or which threshold should I put?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ššš
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ā¤ļø Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.