Reputation: 1054
I am working with Microsoft bot development framework, using its node.js sdk. I have been looking for a way to save all the messages of a conversation. I set persistConversationData to true, and tried to access the conversationData using session.conversationData. However, it is empty.
1- Is there a builtin method to access all the messages within a conversation?
2- If persistConversationData is not for that, can anyone please explain its usage.
Thank you so much.
Upvotes: 3
Views: 2967
Reputation: 777
By default, messages will not be persisted by the Microsoft Bot Framework. For stateful operations, you can use the Bot State API the following ways:
userData
. The persisted data will be available to the same user across different conversations.conversationData
. The persisted data will be available to all the users within the same conversation.privateConversationData
. The persisted data will be available to the given user in the given conversation.dialogData
for storing temporary information in between the steps of a waterfall.According to the documentation, conversationData
is disabled by default. If you want to use it, you have to set persistConversationData
to true
.
tl;dr You have to take care of persistence for yourself. E.g.
// ...
var bot = new builder.UniversalBot(connector, { persistConversationData: true });
bot.dialog('/', function (session) {
let messages = session.conversationData || [];
messages.push(session.message);
session.conversationData = messages;
});
Upvotes: 6