Why isn't BotUserData persisting and retrievable in my Bot Framework bot?

妖精的绣舞 提交于 2019-12-13 21:44:11

问题


I am using dummy messages with user ids to set BotUserData for a particular user, so that the bot can access it elsewhere via the same method.

Example:

        message.From.Id = someUserId;            
        message.SetBotUserData("someObject", someObject);

Later, when another user is interacting with the bot, I execute

        message.From.Id = someUserId
        someObject = message.GetBotUserData<objectType>("someObject")

But someObject is returned as NULL

Note that these two snippets are being executed on different channels, conversations

Am I using it wrong?


回答1:


The userId is different on each channel (i.e. Skype / Slack use a different namespace). BotFramework currently does not provide a means to link accounts between channels. You could create a user interface that allows users link accounts (for example by generating a token in one channel and having the user type it into another).

<SLACK-USER> Get Link code
<SLACK-BOT> Link Code: FSE1-SDF2

<SKYPE-USER> Link account FSE1-SDF2
<SKYPE-BOT>  User linked

You'd then want to create your own data store that you can access with the token you provided.



来源:https://stackoverflow.com/questions/37996859/why-isnt-botuserdata-persisting-and-retrievable-in-my-bot-framework-bot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!