Using the AI prompt condition to detect and ignore spam
The AI prompt condition in workflows is one of the most flexible tools available for automating thread triage — and it's well-suited to detecting spam. This article explains how the condition works, how to configure it for spam detection, and where its boundaries are.
How the AI prompt condition works
When a workflow reaches an AI prompt condition, Plain assembles a context snapshot of the thread and passes it to the model alongside your prompt. The context includes:
- The full thread message history (up to the 600 most recent messages, each up to 3,000 characters)
- Thread metadata: title, description, status, priority, and labels
- Customer details: name and email address
- Channel information (e.g. email, Slack, API)
- Assignees
- Thread fields and their configured schemas
- Attachment count
The model evaluates your prompt against this context and returns a simple boolean: match or no match. Your workflow branches accordingly — if the condition matches, the configured action fires.
For spam detection, you would pair this condition with the Set Status → Ignored action, which closes the thread with an ignored status detail.
Setting up a spam detection workflow
The AI condition prompt is a free-text field (up to 2,500 characters). A well-written prompt is the most important part of making this reliable.
Example prompt:
This thread is spam or should be silently ignored. Examples include: unsolicited sales or partnership outreach, automated phishing or credential-harvesting messages, irrelevant mass marketing unrelated to our product, test messages with no genuine support intent, or messages that appear to be sent to the wrong company entirely. If you are uncertain whether this is spam, treat it as spam and return true.
The last sentence is important: by default, the model returns false (no match) when uncertain. For spam detection, you generally want the opposite behaviour — instructing the model to err on the side of flagging uncertain cases will significantly improve how much spam gets caught.
Your workflow structure would be:
- Trigger: Thread created (or Message added, if you want to catch spam that arrives as a follow-up)
- Condition: AI prompt condition with your spam criteria
- Action: Set Status → Ignored
What this approach handles well
- Text-based outreach spam: Sales emails, partnership pitches, automated marketing blasts — anything where the message content reveals the intent.
- Misdirected messages: Threads clearly sent to the wrong company or product.
- Phishing and credential requests: Messages asking for login details, wire transfers, or similar.
- Pattern-based spam: If your spam follows recognisable patterns, you can describe them explicitly in the prompt and the model will apply them consistently.
Limitations to be aware of
Attachment content is not analysed
The model receives the count of attachments on a thread, but not the attachment content itself. If spam arrives as an image-only message — a common technique for evading text-based filters — the model will have very little signal to work with. This is the most significant gap for a spam use case.
No external reputation signals
The AI condition works exclusively with data Plain has stored about the thread and customer. There is no access to email headers, sender IP reputation, domain blocklists, or DMARC/SPF results. If you need header-level or network-level filtering, that would need to happen upstream at your email provider before the thread reaches Plain.
Already-flagged spam customers are handled separately
If a customer has already been marked as spam in Plain, workflows do not run for their new threads — they are caught earlier in the pipeline and their threads are automatically closed as ignored. The AI workflow condition is therefore most useful for catching new spam from customers not yet identified.
Consistency and determinism
LLM-based evaluation is not fully deterministic. The model settings are tuned to reduce variance, but edge cases — for example, an aggressive but technically legitimate sales email — may be evaluated differently across runs. Writing a precise prompt with concrete examples of what does and does not count as spam for your use case will help significantly.
Plain AI must be enabled
The AI prompt condition requires Plain AI to be active for your workspace. If it is disabled, all AI conditions evaluate to false and the workflow will not trigger.
Recommended approach
For most use cases, an AI prompt workflow condition is a solid first layer of spam defence for content-identifiable spam. We recommend:
- Start with a conservative prompt targeting obvious spam (outbound sales, phishing, clearly misdirected messages) and monitor results over the first week.
- Review threads that are being incorrectly ignored (false positives) and refine the prompt to exclude those patterns.
- If you have specific spam patterns unique to your product or audience, describe them explicitly — the more concrete examples you provide, the more consistent the model's behaviour will be.
- For spam that relies on attachments or header signals, consider handling that filtering upstream before it reaches Plain.
If you have questions about prompt structure or want help drafting your initial condition, get in touch — we're happy to help.