Add function to handle incoming chat messages