chatbot-enchanced

Enhanced chatbot functionality with Redis/Valkey integration for rate limiting, buffer time, session management, and advanced features

Package Information

Released: 8/2/2025
Downloads: 9 weeklyĀ /Ā 65 monthly
Latest Version: 0.1.11
Author: TrigiDigital

Documentation

šŸ¤– n8n-nodes-chatbot-enhanced

npm version
License: MIT

šŸš€ Production-ready chatbot enhancement node for n8n workflows with Redis/Valkey integration.

⚔ High-performance architecture supporting 100-200+ operations per second with enterprise-grade error handling, multi-output streams, and real-time analytics.

šŸ”„ Key Features:

  • šŸ›”ļø Smart Rate Limiting with burst protection and penalty systems
  • šŸ’¾ Session Management with context storage and automatic cleanup
  • ā±ļø Message Buffering with šŸ›”ļø Anti-Spam Detection (1-3600 seconds)
  • 🧠 Smart Memory for conversation, FAQ, and context management
  • šŸ”€ Message Routing with multi-channel support and load balancing
  • šŸ‘¤ User Storage for profiles, preferences, and history
  • šŸ“Š Real-time Analytics with performance monitoring and alerts
  • 🚨 NEW! šŸ›”ļø Built-in Anti-Spam Protection with pattern detection and flood protection

Installation
Operations
Credentials
Compatibility
Usage
Resources
Version history

Installation

Follow the installation guide in the n8n community nodes documentation.

Install the package in your n8n installation:

# In your n8n installation directory
npm install @trigidigital/n8n-nodes-chatbot-enchanced

Or install directly from npm registry:

npm install -g @trigidigital/n8n-nodes-chatbot-enchanced

Operations

The ChatBot Enhanced node uses a Resource/Operation pattern for easy discovery and organized functionality:

šŸ›”ļø Rate Limiting Actions

Smart rate limiting with burst protection and penalties

  • Check Rate Limit: Verify if user is within rate limits and get remaining quota
  • Reset User Limits: Clear rate limiting counters for specific user
  • Get Limit Status: Retrieve comprehensive rate limiting statistics

šŸ‘„ Session Actions

User session management and storage operations

  • Create Session: Initialize a new user session with context storage
  • Update Session: Add message to session and extend timeout
  • Get Session Data: Retrieve session information and conversation history
  • Store User Data: Save user preferences, history and profile information

šŸ’¬ Message Actions

Message buffering and routing for human-like responses with anti-spam protection

  • Buffer Messages: CRITICAL FEATURE - Collect multiple messages and flush after time delay (TimedBuffer implementation) with šŸ›”ļø built-in anti-spam detection
  • Route Messages: Direct messages to appropriate channels or queues
  • Process Queue: Handle queued messages with priority and load balancing

šŸ“Š Analytics Actions

Smart memory, metrics tracking and performance monitoring

  • Track Event: Record custom events for analytics and monitoring
  • Query Metrics: Retrieve analytics data and performance statistics
  • Store Memory: Save conversation context, FAQ or knowledge data
  • Generate Report: Create comprehensive performance and usage reports

šŸ”„ Multiple Outputs (Enterprise Architecture) - UPDATED v0.1.4!

The node provides 2 streamlined outputs for simplified workflow management:

  1. āœ… Main: Successfully processed messages, operation results, and clean data (combines Success + Processed)
  2. šŸ“Š Status: Error handling, metrics, spam detection alerts, and system health (combines Error + Metrics)

šŸ›”ļø Anti-Spam Detection Status: The Status output now includes comprehensive spam detection information:

  • Spam detection results with confidence scores
  • Blocked message statistics
  • Pattern matching details
  • Flood protection alerts

šŸš€ Performance Specifications

  • Throughput: 100-200+ operations per second
  • Latency: 3-10ms average response time
  • Reliability: Enterprise-grade error handling and retry mechanisms
  • Scalability: Supports Redis clusters and high-availability setups
  • Memory: Efficient memory usage with compression and cleanup

Credentials

To use this node, you need to set up Redis API credentials. The node supports multiple Redis connection types:

Prerequisites

  • A running Redis or Valkey server (version 6.0+ recommended)
  • Network access to your Redis instance
  • Appropriate authentication credentials if required

Available Authentication Methods

  1. Standard Connection: Direct connection to a single Redis instance

    • Host and port configuration
    • Optional database selection (0-15)
  2. Redis Cluster: Connection to a Redis cluster setup

    • Multiple host:port pairs for cluster nodes
    • Automatic node discovery and failover
  3. Redis Sentinel: Connection through Redis Sentinel for high availability

    • Sentinel host:port pairs
    • Master instance name configuration

Authentication Options

  • None: No authentication required
  • Password Only: Redis AUTH command with password
  • Username & Password: Redis 6.0+ ACL authentication

Security Features

  • SSL/TLS encryption support with certificate validation
  • Connection options including timeouts, retry logic, and keep-alive
  • Advanced SSL configuration with custom certificates and keys

Connection Testing

The credential configuration includes automatic connection testing to validate your Redis setup before using the node.

Compatibility

  • Minimum n8n version: 1.0.0
  • Node.js version: 20.15 or higher
  • Redis/Valkey version: 6.0 or higher (recommended)
  • Tested against: n8n versions 1.0.0+

Known Compatibility Issues

  • Redis versions below 6.0 may not support username/password authentication
  • Some advanced features require Redis 6.2+ for optimal performance
  • SSL/TLS features require proper certificate configuration

šŸ’” Usage

šŸš€ Quick Start (Resource/Operation Pattern)

  1. Add Redis Credentials: Configure your Redis connection in n8n credentials
  2. Add ChatBot Enhanced Node: Drag the node into your workflow
  3. Select Resource: Choose from 4 action categories:
    • Rate Limiting Actions: For spam protection and user quotas
    • Session Actions: For user session management and storage
    • Message Actions: For buffering and routing (human-like responses)
    • Analytics Actions: For metrics, memory, and performance monitoring
  4. Choose Operation: Select specific action within the resource category
  5. Configure Parameters:
    • Session Key: ={{$json.userId || $json.sessionId}}
    • Message Content: ={{$json.message || $json.text}}
    • Resource-specific settings (buffer time, rate limits, etc.)
  6. Connect Outputs: Wire Success, Processed, Error, and Metrics outputs

āš™ļø Advanced Configuration Tips

  • Buffer Time: 1-3600 seconds for message buffering (human-like delays)
  • Rate Limits: Requests per minute with burst protection
  • Session Timeouts: Minutes for session management
  • Resource Planning: Each buffering session = 1 long-running execution

Resource/Operation Examples

Rate Limiting Actions Example:

Resource: "Rate Limiting Actions"
Operation: "Check Rate Limit"
Session Key: ={{$json.userId}}
Rate Limit: 10 // requests per minute

Message Buffering Example:

Resource: "Message Actions"  
Operation: "Buffer Messages"
Session Key: ={{$json.userId}}
Message Content: ={{$json.message}}
Buffer Time: 10 // seconds - creates human-like delays

Session Management Example:

Resource: "Session Actions"
Operation: "Update Session"
Session Key: ={{$json.userId}}
Message Content: ={{$json.message}}
Session Timeout: 30 // minutes

Output Handling - UPDATED v0.1.4!

Connect the two streamlined outputs to handle different scenarios:

  • Main output: Continue normal flow processing with clean, spam-free data
  • Status output: Implement error handling, monitor performance, and handle spam detection alerts

Expression Usage

The node supports n8n expressions for dynamic configuration:

// Session key from incoming data
={{$json.userId || $json.sessionId || "anonymous"}}

// Message content from various fields
={{$json.message || $json.text || $json.content}}

šŸŽÆ Message Buffering + šŸ›”ļø Anti-Spam - Human-Like Response (ENHANCED in v0.1.4!)

ā±ļø Revolutionary TimedBuffer Implementation with Built-in Anti-Spam Protection - The FLAGSHIP feature for human-like chatbot responses:

🧠 How It Works (TimedBuffer Logic + Anti-Spam)

// REAL BEHAVIOR with anti-spam protection:

Chat 1: "Hello"                → Master Execution: Start 10s timer, wait...
Chat 2: "How are you?"         → Slave Execution: Add to buffer, extend timer, return "pending"
Chat 3: "spam spam spam"       → Slave Execution: šŸ›”ļø BLOCKED by anti-spam detection!
Chat 4: "What's your name?"    → Slave Execution: Add to buffer, extend timer, return "pending"

After 10 seconds              → Master Execution: Return CLEAN MESSAGES only!
// Output: ["Hello", "How are you?", "What's your name?"] (spam filtered out)

šŸ›”ļø Anti-Spam Detection Features

  • Repeated Text Detection: Automatically blocks duplicate or very similar messages
  • Flood Protection: Prevents rapid message spamming within time windows
  • Pattern Recognition: Detects URLs, excessive caps, phone numbers, emails
  • Custom Regex Patterns: Advanced users can define custom spam patterns
  • Configurable Actions: Block, delay, or mark spam messages
  • Smart Filtering: Only clean messages are included in the final batch

šŸ”„ Execution Pattern

  • Master Execution: First message creates buffer, waits for timer, collects all messages
  • Slave Executions: Subsequent messages extend timer, add to buffer, return immediately
  • Natural Delay: Human-like response delay (not instant robot replies)
  • Batch Collection: All messages returned together after timeout

āš™ļø Configuration (Enhanced v0.1.4)

Buffer Time: 10                           // Wait 10 seconds before responding
Session Key: {{$json.userId}}             // Group messages by user
Message: {{$json.message}}                // Content to buffer

// šŸ›”ļø NEW Anti-Spam Settings (Optional)
Anti-Spam Detection: "Repeated Text"      // or "Flood Protection", "Pattern Match"
Spam Action: "Block Message"              // or "Delay Extra", "Mark as Spam"
Similarity Threshold: 80                  // % similarity for spam detection
Flood Time Window: 30                     // seconds to check for rapid messages
Flood Max Messages: 3                     // max messages allowed in time window

šŸŽÆ Perfect For:

  • Human-like Chatbots: Wait for multiple messages before responding (like humans do)
  • Conversation Context: Collect user's complete thought before processing
  • Natural UX: Avoid instant robot-like responses + filter out spam
  • WhatsApp/Telegram Style: Mimic how humans read 2-3 messages then respond
  • šŸ›”ļø Customer Support: Automatically handle spam attempts and repeated messages
  • šŸš€ High-Volume Bots: Built-in protection against abuse and flooding

āš ļø Production Requirements:

  • Execution Timeout: Set workflow timeout to 60 seconds
  • Redis Monitoring: Health checks for buffer persistence
  • Resource Planning: Each session = 1 long-running execution
  • Traffic Limits: Optimal for 5-50 concurrent users

šŸ“Š Response Types (Enhanced v0.1.4):

// Buffered (Chat 2,3,4...)
{
  "type": "buffered", 
  "status": "pending", 
  "message": "How are you?",
  "spamDetection": {
    "isSpam": false,
    "actionTaken": "allowed"
  }
}

// Spam Blocked
{
  "type": "spam_blocked",
  "status": "blocked", 
  "message": "spam spam spam",
  "spamDetection": {
    "isSpam": true,
    "spamType": "repeated",
    "confidence": 95,
    "actionTaken": "blocked"
  }
}

// Batch Ready (After timer - Clean Messages Only!)
{
  "type": "batch_ready", 
  "status": "flushed", 
  "messages": ["Hello", "How are you?", "What's your name?"],
  "spamStats": {
    "totalMessages": 4,
    "spamDetected": 1,
    "spamBlocked": 1,
    "cleanMessages": 3
  }
}

šŸ—ļø Architecture & Performance

Multi-Manager Architecture (Enhanced v0.1.4):

  • šŸ”§ RedisManager: Connection handling with auto-retry and health checks
  • šŸ›”ļø RateLimiter: Sliding window with burst detection and penalties
  • šŸ’¾ SessionManager: Context storage with TTL and cleanup
  • šŸ“¦ MessageBuffer: Time/size-based buffering with šŸ›”ļø integrated anti-spam detection
  • šŸ†• SpamDetector: Hash-based similarity detection, flood protection, pattern matching
  • 🧠 SmartMemory: Conversation and FAQ storage with compression
  • šŸ”€ MessageRouter: Multi-channel routing with load balancing
  • šŸ‘¤ UserStorage: Profile and preference management
  • šŸ“Š AnalyticsTracker: Real-time metrics with histogram generation

Performance Optimizations:

  • Connection pooling for high-volume scenarios
  • Batch processing for Redis operations
  • Memory compression for large datasets
  • TTL-based automatic cleanup
  • Health monitoring and alerting

Resources

Version history

0.1.11 (Current) - Anti-Spam Enhancement & Output Consolidation

  • šŸ›”ļø NEW ANTI-SPAM PROTECTION: Built-in spam detection for Message Buffering operations

    • Repeated Text Detection: Hash-based similarity detection with configurable thresholds
    • Flood Protection: Prevents rapid message spamming within time windows
    • Pattern Recognition: Detects URLs, excessive caps, phone numbers, emails, repeated characters
    • Custom Regex Patterns: Advanced users can define custom spam detection patterns
    • Configurable Actions: Block, delay extra time, or mark spam messages
    • Smart Filtering: Only clean messages included in final batch output
  • šŸ”„ OUTPUT CONSOLIDATION: Simplified from 4 outputs to 2 streamlined outputs

    • Main Output: Clean, spam-free data (combines Success + Processed)
    • Status Output: Errors, metrics, and spam detection alerts (combines Error + Metrics)
    • Backward Compatibility: Existing workflows continue to work with output routing metadata
  • šŸ“Š ENHANCED RESPONSE TYPES: New spam detection information in all responses

    • Spam detection results with confidence scores and action taken
    • Comprehensive spam statistics in batch outputs
    • Detailed spam type identification (repeated, flood, pattern)
  • šŸ—ļø NEW ARCHITECTURE COMPONENTS:

    • SpamDetector Manager: Sophisticated spam detection with Redis state persistence
    • Enhanced MessageBuffer: Seamless integration with anti-spam capabilities
    • Comprehensive Testing: 37+ anti-spam tests with performance validation
  • ✨ USER EXPERIENCE: Non-programmer friendly anti-spam configuration

    • Simple dropdown selections for spam detection types
    • Predefined patterns available (no regex knowledge required)
    • Clear parameter descriptions with helpful examples
    • User-friendly emojis and descriptions throughout the interface

Discussion