# Automations

A rule tells Intray what to do with a conversation when something happens to it. Every rule has a trigger under **When**, optional conditions under **If**, and one or more actions under **Then**. When the trigger fires, Intray checks each published rule that uses that trigger, and every rule whose conditions match applies its actions. Any member of the workspace can create, edit, publish, and delete rules.

## Create a rule

<Steps>
  <Step title="Start a new rule">
    Open **Automations** and press **New rule**. Intray creates the rule as a
    draft and opens it in the builder. A draft does nothing until you publish
    it.
  </Step>
  <Step title="Name it">
    Enter a name of up to 100 characters. The name appears in the rule list and
    in the timeline of every conversation the rule acts on, so write what the
    rule does, for example "Billing questions".
  </Step>
  <Step title="Pick the trigger">
    Under **When**, choose **An email arrives**, **Status changes**, or **A
    label is added**.
  </Step>
  <Step title="Add conditions">
    Under **If**, press **Add condition** for each check. Choose **All match**
    when every condition must be true, or **Any match** when one is enough. A
    rule with no conditions runs every time its trigger fires.
  </Step>
  <Step title="Add actions">
    Under **Then**, press **Add action** for each thing the rule should do. A
    rule needs at least one action before you can publish it.
  </Step>
  <Step title="Save or publish">
    **Save** keeps the rule as a draft. **Publish** saves it and turns it on.
    The header shows **Unsaved** while you have changes. Leaving the page
    discards unsaved changes.
  </Step>
</Steps>

To turn a published rule off without deleting it, open the menu on its row in the rule list and choose **Unpublish**. The same menu has **Duplicate**, which is the quickest way to make a variation of an existing rule.

## Triggers

| Trigger          | Fires when                                                 |
| ---------------- | ---------------------------------------------------------- |
| An email arrives | Intray receives an email on a hosted or forwarded address  |
| Status changes   | A member changes the status of a conversation in the inbox |
| A label is added | A member adds a label to a conversation in the inbox       |

**Status changes** and **A label is added** fire for changes that a person makes in the inbox. They do not fire when a rule, the agent, or the Conversation API makes the change. This is how Intray prevents loops, and it means one rule cannot start another. If you want a label and a draft from the same email, put both actions in one rule.

Some conversations never fire **An email arrives**:

- A form submission created through the Conversation API. It creates a conversation without an inbound email.
- Mail that Intray reads from a connected mailbox over IMAP. Imported history and new mail from a connected mailbox both skip rules today.

## Conditions

Every condition can be reversed. Text conditions offer **is** and **is not**, and the two keyword conditions offer **contains** and **doesn't contain**.

| Condition        | Matches when                                                                      |
| ---------------- | --------------------------------------------------------------------------------- |
| Sender email     | The sender's address equals the value. Case is ignored                            |
| Sender domain    | The part of the sender's address after the @ equals the value                     |
| Inbox address    | The conversation belongs to the address you pick, such as support                 |
| Subject contains | The subject contains any of the keywords. Case is ignored                         |
| Body contains    | The text of the email contains any of the keywords. Case is ignored               |
| Has label        | The conversation has the label you pick                                           |
| Status           | The conversation's status is Todo, Snoozed, Done, or Spam                         |
| AI: Match if…    | A model reads the conversation and answers yes or no to the description you wrote |

Keywords are separated by commas, for example `urgent, asap, critical`, and a condition holds up to 20 of them. A rule holds up to 20 conditions.

### How AI match works

Write a description of the email you want to catch, in up to 2,000 characters. Intray sends the conversation and your description to a model, and the model answers yes or no. Customer text is passed to the model as data, so an instruction written inside an email does not change how the rule behaves.

Intray checks the other conditions first and calls the model only when the result still depends on it. With **All match**, the model is skipped when any other condition is false. With **Any match**, the model is skipped when any other condition is already true.

A good description names what the customer is asking for and gives the model a clear boundary. These two work well:

- "The customer asks about an invoice, a refund, or a charge on their card. Do not match a receipt or a payment notification sent by a billing system."
- "The customer is asking for a demo, a sales call, or a trial extension."

If the model call fails, the rule does not match and none of its actions run. Intray records the failure against the rule.

## Actions

| Action                | What it does                                                                        | Sends email on its own |
| --------------------- | ----------------------------------------------------------------------------------- | ---------------------- |
| Assign to             | Assigns the conversation to a teammate, or to **No one (unassign)**                 | No                     |
| Set status            | Sets Todo, Snoozed, Done, or Spam. Snoozed asks for a number of hours               | No                     |
| Set priority          | Sets the priority number. Lower is more urgent                                      | No                     |
| Apply label           | Adds a label. Skipped when the conversation already has the most labels it can hold | No                     |
| Remove label          | Removes a label                                                                     | No                     |
| Add internal note     | Adds a note to the timeline. Customers never see notes                              | No                     |
| Draft a reply with AI | Writes a reply and leaves it on the conversation for a teammate                     | No                     |
| Send auto-reply       | Sends the text you wrote to the customer                                            | Yes                    |

A rule holds up to 10 actions, with at most one **Draft a reply with AI** and one **Send auto-reply**.

### Draft a reply with AI

The draft appears on the conversation as **Agent drafted a reply**, with **Edit & use** and **Discard**. **Edit & use** copies it into your own reply, where you can change it before you send. Intray never sends an AI draft. You can add optional guidance for the draft, such as "offer a call".

The other actions in the rule apply first, and the draft arrives a moment later. If the model call fails, the other actions stay applied and no draft appears.

### Send auto-reply

This is the only action that sends email without a person reading it first. The reply goes to the customer from the shared address, and the conversation keeps its status. Intray skips the send in these cases:

- The email that fired the rule is itself an automatic reply.
- Your team's email is already the latest message in the conversation.
- An automated reply was already sent in the same conversation in the last 24 hours.

The auto-reply text holds up to 10,000 characters.

## How order works

Intray checks rules in the order of the rule list, from top to bottom, and it does not stop at the first match. Every matching rule applies its actions. When two rules set the same thing, such as the assignee or the status, the rule lower in the list runs later, so its value is the one that stays.

A rule that uses **AI: Match if…** waits for the model, so its actions can land after the actions of rules below it. A new rule is added at the bottom of the list. Intray checks at most 50 published rules per trigger.

## Worked rules

### Route press mail to one person

- **When** An email arrives
- **If** Inbox address is press
- **Then** Assign to the teammate who handles press, and Apply label Press

### Label and prioritize billing questions

- **When** An email arrives
- **If** All match: Inbox address is support, and AI: Match if… "The customer asks about an invoice, a refund, or a charge on their card. Do not match a receipt or a payment notification sent by a billing system."
- **Then** Apply label Billing, and Set priority 1

### Draft a reply for a common question

- **When** An email arrives
- **If** AI: Match if… "The customer cannot sign in or asks how to reset their password."
- **Then** Apply label Account access, and Draft a reply with AI with the guidance "Explain how to reset the password from the sign-in page"

The label and the draft are in one rule because a label that a rule applies does not fire **A label is added**.

### Snooze notifications that need no reply today

- **When** An email arrives
- **If** Any match: Sender domain is the domain your billing or monitoring system sends from, or Subject contains `receipt, payment received`
- **Then** Set status Snoozed for 24 hours

### Acknowledge new support mail

- **When** An email arrives
- **If** Inbox address is support
- **Then** Send auto-reply with the text "Thanks for writing. We have your message and will reply within one business day."

<Warning title="This rule sends without review">
  Every email that matches gets the reply, and nobody on the team reads it
  first. Keep the condition narrow, write a text that is true at any hour, and
  do not promise a response time your team cannot keep.
</Warning>

## See what a rule did

Each time a rule acts on a conversation, the conversation's timeline gets a line that names the rule and lists what it did, for example: Automation "Billing questions": labeled "Billing", priority → 1. When an auto-reply is held back by one of the checks above, the line says "autoresponder skipped (guard)". An AI draft also shows on the conversation as **Agent drafted a reply**.

Intray stores a record for every run that matched or failed, including AI failures. The app does not have a screen for that history yet, so the timeline is where you check a rule's work.

## Limits and known gaps

- Rules have no time condition, so a rule cannot tell working hours from nights and weekends.
- Rules do not run on mail from a connected mailbox, or on form submissions created through the Conversation API.
- A status change or a label made by a rule, the agent, or the API does not fire a trigger. Only a change made by a member in the inbox does.
- The rule list has no control for changing the order. A new rule goes to the bottom.
- There is no screen for a rule's run history.
- **Body contains** checks the text of the email that fired the rule. For the two other triggers it checks the conversation's preview text.
- A published rule needs at least one action. A rule allows up to 20 conditions, 10 actions, 20 keywords per condition, and 2,000 characters per AI description.
