Semi-functional JS for sending messages