Looking for a unique "Conversation ID" in the App Insights for QnA Maker

Viewed 481

We're using QnA Maker attached to an Azure Bot Service. In the Knowledge Base (KB), we've added a Follow up Prompt to every question that says This did NOT answer my question:

Knowledge Base > Follow Up Prompt

Meaning if a bad response was provided, the end-user could indicate so, and the conversation history would look like this:

Example Conversation

What we're trying to do is replay that conversation history so we can see:

  1. The original user prompt
  2. The original answer
  3. The subsequent followup question / answer

We have Application Insights turned on, so we can see both questions as they come through from the logs with the following query:

traces
| project timestamp, 
          itemId,
          question = customDimensions.Question,
          answer = customDimensions.Answer
| order by timestamp

Which will return these two rows:

App Insights Logs

However, we're trying to find a unique conversation id or session id that can correlate both of those records. Notice that the itemId is very similar, but not identical:

53be8c14-702c-11ea-8c41-11c1c266dc55
53be8c13-702c-11ea-8c41-11c1c266dc55

Is there a unique key that can be used to join these two events?

One workaround is to just use the first 7 digits of the itemID and join based on that partial match like this:

traces
| where customDimensions.Question contains "This did NOT answer my question" 
| project itemId,
          SessionID = extract("^[a-z0-9]{7}", 0, itemId),
          timestamp
| join (
    traces
    | extend question = tostring(customDimensions['Question'])
    | extend answer = tostring(customDimensions['Answer'])
    | where message contains "GenerateAnswer" 
        and question  !contains "This did NOT answer my question" 
    | project itemId,
              SessionID = extract("^[a-z0-9]{7}",0,itemId),
              question,
              answer,
              timestamp
) on SessionID 
| project question, answer, SessionID, timestamp //, itemId, itemId1
| order by timestamp desc, SessionID

But we're not sure that value will reliably only differ by the 8th digit, so would prefer a less fragile ID

1 Answers

I recently implemented a QnA maker BOT with active learning.

The sample is located here

It is very similar to what you are trying to achieve.

enter image description here

Related