Botframework 如何在使用主动对话时检测死对话引用

Botframework 如何在使用主动对话时检测死对话引用,botframework,Botframework,我们正在使用ContinueConversationAsync向正在工作的现有对话发送一条主动消息,我们希望这是一种检测该对话是否仍处于活动状态的方法,例如,如果对话频道是webchat,则该会话可能不再存在,或者是一个团队频道,并且用户现在已离开组织。否则,我们的会话参考表将无法确定地增长。此时,即使另一端不再有用户,SetProactiveMessage仍会继续运行,不会出错 var conversationReference = botProactiveMessageConversati

我们正在使用ContinueConversationAsync向正在工作的现有对话发送一条主动消息,我们希望这是一种检测该对话是否仍处于活动状态的方法,例如,如果对话频道是webchat,则该会话可能不再存在,或者是一个团队频道,并且用户现在已离开组织。否则,我们的会话参考表将无法确定地增长。此时,即使另一端不再有用户,SetProactiveMessage仍会继续运行,不会出错

 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);
var conversationReference=botProactiveMessageConversation.ConversationReferenceJson.FromJson();
conversationReference.ActivityId=null;
MicrosoftAppCredentials.TrustServiceUrl(conversationReference.ServiceUrl);
等待defaultAdapter.ContinueConversationAsync(botProactiveMessageConversation.BotAppId,conversationReference,异步)(iTurContext turnContext,CancellationToken CancellationToken)=>
{
turnContext.SetProactiveMessage(botProactiveMessageConversation.ProactiveMessageData);
等待dialogBot.OnTurnAsync(turnContext,cancellationToken);
},违约);

不幸的是,在直拨电话中没有死对话的概念。随后,没有内置的方法可以依赖。会话的conversation.Id由服务存储14天(可能会发生更改,因此不要将此作为规则),此时它将被清除。存储会话引用时,可以附加
lastAccessed
日期,当达到时间阈值时,它将从存储中清除

至于确定某个成员是否仍然是团队或组织的一部分,您需要依靠单独的服务呼叫。你最好的选择是使用微软的来检查状态


希望有帮助

接受/向上投票答案服务于更大的堆栈溢出社区和任何有类似问题的人。如果你觉得我的回答足够,请“接受”并投票表决。如果没有,让我知道我还能提供什么帮助!