Execute custom action just before the end of session

I made a chatbot that collects the data from the users and stores them in a database. If a user just fills half of the form and goes idle then I don’t want already filled data to be lost. Currently, I am performing a custom action that stores slots in the database at the end of the form (custom action is triggered when all the slots are filled). I don’t want to perform a database call every time a slot is filled. Instead, if any slots are not filled and the user goes idle I want to perform the action just before the session expires.

Thanks in advance.

Rasa doesn’t have a concept of an end of session. There’s currently session expiration here but no event is thrown. But the other issue with this is that it is only called if and when the user associated with the session re-starts their conversation.

I think you need to come up with your own way of tracking an incomplete form. Maybe store the session id in Redis or a json file at the start of the form along with the timestamp. Have an external process read this periodically and call a Rasa external event to post the incomplete form.