RbxChatBot V2.8 - Make your roblox chat bot easily

RbxChatBot

Note: This module only worked on server.

Hello Roblox! Here is my new library! RbxChatBot!

With this module, you can easily create a bot in Roblox chat. Inspired by discord.js.

To implement this in your game, you can take this file
RobloxChatBot.rbxm (3.5 KB)
and drop it into the studio, and then simply require it like this

local RbxChatBot = require(game.ReplicatedStorage.RobloxChatBot)

or, if you want to use this module up-to-date. do not use .rbxm file, and simply require it like this.

local RobloxChatBot = require(7294504893)

when requiring module with id, it won’t work on the studio

and then you’re all set!

How to use

you might be asking this, let’s diving into it.

first thing first let’s require it

local RobloxChatBot = require(game.ReplicatedStorage.RobloxChatBot)

and then, let’s create a new client

local RobloxChatBot = require(game.ReplicatedStorage.RobloxChatBot)
local client = RobloxChatBot.new()

and then, let’s set the bot’s name, chat color, and chat tag

local RobloxChatBot = require(game.ReplicatedStorage.RobloxChatBot)
local client = RobloxChatBot.new()

client.Name = "Tutorial"
client.ChatColor = Color3.new(255, 0, 0)
client.ChatTag = {
	TagText = "BOT",
	TagColor = Color3.fromRGB(0, 255, 0)
}

you can change the ChatColor to whatever you like, and edit the ChatTag if you want.

next, we need to detect when the player is sending a message.

client:on("message", function(message)
	
end)

as you can see. I put function with message parameter. this function will trigger when player sending a message.

let’s see what player is sending

client:on("message", function(message)
	if message.content == "/blah" then
		
	end
end)

so, if the message’s content is “/blah” we will reply to it!

client:on("message", function(message)
	if message.content == "/blah" then
		client:send(message.author.Name.." just said weird command.")
	end
end)

let’s send a private message!

client:on("message", function(message)
	if message.content == "/blah" then
		client:send(message.author.Name.." just said weird command.")
		client:sendPrivateMessage("you just said weird command", message.author)
	end
end)

sendPrivateMessage takes two parameters. The first one is the message, the second one is the player object.

message.author will be a player’s object.

and then. we need the bot to be logged in.

client:login()

and, your script should look like this.

local RobloxChatBot = require(game.ReplicatedStorage.RobloxChatBot)
local client = RobloxChatBot.new()

client.Name = "Tutorial"
client.ChatColor = Color3.new(255, 0, 0)
client.ChatTag = {
	TagText = "BOT",
	TagColor = Color3.fromRGB(0, 255, 0)
}

client:on("message", function(message)
	if message.content == "/blah" then
		client:send(message.author.Name.." just said weird command.")
		client:sendPrivateMessage("you just said weird command", message.author)
	end
end)

client:login()

to log out, simply use

client:logout()

Other feature

you could also detect friendJoin, by using the events called friendJoin.
this takes two parameters. The first one is an array full of the joined player’s friends, The second one is the player object who just joined.

client:on("friendJoin", function(friends, playerWhoJustJoined)
	for i, v in pairs(friends) do
		print(v.Name.." is a friend with "..playerWhoJustJoined.Name)
	end
end)

There is also a method to create a channel. Only the player who is in that channel can see the message.

it takes 2 parameters.

  • channelName (string)
  • channelParticipant (table)
RbxChatBot:CreateChannel("ChannelNameHere" {put all the player object you want here})
client:sendMessageToChannel("YourMessageHere", "ChannelNameHere") -- the channel name part is case-sensitive

when the bot is logged out, they wouldn’t be able to send any message!
however, even though the bot is logged out. they are still able to detect events

Drop a like if you like it!

this is one of the screenshots when I tested it!
bandicam 2021-08-20 18-31-37-723

26 Likes

Hi, would be great if we have a video of it working.

1 Like

Oh, yeah. I almost forgot. Thank you!

1 Like

Are there any other events except “messageCreate”?

1 Like

Not for now, but I planned for more events in the future

No problem mate all the best anyways a good resource I found today hope fully I use it in one of my games in future

1 Like

Update V1.1

  • Changed the send function from message to client
    so, if you want to send a message, use this method instead.
client:send("Your message here")
  • Changed the message.author from player’s name to a dictionary. Access player’s name like this instead
message.author.player.Name
  • Some bug fixes.
2 Likes

Planned events: friendJoin
Planned method: private message.

Watch this topic for more updates!

1 Like

How does it train its responses? Or is it preset replies?

Hey, this is cool! I might use this… as a fake player system.

1 Like

what do you mean by that? I don’t understand.

Its not powered by AI models. Its a Input Output kind of conversation, You send a command, and the bot responds to it if you coded it to respond back for a command.

1 Like

Yeah, it’s true. You could also make the function not responds. such as showing the GUI.

Update V2.0

  • Added the way to private message player, using client:sendPrivateMessage(message, player)

  • Changed the message.author from dictionary to player’s object. so, you can access the player’s name with this.
    message.author.Name

  • Some bug fix

Update V2.2

  • Added new events. “friendJoin”. lookup how to use it in the first post on this topic.

  • Some bug fix

Have some feedback? type it below!

Is this meant to run on the client only?

It can be ran only on server since ChatService (which this module uses) is server-side only. Trying to use it on client would probably cause it to error.

1 Like

Okay! Sorry for my mistake. I haven’t gotten a chance to use this yet so I didn’t look at the code.

Planned events: JoinedChannel
Planned method: joinChannel

Update V2.8

  • Added new method. :CreateChannel() look up how to use it at the first post on this topic
  • Some bug fixes