Does botpress maintain session even if the bot is restarted?


#1

Hi all, I am using botpress v.10.51.10 , Say i have a flow like this (refer image)

Now say the bot is running and the user says " hi " , the first node will reply with the text and move on the second node(also replying the onEnter text in second node) waiting for the user input of name , Now suppose i restart the bot and give name now , will it continue from the second node and go to the third node ?

I tried it but it started from the first node only ,
Is there a way to do this ?

NOTE : I am using the same userid / chat again the second time i give my name - userId is the one used to maintain state I guess ,


#2

I believe user’s current node is stored in memory, so restarting bot cleans it away.
You could try override this by storing user’s current node and restoring it on conversation start. But that would be a bit hacky.


#3

I understand that , so would it go like I save the state object (with some values ) and current node name through out the flow in every node ? Is it a good approach to do so ??


#4

I think yes, but you’d need to dig into botpress core code to see where you can get it and how you can restore it.


#5

UserId is what we use to persist the state. State is persisted in the database so a restart won’t affect the ongoing conversation. Beware of the timeouts though. If you don’t speak to the bot for X minutes (default is 10m I think) then the session will be cleared (see logs).


#6
  login: {
    enabled: process.env.A8_ENV === 'production',
    useCloud: process.env.BOTPRESS_CLOUD_ENABLED,
    tokenExpiry: '6 hours',
    password: process.env.BOTPRESS_PASSWORD || 'password',
    maxAttempts: 3,
    resetAfter: 10 * 60 * 1000 // 10 minutes
  }

Hey , saw this configuration in the botfile.js , Is this the 10 minutes you are talking about ?


#7

Sorry I’m a bit confused, botfile.js is a Botpress 10 thing. In Botpress 11 you have a configuration file called botpress.config.json and each bot has their own bot.config.json. Can you confirm your BP version?

If you’re using BP 10.x, then the right internal is here: https://github.com/botpress/botpress/blob/archive/10.x/packages/dev-bot/botfile.js#L74