This module uses AI to protect your webforms from spam by analyzing submissions in real-time. It can be trained with custom prompts and offers options for human review, submission truncation, and trusted IP bypass to help manage costs and accuracy.
AI Webform Guard is a lightweight Drupal module that protects your Webform submissions from spam using AI-powered classification.
Instead of relying on traditional CAPTCHA mechanisms, this module uses Chat-based AI model (via the AI module) to analyze form submissions in real time and decide whether a message is spam or not — based on your custom prompt.
Features
- Seamless integration with Webform module
- Uses LLM-based AI detection to classify submissions
- Configurable AI model and prompt template via UI
- Logs blocked spam attempts if enabled
- Prompt templates support Twig tokens and multilingual rendering
- Exclude specific Webform fields from AI spam evaluation via UI
- Human Iteration. If enabled, flagged submissions require manual confirmation before being allowed. The checkbox appears only for submissions flagged as potential spam.
- Submission Truncation. Maximum words per AI request. Limits how many words from the Webform submission are sent to the AI to reduce token usage. On average, one word equals ~1.3–1.5 tokens. Useful for long forms.
- New: Spam Confirmation Flow (per Webform). If the message is detected as spam, the user can confirm their email address via a new email handler.
To do this, you must set up a new email confirmation handler using the Webform Email Confirmation Link module and enable the checkbox under the respective webform in AI Webform Guard Fields Settings.
See the README for details. - New: Protect your custom forms from spam. You can also protect your custom forms against spam using AI by enabling the ai_form_guard submodule.
After enabling it, you must enter the ID of the corresponding custom form in the AI Webform Guard Settings.
On the new configuration page AI Form Guard – Custom Form Fields, you can define fields to be excluded from the spam check, with one field ID per line. - New:Trusted IPs bypass AI processing via an IP whitelist, repeat spammers are blocked by flood control without AI checks, and configurable token limits reduce API costs.
- New: Spam Probability Threshold. The spam probability threshold is always active and determines when submissions are blocked based on AI-calculated spam probability.50 = Aggressive (block suspicious content, may have false positives), 70 = Balanced (default), 90 = Permissive (only block obvious spam with high confidence).
Requirements
Configuration
- Go to Configuration → AI Webform Guard. (
/admin/config/ai/ai_webform_guard) - Enter a prompt to guide the AI model (e.g., "Classify the following submission as Spam or Not Spam.").
- Select your preferred AI model (optional — uses default otherwise).
- Save your settings.
- To exclude specific fields from spam detection:
- Go to Configuration → AI Webform Guard Fields Settings (
/admin/config/ai/ai_webform_guard/ai_webform_guard_fields) - Select the fields you want to ignore for each Webform
How it works
Each time a Webform is submitted, the module:
- Renders your AI prompt (with Twig)
- Appends the form submission data
- Sends it to the selected AI model via chat interface
- Parses the response looking for: Classification: Spam or Classification: Not Spam
- Blocks the submission and logs it if spam is detected
Similar Projects
Depends on
Dependencies of the latest stable release
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Release Timeline
Releases
| Version | Type | Core | Notes | Release date | |
|---|---|---|---|---|---|
| 1.1.7 | Stable | 10–11 | Aug 21, 2026 | ||
| 1.1.6 | Stable | 10–11 | Jan 20, 2026 | ||
| 1.1.5 | Stable | 10–11 | Jan 2, 2026 | ||
| 1.1.4 | Stable | 10–11 | Dec 20, 2025 | ||
| 1.1.3 | Stable | 10–11 | Dec 20, 2025 | ||
| 1.1.1 | Stable | 10–11 | Nov 20, 2025 | ||
| 1.0.10 | Stable | 10–11 | Oct 11, 2025 | ||
| 1.1.0 | Stable | 10–11 | Oct 11, 2025 | ||
| 1.0.9 | Stable | 10–11 | Oct 11, 2025 | ||
| 1.0.8 | Stable | 10–11 | Confirmation checkbox requiring human validation before allowing submission if flagged as spam. | Jun 12, 2025 | |
| 1.0.7 | Stable | 10–11 | May 28, 2025 | ||
| 1.0.6 | Stable | 10–11 | May 23, 2025 | ||
| 1.0.5 | Stable | 10–11 | It is possible to define a custom prompt for each form. | May 15, 2025 | |
| 1.0.4 | Stable | 10–11 | May 12, 2025 | ||
| 1.0.3 | Stable | 10–11 | May 8, 2025 | ||
| 1.0.2 | Stable | 10–11 | May 8, 2025 | ||
| 1.0.1 | Stable | 10–11 | May 8, 2025 | ||
| 1.0.x-dev | Dev | 10–11 | May 8, 2025 | ||
| 1.0.0 | Stable | 10–11 | May 8, 2025 |