Added the init function and chatEvent handler function