How to detected dead conversation references when using proactive conversations

Viewed 37

We are using ContinueConversationAsync to send a Proactive Message to existing conversations which is working, what we want it a way to detect if that conversation is still active for instance if the conversation channel is webchat that session may no longer exists or a teams channel and the user has now left the organisation. Otherwise our ConversationReference table will just grow indefinably. At the moment SetProactiveMessage still just continues with no error even if there is no longer a user on the other end.

 var conversationReference = botProactiveMessageConversation.ConversationReferenceJson.FromJson<ConversationReference>();
            conversationReference.ActivityId = null;
            MicrosoftAppCredentials.TrustServiceUrl(conversationReference.ServiceUrl);
            await defaultAdapter.ContinueConversationAsync(botProactiveMessageConversation.BotAppId, conversationReference, async (ITurnContext turnContext, CancellationToken cancellationToken) =>
            {
                turnContext.SetProactiveMessage(botProactiveMessageConversation.ProactiveMessageData);
                await dialogBot.OnTurnAsync(turnContext, cancellationToken);
            }, default);
1 Answers

Unfortunately, there is no concept of a dead conversation in Direct Line. Subsequently, there is no method you can rely upon that is built in. A conversation's Conversation.Id is stored by the service for 14 days (subject to change, so don't rely on this as a rule) at which point it is purged. When storing your conversation reference, you can append a lastAccessed date and, when your time threshold is reached, it is purged from your store.

As for determining if a member is still part of a team or in an org, you will need to rely on a separate service call. Your best bet would be to use Microsoft's Graph API to check statuses.

Hope of help!

Related