# Custom scripts in email event rules

Custom conditions and script actions can extend email-event rules while following the same priority and cooldown controls.

*Release 3.3 · admin, developer*

**Settings › Events › Email Events**

## What it is

Email-event rules can use custom script conditions and actions as well as standard ticket actions. INSIDE checks the event, conditions, priority and cooldown before selecting a rule. Powerfront configures the custom processing for your website.

## Who uses it and why

Operators with the **Settings** role and **Events** permission use **Email Events** to control when ticket automation runs, subject to editing restrictions. Developers work with Powerfront when a business rule needs custom processing beyond the standard actions.

## Where to find it

Open **Settings › Events › Email Events**. The **Settings** role with **Events** permission can manage definitions, subject to editing restrictions. The **Manager** role can also see this screen, but visibility alone does not grant permission to save or delete definitions.

Custom script actions are not an option in the standard editor. Ask Powerfront to configure and verify them.

## How it works

1. A ticket event causes INSIDE to check rules assigned to that event. The editor lists **New Ticket Created**, **Ticket Closed**, **New Email**, **Status Changed** and **Time Based Trigger**.
2. INSIDE checks rules in ascending **Priority** order. Rules without a priority come last; equal priorities use the rule ID order.
3. A rule must be enabled, have actions, pass its conditions and be outside its cooldown.
4. INSIDE starts the selected rule's actions and stops looking for another matching rule for that event occurrence.

A custom condition can decide whether a rule matches. A custom script action queues processing in the background. Selecting the rule does not confirm that the script's business action has finished successfully.

Cooldown applies to the rule and conversation together. Another conversation can still trigger the same rule. Time-based conditions also track relevant changes so that an unchanged ticket does not repeatedly trigger the same timed condition.

## Configure it

Agree the trigger, conditions and expected outcome with Powerfront before adding custom processing. Powerfront must confirm the script is available for your website and test its activation, including after a restart.

Use **Priority** values from 1 to 999999999, or leave the field empty. Enter **Cooldown** in seconds. New rules created through the editor start disabled; use **Enabled** when the rule is ready.

The editor requires a name, description, cooldown, at least one event, at least one condition and at least one action. Ask Powerfront before saving a custom script rule through the standard editor, which only offers standard actions.

### Fields

| Field | Where | Required | What it is for |
|---|---|---|---|
| Name | Settings › Events › Email Events | Yes | Identifies the rule; the editor requires a unique, non-empty name. |
| Description | Settings › Events › Email Events | Yes | Explains the rule's purpose. |
| Cooldown | Settings › Events › Email Events | Yes | Sets the waiting period in seconds before the same rule can run again for the same conversation. Zero applies no cooldown. |
| Priority | Settings › Events › Email Events | No | Orders competing rules. Lower numbers run first; an empty value places the rule after numbered rules. |
| Test for this Event | Settings › Events › Email Events | Yes | Selects one or more ticket events that cause the rule to be checked. |
| Actions | Settings › Events › Email Events | Yes | Defines what happens when the conditions match. The editor provides standard actions; custom script actions need Powerfront configuration. |
| Debug | Settings › Events › Email Events | No | Enables additional diagnostic information while testing. This control is visible to Developer accounts with access to the screen and resets after a server restart. |
| Enabled | Settings › Events › Email Events | No | Controls whether the saved rule participates in event processing. |

### Permissions

| Permission | Lets you |
|---|---|
| Settings | Allows access to Email Events and saving or deleting rules when Events is permitted and View Only is off. |
| Events | Allows an operator with Settings to save and delete event definitions when View Only is off. |
| Manager | Allows access to Email Events. This role alone does not grant permission to save or delete rules. |
| Developer | Shows the temporary Debug control when the account also has access to Email Events. |

## Limits and good to know

- This release's standard conversation triggers apply to email. Use **Visitor Events** for visitor-engagement rules.
- Migrated conversations are skipped by these event triggers.
- An earlier matching rule can prevent a later rule from running, even if both sets of conditions match.
- Scripts must be available globally or for the current website. Another website's script cannot be selected as the action.
- **Debug** is temporary and resets after a server restart. It is visible to accounts with the **Developer** role and either the **Settings** or **Manager** role for screen access.
- Background script errors do not make INSIDE select the next rule as a replacement.

## Depends on and works with

### This feature uses

- **Requires** [Email ticket handling and statuses](CHN-026.md): Custom email-event rules run only against email tickets and their lifecycle events.
- **Requires** [Custom scripts managed by Powerfront](EXT-015.md): Script conditions and actions depend on scripts configured by Powerfront.
- **Configured in** [Roles and permissions](ADM-008.md): Settings, Events and editing restrictions govern management of the visible rules.
- **Configured in** [Email event rules and actions](ENG-022.md): Email Events defines the triggers, conditions, priority and cooldown for custom script rules.

### Used by

- **Enhances** [Email event rules and actions](ENG-022.md): Developer extensions can add scripted event behaviour beyond the standard action choices.

## FAQ and troubleshooting

### Why did only one matching rule run?

INSIDE stops selecting rules after the first rule is accepted. Check **Priority**, including rules with the same priority and rules without a number.

### Why does the rule work for one ticket but not another?

Check the selected event, conditions and cooldown for that conversation. Migrated conversations are excluded from the reviewed conversation triggers.

### Where do I select a custom script action?

The standard editor does not offer it. Ask Powerfront to configure the custom action and confirm that it runs in your setup.

### Why was the rule selected but the external change did not happen?

Script actions run in the background. Ask Powerfront to check the script result and availability, particularly after rule creation or a server restart.

### Why did Debug switch off?

It resets after a server restart. Enable it again only when further diagnostic testing is needed.
