Bot Framework 在对话之外读取 UserState 数据或恢复对话对话
Bot Framework Read UserState data outside of dialog or resume to conversation dialog
我有一个 PizzaBot。获得订单后,我将数据保存到 UserState。之后,用户获得一个按钮(ActionTypes.OpenUrl)以在不同的系统上支付订单。到目前为止一切正常。
但是,当支付服务调用我的 api 时,我无法再获取 UserState 数据。我已尝试发送主动通知,显示“您已成功付款”消息,但我无法检索用户数据。
我得到了我的对话 ID conversationReference,但我不知道我应该在 BotCallback 中调用什么来恢复对话。
foreach (var conversationReference in _conversationReferences.Values)
{
await ((BotAdapter)_adapter).ContinueConversationAsync(_appId, conversationReference, BotCallback, default);
}
你有这方面的例子吗?
感谢乔治,我已经解决了这个问题。
在 UserState 文档页面上写着:
User state is available in any turn that the bot is conversing with
that user on that channel, regardless of the conversation.
这意味着如果我的 NotificationController 被调用,UserState 就在某处。
因此,我在 BotCallback 上创建了一个带有选项的主动 MainDialog:请参阅:Starting A Dialog From From A Proactive Message 并读取 UserState 数据(如果该选项已填充且来自我的 NotificationController
)
我有一个 PizzaBot。获得订单后,我将数据保存到 UserState。之后,用户获得一个按钮(ActionTypes.OpenUrl)以在不同的系统上支付订单。到目前为止一切正常。
但是,当支付服务调用我的 api 时,我无法再获取 UserState 数据。我已尝试发送主动通知,显示“您已成功付款”消息,但我无法检索用户数据。
我得到了我的对话 ID conversationReference,但我不知道我应该在 BotCallback 中调用什么来恢复对话。
foreach (var conversationReference in _conversationReferences.Values)
{
await ((BotAdapter)_adapter).ContinueConversationAsync(_appId, conversationReference, BotCallback, default);
}
你有这方面的例子吗?
感谢乔治,我已经解决了这个问题。
在 UserState 文档页面上写着:
User state is available in any turn that the bot is conversing with that user on that channel, regardless of the conversation.
这意味着如果我的 NotificationController 被调用,UserState 就在某处。 因此,我在 BotCallback 上创建了一个带有选项的主动 MainDialog:请参阅:Starting A Dialog From From A Proactive Message 并读取 UserState 数据(如果该选项已填充且来自我的 NotificationController
)