added mongodb functionality to save chat messages