Reputation: 303
Microsoft blogged about GDPR compliance for Bot Framework today - https://blog.botframework.com/2018/04/23/general-data-protection-regulation-gdpr/.
Have a had a go at implementing (https://github.com/leeroy79/GDPRBot) but coming up against a few hurdles. Their provided sample relies on the deprecated state service so wondering about alternatives.
Part 1 -
Specifically - how can we get an IBotState
or IConversations
(which 3 of the mentioned GDPR methods operate on) without using State Client, either within the bot or in an external website as recommended?
Part 2 -
Also any thoughts on how to clear conversation / user / private conversation data for one specific user given the mentioned methods SetUserData()
and SetPrivateConversationData()
are both deprecated?
I've tried the following but it doesn't actually clear the state. I can directly do context.UserData.Clear()
and context.PrivateConversationData.Clear()
but that won't work when this code is moved to a standalone website and context
isn't available as suggested in the GDPR post.
using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, context.Activity.AsMessageActivity()))
{
var dataStore = scope.Resolve<IBotDataStore<BotData>>();
var address = new Address(
context.Activity.Recipient.Id,
context.Activity.ChannelId,
context.Activity.From.Id,
context.Activity.Conversation.Id,
context.Activity.ServiceUrl);
var token = default(CancellationToken);
await dataStore.SaveAsync(address, BotStoreType.BotUserData, null, token);
await dataStore.SaveAsync(address, BotStoreType.BotPrivateConversationData, null, token);
await dataStore.FlushAsync(address, token);
}
Cheers
Lee
Upvotes: 2
Views: 248
Reputation: 14619
how can we get an
IBotState
orIConversations
(which 3 of the mentioned GDPR methods operate on) without using State Client, either within the bot or in an external website as recommended?
The State Client is not deprecated, it's the initial implementation provided by Microsoft which is (sometimes called Bot State Service
).
Once you migrated your bot code to use your own storage (see here), for example Azure Table Storage or Cosmos DB, you should use IBotDataStore<BotData>
interface to manipulate your data.
Also any thoughts on how to clear conversation / user / private conversation data for one specific user given the mentioned methods
SetUserData()
andSetPrivateConversationData()
are both deprecated?
You have to use IBotDataStore<BotData>
interface methods:
public interface IBotDataStore<T>
{
/// <summary>
/// Return BotData with Data pointing to a JObject or an empty BotData() record with ETag:""
/// </summary>
/// <param name="key"> The key.</param>
/// <param name="botStoreType"> The bot store type.</param>
/// <param name="cancellationToken"> The cancellation token.</param>
/// <returns>Bot record that is stored for this key, or "empty" bot record ready to be stored</returns>
Task<T> LoadAsync(IAddress key, BotStoreType botStoreType, CancellationToken cancellationToken);
/// <summary>
/// Save a BotData using the ETag.
/// Etag consistency checks
/// If ETag is null or empty, this will set the value if nobody has set it yet
/// If ETag is "*" then this will unconditionally set the value
/// If ETag matches then this will update the value if it is unchanged.
/// If Data is null this removes record, otherwise it stores
/// </summary>
/// <param name="key"> The key.</param>
/// <param name="botStoreType">The bot store type.</param>
/// <param name="data"> The data that should be saved.</param>
/// <param name="cancellationToken"> The cancellation token.</param>
/// <returns>throw HttpException(HttpStatusCode.PreconditionFailed) if update fails</returns>
Task SaveAsync(IAddress key, BotStoreType botStoreType, T data, CancellationToken cancellationToken);
Task<bool> FlushAsync(IAddress key, CancellationToken cancellationToken);
}
Those methods are generic for user / privateConversation / conversation data.
Upvotes: 2