I am developing a bot using MS Bot framework in Node.JS. I am going through documentation on various ways of saving/retrieving state of user conversation with bot.
As per my understanding, for each bot, each user is a different conversation. For e.g. I have 2 bots, BOT-A & BOT-B. And a user with skype ID abc.skype access these bots. This user will be identified using a different conversationID & userID for each bot. I.e. for BOT-A the user's conversationID will be 'ABC' & for BOT-B the conversationID will be 'XYZ'. The userID field in session object will hold data which can identify the user, such as user's publicly visible name in the channel.
As per documentation (saving-state)
userData stores information globally for the user across all conversations.
- What is meant by globally here?
- What is meant by across all conversations?
conversationData stores information globally for a single conversation. This data is visible to everyone within the conversation so exercise with care when storing data to this property. It’s enabled by default and you can disable it using the bot's persistConversationData setting.
- What is meant by single conversation?
- Which data is visible to everyone? How the data is visible to everyone, when it is the bot which decides, what response to send as reply or each user message? And who is everyone?
privateConversationData stores information globally for a single conversation but it is private data specific to the current user. This data spans all dialogs so it’s useful for storing temporary state that you want cleaned up when the conversation ends.
dialogData persists information for a single dialog instance. This is essential for storing temporary information in between the steps of a waterfall in a dialog.
What is actual storage mechanism/location for saving state? By this I mean that if I save some data in session.userData
and access it after a week for the same user, how come I get the same data. Where is the data saved actually?
What happens if I set persistUserData
& persistConversationData
to false? Does that mean userData & conversationData will not be persisted. If yes, then it essentially means that I cannot save data. Isn't it? Or does this mean something different?
Can anyone share any example where there are multiple users in same coversations? Or an example which demonstrates capabilities(pros & cons) of these various data saving methods.
Resources I referred:
https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-state