Features
- Simple Substring Matching: Configure a list of substrings to detect
- Case Sensitivity Control: Choose case-sensitive or case-insensitive matching
- Selective Scanning: Scan only the latest message or all messages
- Reject or Redact: Either block requests or automatically redact matched content
- Configurable Redaction: Use static text or character repetition for redaction
- Multiple Matches: Handles multiple occurrences of substrings
Use Cases
- Block profanity or offensive language
- Prevent competitor brand mentions
- Enforce content policies by blocking specific keywords
- Redact internal code names or project names
- Filter out specific phrases or terms
- Implement custom content moderation rules
Configuration Options
substrings
(required)
Array of strings to search for in messages. Each string is matched as a substring (not whole word).
rejectMessage
(string)
Custom message to return when a substring is found and redactMatches
is false.
Default: "Request contains forbidden content"
scanAllMessages
(boolean)
true
: Scans all messages in the arrayfalse
: Only scans the latest message- Default:
false
caseSensitive
(boolean)
true
: Substring matching is case-sensitivefalse
: Substring matching is case-insensitive- Default:
false
redactMatches
(boolean)
true
: Redacts matched substrings instead of rejectingfalse
: Rejects the request if a match is found- Default:
false
redactionText
(string)
Text to replace redacted substrings with.
Default: [REDACTED]
redactCharacters
(string)
If set, replaces each match with this character repeated to match the length of the original text. Overrides redactionText
if both are set.
Example Configurations
Block Profanity
Block Competitor Mentions
Redact Internal Code Names
Redact with Character Masking
Case-Sensitive Exact Matches
Response Behavior
When Rejecting (redactMatches: false)
- Returns
reject: true
with the configured rejection message - First matched substring triggers the rejection
- No messages are modified
- Debug logs show total number of matches
When Redacting (redactMatches: true)
- Returns modified messages array with redacted content
- All occurrences of all substrings are redacted
- Original request continues through the pipeline
- Debug logs indicate how many matches were redacted
Matching Behavior
Substring vs Whole Word
The plugin performs substring matching, not whole-word matching:- Substring
"test"
matches: “test”, “testing”, “contest”, “latest” - To match whole words only, include surrounding spaces in your substring (e.g.,
" test "
)
Case Sensitivity
WhencaseSensitive: false
:
- Substring
"Test"
matches: “test”, “TEST”, “Test”, “tEsT”
caseSensitive: true
:
- Substring
"Test"
only matches: “Test” - Does not match: “test”, “TEST”, “tEsT”
Multiple Occurrences
All occurrences of each substring are detected and processed:- Input:
"test test test"
- Substring:
"test"
- Result: All three occurrences are found and redacted
Example Scenarios
Scenario 1: Block Profanity
Configuration:"This is a badword in the text"
Result: Request rejected with message “Inappropriate language detected”
Scenario 2: Redact Competitor Names
Configuration:"Have you tried CompetitorX product?"
Output: "Have you tried [COMPETITOR] product?"
Scenario 3: Mask Sensitive Terms
Configuration:"My password is secret123"
Output: "My ******** is secret123"
Debug Information
The plugin provides detailed debug information including:- Number of messages scanned
- Case sensitivity mode
- Total matches found
- Number of unique matches (when redacting)
- Action taken (blocked or redacted)
Technical Notes
- Empty substrings are ignored
- Handles both string and array content formats
- Preserves non-text content (images, audio, etc.)
- When case-insensitive, original case is preserved in redaction
- Duplicate replacements are deduplicated to improve performance
- All occurrences of each substring are found, not just the first