BotBuilder-Samples icon indicating copy to clipboard operation
BotBuilder-Samples copied to clipboard

Proactive sample stores conversation references in local memory

Open v-kydela opened this issue 5 years ago • 8 comments

Sample information

  1. Sample type: samples
  2. Sample language: all
  3. Sample name: 16.proactive-messages

Describe the bug

Our proactive message sample stores conversation references in the bot's local memory. We need to fix it so that it stores conversation references in persistent storage. This may involve bypassing the bot state classes and accessing the storage classes directly, or it may involve introducing a new global bot state class that can be accessed without a turn context.

Here are some examples of customers who have been encountering problems because we've taught them to store conversation references incorrectly:

  • https://github.com/microsoft/botbuilder-dotnet/issues/4753
  • https://stackoverflow.com/questions/64206530/serialize-turncontext-instance-to-json-and-store-in-redis-or-cosmos-db-for-maint

v-kydela avatar Oct 05 '20 16:10 v-kydela

is the issue is fixed

kandy99 avatar Nov 11 '20 06:11 kandy99

@v-kydela please let me know of any alternative for the same

kandy99 avatar Nov 17 '20 08:11 kandy99

@kandy99

I'm sorry but this issue has not been triaged yet.

@ryanlengel @benbrown @johnataylor @xieofxie

Can you please comment on when this issue might get triaged?

v-kydela avatar Nov 17 '20 18:11 v-kydela

I don't know either.. I see they are working on a StorageQueue Approach here https://github.com/microsoft/botbuilder-dotnet/pull/4974

xieofxie avatar Nov 18 '20 01:11 xieofxie

@v-kydela it will be good if this issue is fixed or there will be an alternative approach for the same

kandy99 avatar Nov 25 '20 06:11 kandy99

@kandy99 - I'm sorry this hasn't been looked at yet. You said you'd like your issue to be addressed with a sample, but if you'd like a workaround for the meantime, it would be a good idea to ask a question on Stack Overflow.

v-kydela avatar Nov 25 '20 18:11 v-kydela

This doc demonstrates using an Azure Queues service: https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-howto-long-operations-guidance an earlier example version of this (not identical to the doc anymore) can be found here: https://github.com/EricDahlvang/LongOperationsBot

Also, here is a Cosmosdb example using an Azure Timer Function: https://github.com/EricDahlvang/TimeoutConversation

These are in my personal GitHub repository, and not official Microsoft samples, but they might help provide some alternative approaches for how to store and use a ConversationReference to proactively restart a conversation without using a local dictionary.

Sample 16.proactive-messages is intentionally left very small, and not demonstrating using a specific storage mechanism. Swapping out the the dictionary for a persistent storage has been left as an exercise for the developer and their specific implementation. Maybe we should update the readme, and comments to suggest that the dictionary should be replaced with persistent storage of the developers choice.

EricDahlvang avatar Nov 25 '20 19:11 EricDahlvang

@mrivera-ms / @tracyboehrer any thoughts on updating the sample / readme to suggest that the user should instead use persistent storage instead of in-memory storage?

tonyanziano avatar Jul 22 '21 18:07 tonyanziano

This sample will not be changed to use persistent storage. As Eric stated, it is to demonstrate the pieces needed to perform proactive messaging and intentionally as simple as could possible. In a production app, persistent storage would be needed.

tracyboehrer avatar Feb 09 '24 20:02 tracyboehrer