Gold Challenge: Chat Bot

You used the WebSocket.Server property to create the chat server. You can also programmatically create a chat client by using WebSocket as a constructor.

The following line is an example:

var chatClient = new WebSocket('http://localhost:3001');

The documentation at github.com/​websockets/​ws has a simple example of sending and receiving text data.

Create a chat bot that automatically connects to the chat server. It should greet each new user but otherwise remain silent unless directly spoken to. For example, if your chat bot responds to the name “Jinx,” you could type “Jinx, put Max in space,” and your chat bot would respond appropriately. (The appropriate response is up to you.)

Make sure that the ...

Get Front-End Web Development: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.