This plugin for osTicket automatically detects and closes spam tickets using AI (OpenAI or compatible APIs) analysis of ticket subject, body, and attached files. It uses keyword matching as a fast first-pass filter and AI for deeper content analysis when needed.
- Automatic processing of new tickets on creation
- Manual trigger via button in ticket view
- Content analysis: subject, message body, attached files
- File format support:
- Images (JPG, JPEG, PNG, GIF, WebP) - via AI Vision API
- PDF - via pdftotext (if installed)
- Word (.doc, .docx) - via antiword or unzip (if installed)
- Plain text files
- Dual detection method: fast keyword matching + AI analysis
- Confidence scoring (0-100%) for spam detection
- Multiple API providers: OpenAI or any OpenAI-compatible API endpoint
- Wide model selection: GPT-5, GPT-4.1, GPT-4o, o-series reasoning models, and custom models
- Fallback mode: works with keywords only when AI is unavailable
- Internal notes with closure reason and spam indicators
- No email notifications sent to users when closing spam tickets
- Debug logging for troubleshooting
- Copy the
osticket-ai-spam-closerfolder to/include/plugins/ - Navigate to admin panel: Admin Panel → Manage → Plugins
- Find "AI Spam Closer" and click Install
- After installation, click on the plugin to configure
-
API Provider - choose API provider type:
Open AI- use OpenAI API (default)Custom- use custom OpenAI-compatible API endpoint
-
API Key - your API key (optional)
- For OpenAI: get one at https://platform.openai.com/api-keys
- For Custom: use your provider's API key
- Leave empty to use keyword matching only (no AI analysis)
-
API URL - custom API endpoint URL (required for Custom provider)
- Must be OpenAI-compatible endpoint
- Example:
https://api.example.com/v1/chat/completions - For OpenAI provider, this is set automatically to
https://api.openai.com/v1/chat/completions
-
Model Name - AI model to use for analysis:
- GPT-5 series (latest):
gpt-5.2- Latest, improved reasoninggpt-5.1- Coding & agentic tasksgpt-5.1-codex/gpt-5.1-codex-mini/gpt-5.1-codex-max- Optimized for codegpt-5-mini- Fast, 400K contextgpt-5-nano- Fastest, cheapest
- Reasoning models (o-series, think longer before responding):
o3- Most advanced reasoningo3-mini- Cost-efficient reasoningo4-mini- Latest compact reasoningo1/o1-mini- Extended/compact reasoning
- GPT-4.1 series (improved coding & long context):
gpt-4.1- Best for coding, 1M contextgpt-4.1-mini/gpt-4.1-nano- Balanced/fastest
- GPT-4o series (multimodal, recommended for images):
gpt-4o- Multimodal, capablegpt-4o-mini- Fast and affordable (recommended)
- Legacy models:
gpt-4-turbo/gpt-3.5-turbo
- For Custom provider: enter any model name manually
- For OpenAI provider: select from dropdown
- GPT-5 series (latest):
-
API Timeout - maximum wait time for API response (seconds)
- Default:
30seconds - Increase if you experience timeout errors
- Default:
-
Temperature - controls response randomness (0.0-2.0)
- Lower values = more deterministic responses
- Higher values = more creative/random responses
- Default:
0.3(recommended for classification tasks) - Range: 0.0 to 2.0
- Note: Lower temperature values (0.0-0.5) are recommended for spam detection to ensure consistent, deterministic results
-
Spam Keywords (Fallback) - backup keywords for when AI is unavailable or as fast first-pass filter
- Format: comma or semicolon separated
- Example:
viagra, casino, lottery, winner, click here, buy now, limited offer, earn money fast, work from home, make money online, free money, get paid, amazing offer - Case-insensitive search
- Partial text matching
- Important: Keywords are checked first (fast), AI analysis runs only if no keyword matches found
-
Close Reason Text - internal note text added when closing spam tickets
- Default:
This ticket has been automatically closed as spam based on content analysis. - This text appears in the internal note along with the detection reason
- Default:
-
Auto-close on ticket creation - automatically analyze and close new tickets if spam is detected
- When enabled, plugin processes tickets immediately on creation
- When disabled, only manual trigger is available
-
Max File Size (MB) - maximum file size to process for text extraction
- Default:
10MB - Larger files are skipped and logged
- Default:
-
Enable Debug Logging - log processing details and AI requests for debugging
- When enabled, detailed information is written to system logs
- Useful for troubleshooting detection issues
When "Auto-close on ticket creation" is enabled, the plugin automatically:
- Analyzes each new ticket on creation
- Extracts text from subject, body, and attached files
- Checks for spam keywords first (fast)
- If no keyword matches, uses AI for deeper analysis (if configured)
- Closes ticket if spam is detected
- Adds an internal note with closure reason and spam indicators
A "🚫 Check for Spam and Close" option appears in the "More" dropdown menu in the ticket view:
- Open a ticket
- Click the "More" button (with three dots) in the ticket toolbar
- Select "🚫 Check for Spam and Close" from the dropdown menu
- The plugin will analyze the ticket and close it if spam is detected
- Results are shown in the UI with debug information (if logging enabled)
The plugin uses a two-stage detection approach:
-
Keyword Check (First Pass - Fast)
- Searches ticket content for configured spam keywords
- Case-insensitive, partial matching
- If matches found → SPAM detected, ticket closed immediately
- No AI call needed, very fast
-
AI Analysis (Second Pass - If No Keywords Matched)
- Only runs if API key and API URL are configured
- Analyzes ticket content using AI
- Considers:
- Promotional/commercial content
- Suspicious links or offers
- Generic mass-mailing patterns
- Requests for personal information or money
- Typical spam keywords and phrases
- Irrelevant or off-topic content
- Returns:
- Spam determination (true/false)
- Confidence score (0-100%)
- Reasoning explanation
- List of spam indicators
- If spam detected → ticket closed
-
Fallback Mode
- If AI is not configured or fails
- Relies on keyword check results
- Works without AI (keyword-only mode)
The plugin collects text from:
- Ticket subject - full subject line
- Message body - all thread entries, HTML stripped
- Attached images (JPG, PNG, GIF, WebP):
- Uses AI Vision API (requires model with vision support, e.g., GPT-4o)
- OCR text extraction
- PDF files:
- Uses
pdftotextutility (if installed) - Extracts all text content
- Uses
- Word documents (.doc, .docx):
- Uses
antiwordorcatdocfor .doc files - Uses
unzipfor .docx files (XML extraction)
- Uses
- Plain text files:
- Direct reading
Files that are too large, unsupported, or fail to process are logged but don't prevent analysis.
Each spam detection and closure operation is recorded as an internal note:
- Poster:
AI Spam Closer - Title:
Spam Detected - Auto Closed - Content:
- Close reason text (from config)
- Detection reason (keyword matches or AI analysis result)
- Confidence score (if AI was used)
- Spam indicators (if AI was used)
- No email notifications are sent to users
- osTicket 1.18+
- PHP 7.2+
- PHP CURL extension
- API key (OpenAI or compatible provider)
- API URL (for custom providers)
pdftotext- for PDF text extractionantiword- for Word .doc filescatdoc- fallback for Word .doc filesunzip- for Word .docx files
Note: The plugin can work in keyword-only mode without AI or file processing utilities. However, for best results, configure AI and install file processing utilities.
When "Debug Logging" is enabled, information is written to the system log:
- Details of each ticket processing
- Number of configured keywords
- Content preview and length
- Keyword match results
- AI API requests and responses
- Confidence scores and spam indicators
- File processing details
- Errors and exceptions
Log viewing: depends on server configuration (usually /var/log/apache2/error.log or /var/log/nginx/error.log)
viagra, casino, lottery, winner, click here, buy now, limited offer, earn money fast, work from home, make money online, free money, get paid, amazing offer, urgent action required, guaranteed income, no investment, risk-free, act now, limited time, exclusive offer
get rich quick, investment opportunity, cryptocurrency, bitcoin, forex trading, binary options, passive income, money making scheme, pyramid scheme, ponzi scheme
verify account, update payment, account suspended, security alert, click to confirm, urgent verification, account locked, password reset required
- Check that "Auto-close on ticket creation" is enabled (for automatic mode)
- Verify spam keywords are configured
- If using AI: ensure API key and API URL are correct
- Enable Debug Logging and check logs
- Check that tickets actually contain spam keywords or are detected by AI
- Verify API key is correct and has sufficient balance (for OpenAI)
- Check API URL is correct (for Custom provider)
- Ensure API Timeout is sufficient (increase if requests timeout)
- Verify model name is correct and available
- Check Temperature value is within range (0.0-2.0)
- Check system logs for API errors
- Test API connection manually
- Check file sizes (don't exceed Max File Size setting)
- For PDF/Word: install pdftotext/antiword/catdoc utilities
- For images: verify model supports Vision API (gpt-4o, gpt-4o-mini, or compatible)
- Check system logs for file processing errors
- Review spam keywords - remove or refine overly broad terms
- Lower Temperature value (e.g., 0.1-0.2) for more deterministic, conservative detection
- Review AI analysis results in debug logs
- Consider disabling auto-close and using manual trigger only
- Add exceptions to keywords list
- Add more spam keywords to the list
- Ensure AI is configured and working
- Review detection results in debug logs
- Check that file attachments are being processed
- Verify keywords match spam patterns in your tickets
- Ensure plugin is installed and enabled
- Check that you have permission to view tickets
- Verify plugin files are correctly placed in
/include/plugins/ - Clear browser cache and reload page
OpenAI API is paid, approximate prices (may vary):
- GPT-4o-mini: ~$0.15 per 1M input tokens (recommended for spam detection)
- GPT-4o: ~$5 per 1M input tokens
- GPT-4.1 series: varies by tier
- o-series (reasoning): premium pricing
- Vision API: ~$0.01 per image
For Custom API providers, check your provider's pricing.
Cost optimization tips:
- Use keyword matching first (free, fast) - most spam will be caught here
- Use
gpt-4o-minifor AI analysis - best balance of cost and quality - Only process files when necessary (images, PDFs with text)
- Monitor API usage in debug logs
Recommendation: The plugin is designed to minimize API calls by checking keywords first. Most spam will be caught by keywords, and AI will only be used for edge cases.
- Plugin ID:
osticket:ai-spam-closer - Classes:
AISpamCloser* - Ajax endpoint:
/ai-spam-closer/analyze - CSS classes:
.ai-spam-closer-*
- Class:
AISpamCloserAPIClient - Supports OpenAI and OpenAI-compatible endpoints
- Temperature: configurable (default: 0.3, range: 0.0-2.0)
- JSON mode: enabled for structured responses
- Images: base64 encoded, sent to Vision API
- PDF: requires
pdftotextsystem utility - Word .doc: requires
antiwordorcatdoc - Word .docx: uses
unzipto extract XML, then parses text - Text files: direct file reading
- Keyword check: < 1ms (in-memory string search)
- AI analysis: 1-5 seconds (depends on API response time)
- File processing: varies by file size and type
- Overall: most tickets processed in < 1 second (keyword match), AI tickets in 2-6 seconds
- Anatoly Melnikov
1.0.0
This plugin is licensed under the GNU General Public License v2 (GPL-2.0).
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See the LICENSE file for the full license text.