# Rules

A rule starts work without you asking each time. You set when it runs and what happens, test it on recent events, and then turn it on.

Web version: https://www.svanja.com/docs/rules/

Without a rule, the assistant only works when you ask it to. A rule does the asking for you. You set when it starts, such as when an email asks for a price or every Friday afternoon, and what should happen next. From then on, it runs on its own, even while you're away.

A rule can sort mail without any AI. It can also draft a reply that waits for you, or start a task. A task is a job the assistant works on in the background (see [Tasks](https://www.svanja.com/docs/tasks/)). You'll find your rules under [Rules](https://app.svanja.com/rules) in the sidebar.

![The Rules list with four draft rules, the line 0 of 3 AI rules on your plan are on, and the buttons Import, Start from a sample and New rule](https://www.svanja.com/images/docs/rules/list.webp "Each rule shows what starts it, its state and its next run. The count at the top shows how many AI rules are on.")

## What is a rule?

A rule has three parts:

- **When** says what starts it.
- **Only if** narrows it down. This part is optional.
- **Do** says what happens.

For example: when mail arrives, only if the sender is not a client and asks for a price, draft a reply using my note on price questions.

At the bottom of the form, **In plain words** sums up the rule in a few sentences. It tells you whether the rule uses AI and what it can do without asking you.

## What can start a rule?

Under **When the rule starts**, you pick one of four kinds. Under **What happens**, you pick the exact event.

| Kind                  | Starts when                           | For example                                                          |
| --------------------- | ------------------------------------- | -------------------------------------------------------------------- |
| **Mail**              | An email arrives, is sent, or changes | Mail received, Snooze ended, Reminder due                            |
| **Schedule**          | At set times                          | Every week, First business day of the month, Once                    |
| **Svanja event**      | Something happens in Svanja           | File added to a Space, Task finished                                 |
| **Connected service** | A connected service sends an event    | Webhook received, from a [Custom API connection](https://www.svanja.com/docs/connections/) |

Mail rules need a [connected mailbox](https://www.svanja.com/docs/connecting-your-mailbox/). Until you have one, you can only save them as drafts. A schedule runs in the time zone you choose, and **Skip public holidays** leaves out German or US holidays.

## Start from a sample

A sample is a ready-made rule. Starting from one gives you a draft you can edit. Nothing runs until you enable it, and samples never send anything.

1. Open [Rules](https://app.svanja.com/rules).
2. Choose **Start from a sample**.
3. Pick a sample.
4. On the new draft, choose **Edit** and change what you need.
5. Choose **Save as draft**.

![The sidebar with Rules selected and the Rules list with the Start from a sample button](https://www.svanja.com/images/docs/rules/sample-1.webp "Open Rules in the sidebar. Start from a sample is above the list.")
![The Start from a sample window listing the eight samples, from File newsletters and notifications to Task assigned to me](https://www.svanja.com/images/docs/rules/sample-2.webp "Choose Start from a sample, then pick one of the eight samples, here Client reports a problem.")
![The new draft rule Client reports a problem with What this rule does and the buttons More, Edit and Enable](https://www.svanja.com/images/docs/rules/sample-3.webp "The sample is now a draft that does nothing yet. Choose Edit to change it.")
![The rule editor with When set to Mail and Mail received, the Only if filters and condition, and the Do section with the task and Draft a reply](https://www.svanja.com/images/docs/rules/sample-4.webp "Change what you need under When, Only if and Do.")
![The end of the rule editor with Notify me, the In plain words summary and the buttons Cancel, Save as draft and Save and enable](https://www.svanja.com/images/docs/rules/sample-5.webp "Check In plain words, then choose Save as draft.")

The eight samples are:

- File newsletters and notifications (no AI)
- Price questions from new contacts
- Client reports a problem
- Requests I email to myself (put in your own address first)
- Weekly status note
- Monthly briefing
- Summarize new files
- Task assigned to me (needs Asana, which can't be connected yet)

## Make your own rule

Choose **New rule** to open an empty form. Along with the three parts above, fill in:

- **Name**: so you can find the rule again.
- **Space**: the client Space the rule's tasks work with (see [Spaces](https://www.svanja.com/docs/spaces/)).
- **For**: **Just me**, or **My team** on the Team plan.

Under **Only if**, filters check simple facts, like **Sender is** or **Subject contains**. **Only if the assistant agrees that** takes a condition in your own words.

Under **Do**, choose what happens:

- **What should the assistant do?** Write it like a note to a colleague. Each run starts a task with it.
- **Draft a reply**: the draft waits in the conversation for you.
- **Organize the mail without AI**: move, label, assign, or snooze. These steps are free.

## Test a rule before you turn it on

A test shows what the rule would have done without changing anything.

1. Open the rule.
2. Under **More**, choose **Test on recent events**. For a schedule, it's **Test now**.
3. Choose **Test**.

The assistant checks events from the last 30 days and prepares previews for up to 10 matches. The **Tests** tab shows what matched and what the rule would have done. Nothing is sent, moved, or changed. The previews use a few credits. When the results look right, choose **Enable**.

## What happens after you turn it on?

Each run shows up on the **Runs** tab, with a link to its task. If a rule caught an email it shouldn't have, choose **This should not have matched** on that run, and the assistant adds a condition to a draft of the rule. Changes apply to new events only. The **History** tab keeps every saved version.

A rule never sends email on its own. When its task writes an email, your settings under [Settings, Assistant](https://app.svanja.com/settings/assistant) decide whether it goes out or waits for your OK. See [What the assistant may do](https://www.svanja.com/docs/what-the-assistant-may-do/).

## What do rules cost?

Credits are how you pay for the assistant's work. A rule that only organizes mail costs nothing. Every other rule uses AI, so each run uses credits. That includes a rule whose only AI part is an **Only if the assistant agrees that** condition. When your credits run out, these rules skip their runs, and you can run the missed ones later. See [Credits and prices](https://www.svanja.com/docs/credits-and-prices/).

The Free plan lets you have 3 AI rules turned on at once. Rules that only organize mail don't count toward that limit. Pro and Team plans have no limit.

## Related pages

- [Tasks](https://www.svanja.com/docs/tasks/)
- [Skills, tools and templates](https://www.svanja.com/docs/skills/)
- [Use case: email rules and automation](https://www.svanja.com/docs/use-cases/email-rules-and-automation/)
