> For the complete documentation index, see [llms.txt](https://docs.lassomoderation.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lassomoderation.com/automation-and-review/custom-moderation-rules.md).

# Custom Moderation Rules

Guide on rulesets, rules and conditions and how they can be used

Custom moderation rules automate moderation on the Lasso platform. Each rule combines a set of conditions with one or more actions. When a piece of content or a user matches the rule's conditions, Lasso applies the rule's actions, without a moderator having to look at it first.

> **Note**: Some of the conditions and actions described on this page are not available by default and can be enabled on request. If you don't see one in your dashboard, contact us.

There are three types of rules:

* **Content rules**: run on incoming content (messages, images, videos, audio). They can use both content conditions and conditions about the user who posted the content.
* **User rules**: run on users. They can use user conditions, such as signup date, reports received or content volume.
* **Routing queue rules**: decide which review queue a flagged item goes to. They can use review conditions (priority, policy, review type) as well as user and content conditions.

<figure><img src="https://720369-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEHJJyWYjMNTzFPyCUpfR%2Fuploads%2FZmF3VrNyMsxmpjd9tOdp%2FScreen%20Shot%202023-03-07%20at%2012.49.32.png?alt=media&#x26;token=bea06cb7-d64a-46a6-846d-4844f3f65a8e" alt="An example of a rule targeting images containing nudity"><figcaption><p>An example of a rule targeting images containing nudity</p></figcaption></figure>

### Anatomy of a rule

A rule consists of:

* **Name**: identifies the rule in the dashboard.
* **Notes** (optional): a short explanation of what the rule is for. Helpful when your team maintains many rules.
* **Conditions**: the criteria that must be met. By default a rule matches only when *all* of its conditions are met (they are combined with AND). See [Combining conditions with AND and OR](#combining-conditions-with-and-and-or) to match when any of them is met.
* **Actions**: what happens when the rule matches. See Actions below.
* **Status**: **Off**, **Monitor only** or **Live**. An off rule is not evaluated. A live rule takes its actions on every match. A monitor-only rule is evaluated and its matches are tracked, but its actions are not taken (see [Monitor-only rules](#monitor-only-rules)). New and imported rules start off, so you can review them before they take effect.

### How rules are evaluated

Rules are evaluated from top to bottom, in the order shown in the rules list. You can drag rules to reorder them, and order matters:

* When a rule's action is **allow** or **remove/ban**, a match stops evaluation. Rules below it are not evaluated for that item.
* When a rule's action is **flag**, evaluation continues. Multiple flagging rules can match the same item, and each can add its own policy, tags and priority.
* When a rule leaves the status unchanged, evaluation continues too. The rule applies its strike and tags once per item and is not applied to that item again, also not after a moderator decision. A content rule that strikes the user does so once for each piece of content that matches.
* A rule that has already been applied to an item is not applied again.
* Decisions made by a human moderator take precedence. If a moderator has removed an item, rules will not overrule that decision.

For routing queue rules, the first matching rule wins and determines the queue.

[Monitor-only rules](#monitor-only-rules) are the exception to the order: they never stop evaluation, and they are evaluated even when a rule above them stopped it.

#### Confirming a rule before it goes live

When you enable or update a rule, Lasso shows a confirmation step that previews how the rule would have matched against your recent content or users, including match counts and percentages. This lets you catch a rule that matches far more (or less) than you intended before it starts taking action.

To try out conditions on recent content before you create or change a rule, use [Research](https://docs.lassomoderation.com/automation-and-review/research.md).

### Monitor-only rules

A monitor-only rule is evaluated like any other enabled rule, but its actions are never taken. Use it to see how often a new rule would match on your live traffic before you let it act. For example, monitor a stricter image label threshold for a week, look at what it matched, and then switch it to live.

To make a rule monitor-only, open the rule, click **Edit rule** and set **Status** to **Monitor only**. Set it to **Live** when you want the rule to take its actions. The switch in the rules list turns a rule on or off and keeps its mode: a monitor-only rule switched back on stays monitor-only.

{% hint style="info" %}
A monitor-only rule does not change the item's status, add tags, give strikes, remove content or route to a queue, so no webhooks are sent for its matches.
{% endhint %}

How a monitor-only rule behaves:

* **It sees all traffic**: it is evaluated even when a rule above it matched and stopped evaluation, so its numbers are not limited to the items that got past your other rules. The one exception is items a moderator removed: no rules run on those.
* **It doesn't affect other rules**: a match does not stop evaluation, and the rules below it run as usual.
* **It counts as no match**: an item that only matches monitor-only rules is treated as not matching any rule.
* **The counts are evaluations, not unique items**: when the same item is checked again (for example after an update or a report), it is counted again.

Monitor-only rules show a **Monitor** badge in the rules list, and you can filter the list on **Monitor only**. On the rule's page, the **Activity** tab shows how many items were evaluated and matched over time, and the items it matched.

{% hint style="warning" %}
📷 Screenshot placeholder: a rule's page with the **Monitor only** badge next to its name and the **Activity** tab open, showing the Evaluated and Matched charts.
{% endhint %}

Monitor-only rules use the same conditions as live rules, including AI and image analysis, so they are not free to evaluate. Switching a rule between monitor-only and live is recorded in the rule's version history.

### Actions

Actions run when the rule's conditions are met.

* **Change status**: sets the item's moderation status to **allowed**, **flagged** or **removed** (for users: **banned**). The exact wording of these statuses can be customized per dashboard. Remove the status change with the **X** next to it to only strike or tag; add it back with **Change content status** (or **Change user status**). Such a rule needs at least a strike or a tag. New content that no rule gives a status still becomes **allowed**, as it does when no rule matches.
* **Policy category**: categorizes the action under one of your policies. This is how you track which policy an automated action was taken under, and it is included in webhooks and analytics. Depending on your dashboard settings, a policy can be required for flag/remove actions. You can also add extra policy information as free text.
* **Priority**: shown when the action is *flag*. Sets the review priority of the flagged item: urgent, high, medium (default), low or very low. Routing queue rules can use this priority to route items to different queues.
* **Strike user**: give the user a strike as part of the action. Two variants:
  * **Strike**: adds a strike only if the user has no active strike yet.
  * **Add strike**: always adds a strike, even if the user already has one.
* **Add tags**: add tags to the content and/or the user when the rule matches. Useful for building segments, filtering queues, or feeding follow-up rules that use the *Content tags* / *User tags* conditions.
* **Hide all content** (user rules with a *ban* action): when a user is banned by the rule, all of their existing content is removed as well. You can select a separate policy category for the removed content.
* **Route to queue** (routing queue rules): sends matching items to the selected review queue.

Rule actions trigger the same webhooks as manual moderator actions, so your platform is notified of status changes, strikes and tag updates made by rules.

### Conditions

A rule can have one or more conditions, and conditions from different categories below can be combined. For example, to catch potential spam you can combine *Signed up* (in the last 10 minutes) with *User's content volume* (more than 20 messages).

<figure><img src="https://720369-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEHJJyWYjMNTzFPyCUpfR%2Fuploads%2FOeKJ8SQIfuiYiSXYL5rV%2FScreen%20Shot%202023-03-06%20at%2017.27.51.png?alt=media&#x26;token=591677a6-e598-446f-afab-8cad0e17e40f" alt=""><figcaption><p>Example of a set of conditions targeting recently signed up users that have sent over 20 flagged or removed messages</p></figcaption></figure>

#### Combining conditions with AND and OR

Between every two conditions the editor shows how they combine: **AND** (every condition must match) or **OR** (any condition can match). Hover the connector and pick the other option to switch it. All connectors at the same level switch together, so a list of conditions is either all AND or all OR.

To mix the two, use a group. Click **Add group** to add a box of conditions with its own AND/OR connector, and **Add condition to group** to add more conditions to it. The rule treats the whole group as one condition. For example, to catch slurs and hate speech, but only from new accounts:

* A group with *Text* (contains any word from your slur list) **OR** *AI Models* (Hate Speech, is a violation)
* **AND** *Signed up* (in the last 7 days)

This rule matches a message from a new account that either contains a word from the list or is a violation according to the Hate Speech model. Without groups you would need two rules that each repeat the signup condition.

A few things to keep in mind:

* A group cannot contain another group.
* **Ungroup** removes the box and keeps its conditions in place. The **×** on a group removes the group together with its conditions.
* When a rule matches through an OR, the matched words and labels shown on the item come from the conditions that made it match. Conditions in a branch that did not match are not shown, even if one of them matched on its own.
* The rule's page and its version history show how the conditions combine. A change that only moves a condition into or out of a group, or switches AND and OR, is recorded as a new version and goes through the confirmation step like any other change.

Every condition below lists what it checks and the options you can configure.

#### Score comparisons

Conditions that use an AI score compare it with **more than** or **less than** a likelihood you set (0-100%):

* **Both are strict**: a score exactly equal to the likelihood you set does not match.
* **More than** matches when any of the selected scores is above the likelihood. **Less than** only matches when all of them are below it.
* **A score that was never computed does not match either way**, for example when an item was never analyzed by that model.

#### Text conditions

* **Text**: matches words, phrases, URLs, phone numbers or email addresses in the text. Lasso also extracts text from images, videos and audio, and you choose which of these sources the condition applies to. Matching options:

  * **Contains any word / not contains any word**: matches when the text contains one of your word list entries as a whole word, bounded by spaces, punctuation or the start/end of the text. The list entry "ball" matches "nice ball!" but not "football" or "ballroom". Use this for words that are only a problem on their own: an entry like "ass" won't match "class" or "grass". List entries can also be phrases containing spaces or special characters, such as "free money" or "sh\*t", and these match as a whole phrase.
  * **Contains part of any word / not contains part of any word**: matches when a list entry appears anywhere in the text, including inside longer words. The list entry "ball" also matches "football" and "ballroom". This casts a wider net and is harder to evade with creative spelling, but pick entries with care: short entries can match inside innocent words.
  * **Contains at least X words** and **contains part of any word at least X times**: like the above, but the item must contain a minimum number of (partial) matches. Useful for tolerating a single borderline word while catching repeated use.
  * **Contains regex / not contains regex**: matches when the text matches (or matches none of) the patterns in one of your regex lists, for advanced cases that word lists can't express.
  * **Contains a URL / contains any URL / not contains any URL**: detect any link, or match links against one of your domain lists (for example an allowlist of your own domains).
  * **Contains a phone number / contains any phone number / not contains any phone number**: detect any phone number, or match against a phone number list.
  * **Contains an email / not contains an email**: detect email addresses in the text.

  Word matching is case-insensitive. Lasso also matches against a normalized version of the text: accents and look-alike characters are converted to their plain equivalents (for example "bäll", or a Cyrillic "а" styled to look like a Latin "a") and invisible characters are stripped, so common tricks to sneak words past a filter still match.
* **Text length**: the number of characters in the text, longer or shorter than a value you set. For example, flag messages over 300 characters to catch copy-paste spam.
* **Special characters in text**: the number of special characters (anything that is not a letter, number or space). Useful against zalgo text, ASCII art and other obfuscation.
* **Duplicate messages**: matches when the same user has sent the same exact text a minimum number of times within the recent period. A classic spam signal.
* **Language**: the detected language of the text, is (or is not) in a list of languages you select. For example, flag content in languages your moderation team doesn't cover.
* **AI Models**: the verdict of Lasso's default AI models for text (such as Harassment & Bullying, Hate Speech or Scams & Spam) and of any AI models Lasso set up for your platform. Select one or more models and match on their verdict: *is a violation* or *is not a violation*. Some older models return a likelihood instead, which you [compare](#score-comparisons) to a threshold. With more than one model selected, choose how many of them must match: *any* (the default), *all* or *none* of them, or *at least*, *exactly* or *at most* a number of them. A model that has no result for the content never counts as a match, and *none* and *at most* only match once every selected model has a result.
* **AI Scores** (deprecated): the toxicity, threat, identity attack and profanity scores, [compared](#score-comparisons) to a likelihood. These scores stop being available on December 31, 2026, after which rules that use them no longer match. See [Migrating from AI Scores](https://docs.lassomoderation.com/other/migrating-from-toxicity-scores.md) to replace them with AI models.
* **Topic**: the topic assigned to the content is (or is not) in a set of topics you select.

#### Image conditions

* **Image labels**: moderation labels (nudity, violence, drugs, weapons, etc.) that Lasso's AI detects in images. Select one or more labels and [compare their scores](#score-comparisons) to a likelihood. For example, remove images with a likelihood of more than 80% of containing explicit nudity, and flag those with more than 50%.
* **AI Models**: the verdict of AI image models Lasso set up for your platform, *is a violation* or *is not a violation*. Some older models return a likelihood instead, which you [compare](#score-comparisons) to a threshold. With more than one model selected, choose how many of them must match: *any* (the default), *all* or *none* of them, or *at least*, *exactly* or *at most* a number of them. A model that has no result for the content never counts as a match, and *none* and *at most* only match once every selected model has a result.
* **Custom image labels**: images do (or do not) contain one of your custom-trained labels, with a minimum likelihood.
* **Image type**: the image's file type is (or is not) in a set you select, for example to treat GIFs differently from photos.
* **Similar images**: the image is the same as, very similar to, or somewhat similar to images that were previously removed, or images posted by banned users. When a moderator removes an image, this condition lets a rule automatically catch reposts of it, including slightly edited versions.
* **Number of people in image(s)**: how many people are detected in the image, compared to a number you set. For example, on a profile photo, require exactly one person.
* **Content's age range**: the estimated age of people in the image, compared to the user's own age or to a custom age you set. For example, flag profile photos where the estimated age is below the user's registered age.
* **QR code**: the image does (or does not) contain a QR code. QR codes are a common way to smuggle links past text filters.
* **AI generated image**: the image declares in its metadata that it is fully or partly AI generated, from any metadata or only from a verified signature. See [AI Image Detection](https://docs.lassomoderation.com/content-analysis/ai-image-detection.md).
* **AI generated video**: the same check for videos, read from the original video file. See [AI Image Detection](https://docs.lassomoderation.com/content-analysis/ai-image-detection.md#videos).
* **Face recognition**: whether all faces in the image match the user's verified photo. Useful for profile photo verification flows.
* **Face close-up**: whether the image is (or is not) a close-up of a face, based on the percentage of the image the largest face covers (defaults to 7%).
* **Celebrity**: the image does (or does not) contain a recognized public figure, with a minimum confidence. Helps catch impersonation and fake accounts using celebrity photos.
* **CSAM**: the image matches (or does not match) known CSAM via industry hash-matching.

#### General content conditions

* **Content type**: the content has text, image(s), video(s) or audio. Best combined with other conditions, for example: flag all images posted by users who signed up within the last day.
* **Project**: the project the content belongs to is (or is not) in a set you select, so you can apply stricter rules to specific projects. (This condition uses whatever name you have given projects in your dashboard, for example "Category" or "Room".)
* **Content tags**: the content's tags are (or are not) in a set you select. Combine with the *Add tags* action to build multi-step rule flows.
* **Content status**: the content's current status is (or is not) allowed, flagged, removed or no status. Rules run when content is sent, so new content has no status yet: use *No status* to match only new content, or *is not* *No status* to match only content that is updated and sent again.

#### Report conditions

Available for both content and users:

* **# of times reported**: how often the item or user has been reported. You can count unique reporters or total reports, over all time or within a period. By default every report counts, and two filters narrow that down: count reports from **any user type** or only from **specific user types** (normal user, trusted user, moderator, admin), and count reports filed under **any policy** or only under **specific policies** (the policy category the reporter picked). Counting any user type also includes reporter types introduced later, so it is the safer default; a specific selection only ever counts the types you picked. For example, remove content reported by 3 or more unique users within 24 hours, or flag content after 2 reports under your harassment policy.
* **Reported by**: the type of user the report came from, is (or is not) one of: normal, trusted, moderator, admin. On workspaces with DSA compliance enabled, state actor is also available, so a rule can react to notices filed by authorities. A report from a moderator can be trusted more than one from a normal user, so you can act on it immediately.

User rules only:

* **# of reports made**: the number of reports the user has made, compared to a number you set. Useful for catching users who mass-report others in bad faith.

#### User conditions

These can be used in user rules, and in content rules to check the user who posted the content:

* **Name**: the user's name, with the same matching options as the *Text* condition (word lists, partial matches, regex). For example, flag users with offensive words in their name.
* **Status**: the user's moderation status is (or is not) allowed, flagged or banned. For example, flag all content posted by currently flagged users.
* **Type**: the user's type is (or is not) one of: normal, trusted, moderator, admin, testing (and, on workspaces with DSA compliance enabled, state actor). For example, skip moderation for your own moderators and admins.
* **Signed up**: how long ago the user signed up (more or less than a number of seconds, minutes, hours, days or weeks). New accounts are riskier, so many spam rules start here.
* **Signup method**: how the user signed up (email, phone, Google, Facebook, Apple, Twitter, etc.). Users signing up through SSO are less often spammers, so you could allow them without review.
* **Email domain**: the user's email domain, matched against one of your domain lists. For example, allow signups from your own company's domains without review, or flag domains you have seen abused before. For disposable email providers, use the *Email address* condition below instead of maintaining a list yourself.
* **Email address**: the user's email address is (or is not) a temporary email address, based on its domain. Lasso checks the domain against a continuously updated database of disposable email providers (mailinator.com, 10minutemail.com and similar services), so you don't have to keep a list up to date. For example, flag signups with a temporary email address so a moderator reviews them before they can post, or combine it with *Signed up* to catch throwaway accounts created for spam. Users without an email address never match. This condition is an add-on: if it shows **(Upgrade required)** in the condition list, contact us to enable it.
* **Location (country)**: the user's country is (or is not) in one of your location lists.
* **IP address**: the user's IP address is (or is not) in one of your IP lists.
* **Profile image**: the user does (or does not) have a profile image. Accounts without one are more often fake, so this combines well with other signals.
* **Number of strikes**: the user's strike count, compared to a number you set. For example, ban users who reach 3 strikes.
* **User tags**: the user's tags are (or are not) in a set you select.
* **User's project**: the project the user belongs to is (or is not) in a set you select.
* **User's content volume**: how much content the user has posted. Choose what to count (messages, images, videos, or all content), which moderation statuses to include, a comparison and number, and whether to count in total or within a period (up to 30 days). For example, flag users with more than 5 removed messages in the last 7 days.
* **Topic volume**: like content volume, but counted per topic. For example, flag users who posted more than 10 items in a sensitive topic.

#### Review conditions (routing queue rules)

Routing queue rules can additionally match on properties of the review itself:

* **Priority**: the review priority is (or is not) urgent, high, medium, low or very low. For example, route urgent items to a dedicated queue.
* **Review type**: the item under review is content or a user.
* **Policy category**: the policy the item was flagged under is (or is not) in a set you select. For example, route everything flagged under your child safety policy to a specialist queue.

#### Custom attribute conditions

Any custom attributes you send with your content or users show up as conditions automatically, named after the attribute. The available options depend on the attribute's type:

* **Number**: compared to a threshold (greater than, at least, less than, at most). For example, flag marketplace listings with a price above 10,000.
* **Text**: the same matching options as the *Text* condition, including your word lists.
* **True/false**: the attribute is true or is false. For example, only apply a rule when `is_verified` is false.
* **Choice (enum)**: the value is (or is not) in a set of the attribute's possible values.

See Custom attributes for how to send these with your content and users.
