add the function to save chat record