wit icon indicating copy to clipboard operation
wit copied to clipboard

Context management in wit

Open cristian-aimi opened this issue 8 years ago • 13 comments

Hi, I have a question for the topic in object, there is a manner to manages the context? For Example:

User: there is a parking? Wit.ai: "entities"{Parking} BOT: Yes, of course, in front of us.

User: How much does it cost? Wit.Ai: "entities"{NULL} BOT: ####### (The Bot in this case without a context he can not know that the user is talking about the parking)

How can I hook the first question with the second? I must implement it in my application or there is something that i could use in wit.ai. There is something in the roadmap?

TIA Cristian

cristian-aimi avatar Dec 21 '17 14:12 cristian-aimi

Same question.

pintux avatar Jan 08 '18 10:01 pintux

hey team, currently, I'd suggest you store it on your app's end. The reasoning is:

  • Context can extend far beyond the conversation
    • For example:
      • you may fetch information about the user from the database (their previous preferences, information they entered online, etc)
    • We found storing context on Wit can lead to some brittle situations, where you end up needing to move more and more logic onto Wit, and that becomes cumbersome to functionality down the road

We are still thinking about better approaches however, and may introduce better ways to manage context with Wit down the road.

In the meantime, if you come across a problem managing context on your end, feel free to ping us and we'd be happy to weigh in.

stopachka avatar Jan 11 '18 23:01 stopachka

Another workaround you may want to try is to send back both the user request and the previous one and train your wit app to handle them. In this case: "How much does it cost?" may not returned anything but "there is a parking? How much does it cost?" will return something

l5t avatar Jan 11 '18 23:01 l5t

What is a good way to implement context management like a good data structure if any?

rajathgunners avatar Oct 15 '18 18:10 rajathgunners

Please any help would be appreciated. Facing a blocker in the current chatbot project.

rajathgunners avatar Oct 15 '18 18:10 rajathgunners

Hi @rajathgunners, the above ideas are generally what we recommend for context management. what are you trying to accomplish?

jtliao avatar Oct 16 '18 15:10 jtliao

A flight service bot mainly to check on lost luggage, reservation details and flight details. I plan on using a decision graph. Are graphs commonly used to store the flow of the conversation?

rajathgunners avatar Oct 16 '18 15:10 rajathgunners

This may be something worth posting on our Facebook group to see what other developers are doing, as we aren't always aware of how developers are doing things like context management.

When you say you plan to use a decision graph, do you mean:

  1. bot receives a message, and based on the intent, moves down one branch and keeps track of this new state
  2. bot receives another message, based on the intent, either goes down one branch based on the past state, or "resets" and goes back to the top

Seems feasible to me, though I don't know how commonly it is used.

jtliao avatar Oct 16 '18 15:10 jtliao

Thank you

rajathgunners avatar Oct 16 '18 15:10 rajathgunners

Please add a recipe to manage the context. Right now I am not sure how to create a dialog flow that remembers the state. :(

towfiqi avatar Feb 15 '19 15:02 towfiqi

Besides managing the dialog flow by your own coding, Microsoft Bot Framework is probably the sole setup where a context object is defined facilitating a stack to manage each and every "dialog" you have in your dialog flow. Pls refer to Bot Framework web pages for details.

So in principle you can keep relevant context/state info in each dialog instance. For example I plan to use a dictionary data structure to store all context variables of an interaction, which will be very "scenario based" then. But that's the most common design I can imagine so far.

The NLU I use is api.ai. Unlike the wit strategy revealed here, you can specify output/input context variables to link related intents. A simple construct but can sort of offer context in chaining intents.

Context variables in Bot Framework code plus the input/output context at the NLU intent level is the solution I plan to write intelligent bots so far.

Hope it helps.

diymikie avatar Jun 09 '19 04:06 diymikie

wouldn't it help the engine if we could just add a context string to an intent, so if the context is set to X you will search only for intents with that context? It would help the engine focus on relevant intents and maybe increase the probability of understanding the utterance?

gorenbox avatar Jun 18 '20 17:06 gorenbox

Hi everyone, we've recently launched the alpha release of Composer, a way to manage dialogue state and support multi-turn conversations. Check it out!

patapizza avatar Aug 10 '22 17:08 patapizza