Clearing State
StuartMorris0 opened this issue · 5 comments
Hello,
Is there a quick way to clear the stateMachine at all?
For testing the bot, I would like to clear all state on previous conversations/loads so that I can start from the beginning of the script each time without having to clear cache etc.
Thanks,
👍
The stateMachine doesn't persist any state, that's the store's job, so clearing the state depends on what kind of store you're using.
However if you're using the SmoochApiStore then clearing state for a given user isn't possible. If you know which userId you want to reset, you would have to explicitly set the state to your bot's beginning state, eg like this:
bot.store.set('yourUserId', 'state', 'yourStartState')
Thanks @alavers.
When using just the web messenger for Smooch, is there a way to find out the userID and to make a JS call to clear the state somehow?
And you can do it through SmoochApiStore with bot.store.set
as suggested above, or to do it directly via web messenger you can use https://github.com/smooch/smooch-js#updateuseruser