Implement chat function