Fix type bug
Extract common chat functionality