VermontDepartmentOfHealth / covid-bot

A knowledge base & automated chatbot from the Vermont Department of Health with info for the COVID-19 response
https://vermontdepartmentofhealth.github.io/covid-bot/
MIT License
3 stars 2 forks source link

track conversation history #5

Open KyleMit opened 4 years ago

KyleMit commented 4 years ago

Stack Overflow Thread: Looking for a unique “Conversation ID” in the App Insights for QnA Maker

We currently have a kql query in app insights that joins on a partial ID match

// answered and unanswered
let startDate = todatetime("2020-03-25T16:30:00");
// bad convo ids
let wrongIDs = traces
| where customDimensions.Question contains "This did NOT answer my question" 
| project extract("^[a-z0-9]{7}", 0, itemId);
// get all q/a pairs
traces
| extend input = tostring(customDimensions.Question),
        answer = tostring(customDimensions.Answer),
        scoreInt = toint(round(todouble(customDimensions.Score))),
        convoId = extract("^[a-z0-9]{7}", 0, itemId)
| where message contains "GenerateAnswer"
    and input  !contains "This did NOT answer my question"
    and timestamp > startDate
| extend score = iif(convoId in (wrongIDs), -1, scoreInt), // separate bad vs good
         EST = datetime_add("hour", -4, timestamp)         // convert UTC to EST
| order by timestamp desc 
| project itemId,
          input,
          faq = extract("^\\*\\*(.*)\\*\\*", 1, answer),
          type = case(score == -1, "wrong",
                      score == 0, "no answer",
                      "answered"),
          score,
          timestamp = format_datetime(EST, "MM/dd/yyyy hh:mm tt")

But we should confirm if this is the best approach or potentially customize the build

KyleMit commented 4 years ago

Save user conversation - Docs

A bot is inherently stateless. Once your bot is deployed, it may not run in the same process or on the same machine from one turn to the next. However, your bot may need to track the context of a conversation so that it can manage its behavior and remember answers to previous questions. The state and storage features of the Bot Framework SDK allow you to add state to your bot. Bots use state management and storage objects to manage and persist state. The state manager provides an abstraction layer that lets you access state properties using property accessors, independent of the type of underlying storage.

Add telemetry to your bot

BotBuilder-Samples > samples > csharp_dotnetcore > 45.state-management