Kaizoku Kaizoku - 1 year ago 142
C# Question

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

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.


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

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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download