Kaizoku
Kaizoku

Reputation: 47

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.

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?

Upvotes: 0

Views: 185

Answers (1)

Lars
Lars

Reputation: 10573

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.

Upvotes: 1

Related Questions