Hello, I'm interested in storing the entire chat history in our database using an API. Currently, I'm only storing it after the user has rated the chat, but I'm losing data if the user closes the chat before reaching the rating stage. Can you assist me in achieving this?