Does botpress maintain session even if the bot is restarted?


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 ,


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.


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 ??


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.


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).

  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 ?


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: