0
votes

I am creating an FAQ bot using bot framework V4, Node.js. I have to implement a simple counter - when the bot did not respond with the right answer 3 times consecutively, a message should be displayed.

I tried a class level variable and an instance level variable to keep track of the number of errors. Since only a single instance of the bot class is created all these variables are singleton and can't work for each conversation.

Please share if you have any reference implementation for such issues, with out using conversation state.

1
Can you clarify what you mean by each variable is singleton? Are you saying setting variables within your bot class retain their values across different user conversations? If that is the case, conversation state is probably the best solution. Is there a reason you do not want to use it? - billoverton
Yes, I meant setting a variable is shared across user conversations. Main reason to avoid conversation state is to avoid an additional resource, CosmosDB/Storage, just for a counter. The counter is specific to a conversation and is not required to be retained. - sreeharikm

1 Answers

1
votes

If you want to monitor and counter the error occurs in each conversation , you can follow this official guide to add state for your bot conversations

And this is the node.js state management demo.

With this demo you can make your each conversation stateful and monitor counters for each conversation .

If there is anything unclear , pls feel free to let me know.