Store chat in Mongo DB

Hi,

Can somebody guide me is there anyway to store chats permanently and reload from database likewise MongoDB or any other source.

Thanks