# Automations

Synthesise AI features a powerful visual automation engine that allows users to chain together intelligent triggers and actions inside their product workflows. Automations are the bridge between user behavior and system response, enabling seamless personalization, monetization, and engagement—without writing code.

***

#### 1. Automation Architecture

**1.1 Core Design**

Automations are compiled into a lightweight rule engine that listens for defined events (e.g., purchase, quiz completion, drop-off) and responds with one or more predefined actions (e.g., send email, issue NFT, update state).

Each automation includes:

* **Trigger** – the system event to listen for
* **Condition** – optional logic (time delay, user segment)
* **Action** – system behavior (send email, log event, mint token)

**1.2 Rust Struct Representation**

```rust
enum Trigger {
    Purchase(String),
    DropOff,
    Completion,
}

enum Action {
    Email(String),
    Webhook(String),
    IssueToken(String),
}

struct Automation {
    trigger: Trigger,
    action: Action,
}
```

***

#### 2. Visual Builder

Users can build automations using a no-code canvas interface. Nodes represent events, conditions, and actions. Paths can be dragged to connect logic visually.

Common visual flows:

* Purchase → Delay (24h) → Email: “Welcome Module”
* Abandon Cart → Email: “Reminder” → Delay (6h) → SMS: “Still Interested?”
* Module Complete → Issue Token → Unlock Bonus

The visual flow is compiled behind the scenes into a Rust automation object.

***

#### 3. Event System

Synthesise’s automation engine is event-driven. It listens to an internal event bus across the application (e.g., purchases, interactions, completions) and matches these against active automation rules.

Example event consumption:

```rust
fn dispatch(event: Trigger) -> Option<Action> {
    match event {
        Trigger::Purchase(product) => Some(Action::Email(format!("Thanks for purchasing {}", product))),
        Trigger::DropOff => Some(Action::Email("Reminder to complete your course".to_string())),
        _ => None,
    }
}
```

***

#### 4. Supported Actions

| Action Type    | Description                                            |
| -------------- | ------------------------------------------------------ |
| `Email()`      | Sends templated email through integrated mail provider |
| `Webhook()`    | Calls external system with product metadata            |
| `IssueToken()` | Mints tokenized rewards or NFTs                        |
| `Delay()`      | Defers next step by minutes/hours/days                 |
| `Split()`      | Randomizes or segments flow paths                      |
| `Log()`        | Saves output to analytics or CRM system                |

***

#### 5. Advanced Use Cases

**5.1 Dynamic Segmentation**

Users can build dynamic audience segments (e.g. “clicked but didn’t buy,” “watched 75%”) and create tailored follow-up flows per segment.

**5.2 Recurring Sequences**

Automations can be looped for recurring billing reminders, educational check-ins, or progressive onboarding modules.

**5.3 NFT Certificate Distribution**

Issue personalized, verifiable certificates for course completion:

```rust
fn issue_certificate(user_id: &str) -> Action {
    Action::IssueToken(format!("certificate_for_{}", user_id))
}
```

***

#### 6. Deployment & Execution

Automations are stored as JSON payloads in the database, compiled at runtime into action trees, and executed by a multi-threaded scheduler in Rust.

```rust
fn run_automation(auto: Automation) {
    match auto.action {
        Action::Email(body) => println!("Sending email: {}", body),
        Action::IssueToken(token) => println!("Minting token: {}", token),
        _ => println!("Unhandled action"),
    }
}
```
