Skip to content
← Back to Community
Tutorial: How to make a bot in my chat service (Documentation)
Profile icon

You have probably already read my forum about my new chat service (if you haven't, click the link). In this tutorial, you will learn how to make a bot on my chat platform. This will probably also help you with making bots in other chat services and improve your javascript skills in general. Now let's get to it!

1. Basics

To run your bot you will have to run it using your js console. Press Ctrl Shift I and open the console. Your bot will stop running if you close your tab. Make sure that your javascript context is top, not the iframe or anything else.

2. Keywords

You need something to trigger the bot to run, so the Register function with register a keyword. When anyone sends that keyword in the chat, the bot will do the corresponding function. Just have Register(Keyword to register as a string, Function name to do as a string). Do not declare your functions or variables names as Names, Keywords, Functions, Socket, NewMessages, Send, Register, Frame, TextBox, Button, ScrollButton, ReadButton, New or MessageReceive, as those variables and functions are needed for the web client to run correctly so don't overwrite them.

3. Send()

Of course, you need a way for your bot to interact with other people in the chat, so call Send(Message to send as a string) to send a message.

4. An Example

Register("I like cats", "Reply") function Reply() {Send("I like cats too")}

5. Advanced

If you want to get super advanced, you might want to get the messages people send. Since the messages are in the iframe, this might be helpful.

6. Bonus

If you want your own chat room, simply fork my repl. If you want to make it private, add a feature that prompts the user to enter the password and then make an XHR request to the server and if it matches the secret environment variable then allow the user into the room. You will have to figure out the specifics of that yourself (hey, replit is about coding, not being lazy).
svg files cannot be displayed:

Profile icon
Profile icon