FilterStringAsync's optional TextFilterContext parameter

Hello Developers and internet users!

We are making a change to the text filter API to help us improve the quality of our text filtering! :tada:
However we need your help and cooperation! We have added new api members to our text filtering functions which will identify chat as either public or private when you are filtering it.

These changes only affect our lovely TextService method :FilterStringAsync. Going forward this function will accept three parameters instead of two.

Here’s how FilterStringAsync looks today:

TextFilterResult FilterStringAsync (
    string stringToFilter,
    int64 fromUserId,
    TextFilterContext textContext = PrivateChat
)

You’ll notice that the third argument here is optional. This means there is no need for panic! If you are unable to add this parameter right away, our default value will take care of everything!


How will this affect my game?

If you are using the standard chat system, you do not need to do anything! The Roblox default chat system has been updated to automatically include these changes.

If you have modified the chat system, you may update any calls to TextService:FilterStringAsync to include an optional third parameter, Enum.TextFilterContext. The allowed values for this parameter are Enum.TextFilterContext.PublicChat or Enum.TextFilterContext.PrivateChat (as appropriate for the type of chat).

"Which files should I edit if I have forked Roblox's default chat and I want to make these changes?"

I only had to change two files to bring things up to code. ChatService had one function I looked at which was InternalApplyRobloxFilterNewAPI and ChatChannel had two functions I looked at which were SendMessageToSpeaker and InternalApplyRobloxFilter. Good luck! :eyes::construction_worker_man:

Hint: If you have simply modified the default Roblox in game chat scripts, you’ll want to leverage ChatChannel’s Private field to determine which Enum to send to TextService. That’ll do the trick!


What qualifies as private text?

Private text is anything that is seen only by specific players, rather than every player. For example, if the speaker’s expectation is that the chat will only be seen by a single player, or by a selected group of players, then the chat is considered private. Chat for teams or chat that is potentially visible to a wider group, such as the server and its inhabitants, is considered public.

If you are unsure what your text qualifies as, please leave the optional field blank. Easy!


What if I do not use TextService?
If you are not using TextService to filter your user’s text input, then I hope you are at least using ChatService’s methods! (I would recommend using TextService’s api in the future as it is much nicer and ergonomic!)

However if you currently have legacy content that utilizes ChatService’s filtering methods, never fret! These methods will currently default to appropriate values and do not require any changes at this time.


These changes have already been documented by our wonderful Information Experience team!
Find out more about this API on our Developer Portal at Documentation - Roblox Creator Hub

Bear in mind, while text filtering may seem daunting, these changes were made with developers (yes, you!) in mind.
Feel free to ask questions about these changes or the impact they may have on your games.

30 Likes

So will this lessen the filter strength?

5 Likes

So will this lessen the filter strength?

Good question. This could be fielded in two different ways.
The optional third parameter itself will have no bearing on the actual filtering results.
Overtime though, we do want to make our filtering smarter!

In other words – right now the parameter does not affect your games in the present nor how your users interact.
In the future – this parameter is a stepping stone for a greater Roblox social experience overall.

6 Likes

This is a step in the right direction. I hope the filter system will become smarter in the future to allow for more appropriate filtering and smarter word censoring. Great work :slight_smile:

4 Likes

I hope this will prevent instances where coordinates or numbers in general are tagged for seemingly no reason. It is certainly a step in the right direction!

4 Likes

Is the issue regarding that the fromUser has to be online and in the current server still a thing? This prevents us from creating proper filtering systems that don’t cache content.

I adore this man’s enthusiasm. Looking forward to hearing more awesome updates. :tada:

2 Likes

While true that you should not create a filtering system that does not cache content, my recommendation for you is to create a new topic describing what you are trying to do in your project. (Since that question is somewhat outside the scope of this topic.)

Giving us detailed examples of what you cannot do right now (but would like to do) would help Roblox make sure we are offering the proper tools you need!

Heads up - I have enabled a flag that relates to this topic. Please do let me know if you encounter any issues with TextService’s filtering method in new servers! :crossed_fingers:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.