Godot Integration
Secure your Godot multiplayer games with real-time chat moderation.
Architecture & Security
Never expose your API key in client builds. If you are building a multiplayer game, we strongly recommend running SafeComms on your authoritative game server (Node.js, Go, C#, etc.) rather than the client.
For the best player experience, use an Optimistic UI pattern:
- Client sends message to Server immediately.
- Client displays message locally (greyed out or pending state).
- Server validates content with SafeComms asynchronously.
- Server broadcasts message to other players if safe.
The example below demonstrates a direct integration for prototyping or server-side Godot instances. For production clients, proxy requests through your backend.
Prerequisites
1. Installation
Start by installing the SafeComms addon into your project.
- Download the safecomms-godot addon.
- Copy the
addons/safecommsfolder into your project. - Go to Project > Project Settings > Plugins.
- Enable the SafeComms plugin.
2. Configure Plugin
Configure the plugin with your API key. ⚠️ Only do this in a server-side script or during development. Do not ship this key in a client build.
func _ready():
# Initialize with your API Key
# IMPORTANT: This should be run on your authoritative server, not the client!
SafeComms.api_key = "your-api-key"3. Moderate Chat
Add the moderation logic to your chat system. This will scan messages before they are broadcast to other players.
func _on_send_message_pressed():
var text = $LineEdit.text
# Check content (Server-side check)
var result = await SafeComms.moderate_text(text)
if result.has("flagged") and result.flagged:
print("Message blocked: ", result.reason)
# Show error to user
$StatusLabel.text = "Message blocked: " + result.reason
else:
# Content is safe
send_message(text)4. Verify & Test
Finally, verify your integration is working correctly by running your game and sending a test message.
{
"id": "req_123abc",
"isClean": false,
"severity": "Critical",
"categoryScores": {
"profanity": 0.98,
"toxicity": 0.85
},
"reason": "Content contains profanity"
}5. Complete Example
Here is the full code block ready to copy and paste.
extends Control
func _ready():
# Initialize with your API Key
# IMPORTANT: This should be run on your authoritative server, not the client!
SafeComms.api_key = "your-api-key"
func _on_send_message_pressed():
var text = $LineEdit.text
# 1. Check content (Server-side check)
var result = await SafeComms.moderate_text(text)
# 2. Act on result
if result.has("flagged") and result.flagged:
print("Message blocked: ", result.reason)
$StatusLabel.text = "Message blocked: " + result.reason
return
# 3. Content is safe, proceed to send...
send_message(text)
$LineEdit.text = ""
func send_message(text):
# Your networking code here
passConfiguration & Tuning
Need to adjust sensitivity or allow certain words? You don't need to change your code. Head to the dashboard to configure your moderation profile globally.