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
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 want the opposite behavior. Instructing the model to err on the side of flagging uncertain cases catches more spam, at the cost of more false positives. 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 recognizable 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 analyzed
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 way to evade text-based filters, the model has almost no 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 reduces this variance.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 behavior will be.
- For spam that relies on attachments or header signals, consider handling that filtering upstream before it reaches Plain.

