How to clear state in botkit 4 conversation

150 views Asked by At

We have built a bot using botkit v4 and we are using it with Facebook messenger.

We want to clear the state on a specific facebook_postback.

I tried the following but nothing is working.

bot.controller.storage.delete(message.user)

I did not find any proper references in the documents as well. any help will be appreciated.

Ref: https://learn.microsoft.com/en-us/javascript/api/botbuilder-core/storage?view=botbuilder-ts-latest#delete-string---

1

There are 1 answers

0
Naktibalda On

Storage.delete method takes a list of identifiers, so correct syntax is

bot.controller.storage.delete([itemId]);

Also you need to discover correct format for itemId, I have an example from websocket controller and it looks like this:

websocket/conversations/USERID-USERID/

The final syntax would look like this:

const itemId = 'facebook/conversations/' + message.user + '-' + message.user + '/';
await bot.controller.storage.delete([itemId]);