At what point does the openfire is storing the chat transcripts?

At what point does the openfire is storing the chat transcripts? I have a ticket Id in my application and I want to track the chat transcripts based on the ticket id? Is there a way to solve this problem? Further, if the case was old I want to display the question asked by the client to the agent. Please help me.