Detecting messages with Node.JS

Thank you for your response, I am very grateful. I tried to use the code but couldn’t get it to work, and I don’t really understand what it all means. If possible, could you explain how it works and to get it working? Thanks.