Closed dabgar closed 3 years ago
@dabgar could you give us some details on this? In #3668, Peter suggested telemetry could be logged through these two classes:
https://github.com/microsoft/botbuilder-dotnet/blob/main/libraries/Microsoft.Bot.Builder.AI.QnA/Dialogs/QnAMakerDialog.cs https://github.com/microsoft/botbuilder-dotnet/blob/main/libraries/Microsoft.Bot.Builder.AI.QnA/QnAMaker.cs
Are you saying that, even coded added to log telemetry data through these classes, it is not appearing in App Insights?
Attaching a screenshot of the issue faced. The code shared is C# code , is there a nodejs version of the same. Also like answer and question which comes directly without adding any code is it not possible to get the metadata similar way?
Let me know the way to get the metadata of qnamaker in the insight(complete procedure with the query please)
@dabgar, Peter's suggestion of writing a custom dialog to achieve this would be my recommendation as well. Unfortunately, we do not have a sample available that illustrates how to achieve this functionality.
There is a sample custom dialog, the MultiplyDialog
in the samples repo that shows how to write a custom dialog.
The general approach you would take is to write a custom dialog extending from QnAMakerDialog
, probably overriding the protected getQnaMakerClient(...)
method to return a custom QnAMaker
implementation that includes the metadata you care about in the onQnaResults
method. Below is some pseudocode that illustrates the example
class CustomQnAMakerDialog extends QnAMakerDialog {
async getQnaMakerClient(dialogContext) {
const client = await super.getQnAMakerClient(dialogContext);
const onQnaResults = client.onQnaResults.bind(client);
client.onQnaResults = (qnaResults, turnContext, properties = {}, metrics = {}) => {
properties = { ...properties, custom: 'property' };
metrics = { ...metrics, custom: 1.0 };
return onQnaResults(qnaResults, turnContext, properties, metrics);
}
}
}
As I mentioned above, this is pseudocode so you will have to study it and probably amend it further to suit your needs. I hope this helps!
Closing with Josh Gummersall's answer.
Please let me know how to include metadata in the insight query for QnAMaker logs somthing as this, here the meatadata field comes empty
requests | where url endswith "generateAnswer" | project timestamp, id, url, resultCode, duration, performanceBucket | parse kind = regex url with *"(?i)knowledgebases/"KbId"/generateAnswer" | join kind= inner ( traces | extend id = operation_ParentId ) on id | extend question = tostring(customDimensions['traces']) | extend answer = tostring(customDimensions['Answer']) | extend score = tostring(customDimensions['Score']) | extend metadata = tostring(customDimensions['qnaMakerOptions']) | project answer,['metadata']
Originally posted by @dabgar in https://github.com/microsoft/botframework-solutions/issues/3668#issuecomment-925524320