Hey developers! I’m excited to introduce an exciting new option for text chat in your experiences - TextChatService!
Overview
TextChatService is our new successor to the existing Chat service, and makes the process of managing channels, decorating messages, filtering text, creating commands, and developing custom chats much more simple.
In addition, this system is much easier and sustainable for engineers at Roblox to iterate on and will receive regular fixes & new features over time without conflicting with any code you may have written that uses it.
If you’d prefer to make your own frontend GUI for chat, this should help streamline your development process by handling the chat boilerplate code for you.
How is TextChatService different from Chat service?
TextChatService formalizes the sending and delivery of chat messages specifically within the Roblox engine and treats the data it receives appropriately with that context.
Think of this feature as the sum of two parts:
API
The most notable piece de resistance aspect of the next TextChatService is how TextChannel:SendAsync operates. SendAsync will handle all the important policy-abiding business logic that every Roblox experience must follow for developers.
Here’s a laundry list of details that are automatically handled when using TextChatService API:
- Text filtering
- Message size limits/rate limiting
- Respecting chat privacy settings
- Message replication
- Channel permissions
- Command logic
Frontend
In addition to the API, TextChatService can also optionally provide a default frontend chat UI for your experience. Instead of “forking” chat player scripts to tailor the default UI for your experience, we plan to expose formal Roblox APIs (see ChatWindowConfiguration
and ChatInputBarConfiguration
to edit the look and feel of the chat. You can also disable the default frontend completely and still get the benefits of the new TextChatService instances for your own custom chat UIs!
Additionally, you can alter message styling without overriding our existing UI using OnIncomingMessage
hooks and [RichText tags - which means you can customize it to fit your experience.
New objects and services (formal documentation pending)
-
TextChatService - The top-level container for the new chat system. Chat objects must be parented under this.
-
ChatWindowConfiguration - Created automatically and parented under TextChatService, controls chat window style/behavior
-
ChatInputBarConfiguration - Created automatically and parented under TextChatService, controls chat window style/behavior
-
TextSource - Represents a speaker in a TextChannel,
-
TextChannel - Represents a text channel. Contains TextSources. Calling SendAsync from a client with a TextSource in that channel that has CanSend = true will send a chat message.
-
TextChatCommand - When a message with a prefix matching the Primary or Secondary alias is sent, the Triggered event will fire on the sending client and on the server
-
TextChatMessage - Immutable data object used to represent a chat message
-
TextChatMessageProperties - When returned from the TextChatService.OnIncomingMessage or TextChannel.OnIncomingMessage callbacks, will overwrite the matching properties on the TextChatMessage. Can be used to add rich text tags to a message.
How to opt-in
First, enable the Text Chat Service beta from the Studio beta menu & restart studio:
Next, when you open a place, you should see TextChatService in your explorer:
Click on this and change the ChatVersion property from LegacyChatService to TextChatService. This will disable the old chat from loading by default, and enable the new system:
…and you’re done! If you haven’t forked the old chat system, you shouldn’t have to make any changes. If you have, you may run into some issues as missing chat modules will no longer be automatically loaded in.
Demos
Adding name colors
See StarterPlayer.StarterPlayerScripts for relevant TextChatService code
NameColorDemo.rbxl (38.7 KB)
Adding commands
See ServerScriptService for for relevant TextChatService code
CommandsDemo.rbxl (38.4 KB)
Adding a VIP tag
See StarterPlayer.StarterPlayerScripts for for relevant TextChatService code
VIPDemo.rbxl (39.9 KB)
FAQs
Is the old Chat service going away? Do I have to migrate my existing custom chats?
- No. We have future plans to deprecate Chat service in favor of this, but you will not be forced to use TextChatService. While we encourage you to use our new chat objects (TextChannel, TextSource, TextChatCommand) to handle the replication of messages for safety purposes, you are still free to write your own chat systems as long as messages are properly filtered. There will be an extended period of time where we are strictly taking feedback to improve the new TextChatService system before we even consider deprecating the existing service.
Where’s the documentation?
- Full documentation and tutorials are still pending, and will be added here when completed!
Where are the name colors?
- If you would like to implement name colors as they are right now, here is a demo place (38.7 KB) that shows how this can be implemented. If you have an opinion on this, please let us know!
What about BubbleChat?
- Currently, BubbleChat API lives in the old Chat service. Exposing BubbleChat controls through a TextChatService member is something we intend to support very soon.
Next steps
We’re aiming to support as many chat use cases as we can, and not to build a product that you’re forced to use, but that you want to use. In doing this, we would really appreciate your feedback - is there something you would add to the configuration objects? Is there a reason you forked the old chat that is still an issue in this chat? Do you feel like there’s an event or helper function that could make your experience using this easier? Let us know about these and any issues you may encounter!
Thanks!