ChatToWebhook
This is a server-side module that logs in-game chat messages and sends them to a generic webhook endpoint (any HTTP receiver you control). It’s designed for moderation/audit logging and avoids spamming your endpoint by batching messages on an interval and whenever the queue nears the content limit.
Features
-
Server-side capture using
Player.Chatted -
Batching + queue
- flushes every
BATCH_INTERVAL - flushes early when queued content reaches the soft limit
- retries safely by re-queueing the batch on request failure
- caps batches per tick (
MAX_BATCHES_PER_TICK)
- flushes every
-
Sanitization
- removes control chars (keeps
\nand\t) - prevents accidental
@-style pings by inserting a zero-width character - clamps to max UTF-8 characters and appends
…
- removes control chars (keeps
-
Content-limit aware
- uses a soft limit (1900) with truncation to avoid hard cutoffs
- truncates single oversized lines with
…
Use cases
- Remote logging / audit trails
- Moderation review logs
- Basic server telemetry (“what players are saying”) stored off-platform
Setup
-
Place the module somewhere server-only (ex:
ServerScriptService/ChatLogger). -
Enable HTTP requests:
- Game Settings → Security → Enable Http Requests
-
Open
Configand set:WEBHOOK_URL = "https://your-endpoint.example/webhook"
Keep the webhook URL server-side only (do not replicate it to clients).
Configuration
In Config:
WEBHOOK_URL— your endpoint URLMAX_NAME_LENGTH— clamp username lengthMAX_MESSAGE_LENGTH— clamp message lengthBATCH_INTERVAL— flush interval (seconds)CONTENT_LIMIT/CONTENT_SOFT_LIMIT— request body content sizing
Payload format (what your endpoint receives)
Requests are sent as JSON with a single field:
{
"content": "...\n..."
}
Each line is formatted like:
[HH:MM:SS] Username: message
How it works
-
Each chat message is turned into a
LoggedMessagewith:timestampIso,unixuserId,usernamemessage
-
The logger estimates the total content size and pops batches that fit under
CONTENT_SOFT_LIMIT. -
If the request fails, the batch is prepended back into the queue to avoid losing logs.
Notes about chat capture
This implementation uses Player.Chatted on the server for broad compatibility with existing experiences. If you want true per-channel logging (e.g., team/global/system channels), that typically requires additional integration depending on your chat pipeline.