Closed Stevenic closed 6 years ago
Working on this. Hoping to get a PR sometime tonight or tomorrow.
Cool... You might look at the version I did for JavaScript for inspiration:
I ended up calling it ConversationVersion
because it's really about deleting the conversation state anytime you update things. I also let the dev provide a callback that's called anytime a version difference is detected. Its then up to their code to decide if they wish to upgrade or delete the state and start over.
Okay sure thing. Thanks for sending me this.
v3 has a dialog version middleware which is useful for you adding a major.minor version to your bots conversational system. This version number gets stamped on every conversation state object an anytime the conversations major versions no longer match the state will be automatically deleted and the user will be sent a message saying "A system update has occurred and we need to start over." Why do you need to do that?
If you deploy a major update to your bot you run the risk of users getting into a stuck state due to the fact their current conversation state no longer reflects the structure of the bot that was just deployed. In some cases this can result in your bot throwing an exception which is actual a good thing because we'll catch that and automatically deleted the conversation state. The more difficult scenario is that instead of throwing an exception you can end up trapping the user in an infinite loop that they can't get out of. Given the user a way to always say "goodbye" and force a conversation state deletion is one way to get them out but incrementing your bots major version number is a more automatic way of doing this and prevent the user just having to know they can say "goodbye".
I can't say enough how critical a feature this is so while it could be done as a sample its probably best as a piece of middleware that we encourage all developers to always include in their bot somewhere after the ConversationStateStore middleware.