# Manual / Ad-Hoc Trigger

> Allows a workflow to be started manually by a user or administrator.

Source: https://docs.sommatic.ai/en/nodes/manual.trigger/

- Slug: `manual.trigger`
- Family: Triggers
- Version: 1.0.0
- Status: Available
- Execution: sync

Allows a workflow to be started manually by a user or administrator.

This trigger defines the "Start Button" for a workflow. It is commonly used for testing, debugging, or workflows that require explicit human initiation (e.g., "Run End of Month Report").

**Features:**
- **Form Input:** Can define a schema for the input payload the user must provide when clicking "Run".
- **Testing:** Ideal for validating logic with disparate test datasets.

**Use Cases:**
- Launching a one-off database migration script.
- Testing a new workflow with mock customer data.

## Configuration

- `payload_template` (object, optional): Auto-fills the manual input form for convenience.

Its configuration shows the shared execution settings, but this node does not apply retries (`retryOnFail`, `maxTries`) yet. `continueOnFail` is not applied by any node.

## Output ports

- `out` (default): Started
- `error`: Error

## Output contract

- `triggered_by` (string, optional): User who clicked Run.
- `timestamp` (string, optional)
- `manual_payload` (object, optional): Data entered by user.

## In expressions

What a later node can read from this node's output with `$("Manual / Ad-Hoc Trigger").item.json.<path>` (write your node's label instead of `Manual / Ad-Hoc Trigger`). **Editor** marks the paths the workflow editor suggests under Previous Nodes (the output contract); **Worker** marks the paths the worker really returns through `out`, from the output shown in Ports.

- `$("Manual / Ad-Hoc Trigger").item.json.triggered_by` (string) = `"manual"`: User who clicked Run.
- `$("Manual / Ad-Hoc Trigger").item.json.timestamp` (string) = `"2026-11-26T09:15:42.008-05:00"`
- `$("Manual / Ad-Hoc Trigger").item.json.manual_payload` (object) = `{…}`: Data entered by user.
- `$("Manual / Ad-Hoc Trigger").item.json.manual_payload.period` (string) = `"2026-10"` (Not suggested by the editor)
- `$("Manual / Ad-Hoc Trigger").item.json.manual_payload.region` (string) = `"north"` (Not suggested by the editor)
- `$("Manual / Ad-Hoc Trigger").item.json.period` (string) = `"2026-10"` (Not suggested by the editor)
- `$("Manual / Ad-Hoc Trigger").item.json.region` (string) = `"north"` (Not suggested by the editor)


## How it works

Entry node for workflows started by hand or by an execution request. It merges `payload_template` with the input, and outputs the result both under `manual_payload` and at the root, with `triggered_by` and `timestamp`.

1. What starts it: a run from the editor or an execution request with an input. A run of the draft is a test run; a run of a published version is a production run.
2. Resolves the node config and merges `{ ...payload_template, ...input }`: input keys win over the template.
3. Outputs `{ triggered_by, timestamp, manual_payload, ...merged }` on `out`.

## In a workflow

### Node

```json
{
  "node_id": "node-start",
  "label": "Run report",
  "operator_slug": "manual.trigger",
  "operator_version": "1.0.0",
  "config": {
    "payload_template": {
      "region": "north"
    }
  }
}
```

### Envelope

```json
{
  "ok": true,
  "data": {
    "triggered_by": "manual",
    "timestamp": "2026-11-26T09:15:42.008-05:00",
    "manual_payload": {
      "region": "north",
      "period": "2026-10"
    },
    "region": "north",
    "period": "2026-10"
  },
  "port": "out"
}
```

## Output ports (behaviour in the code)

### `out`

Always, unless an unexpected exception occurs.

```json
{
  "triggered_by": "manual",
  "timestamp": "2026-11-26T09:15:42.008-05:00",
  "manual_payload": {
    "period": "2026-10",
    "region": "north"
  },
  "period": "2026-10",
  "region": "north"
}
```

### `error`

Only on an unexpected exception; the output is `{ error, response }`. Not reachable in normal use.

```json
{
  "error": "<exception message>",
  "response": null
}
```

## Behaviour in the code

- `payload_template`: Default values merged under the input. If a key collides with `triggered_by`, `timestamp` or `manual_payload`, the merged value overwrites them at the root.

## Notes and limits

- `triggered_by` is always `manual`: the user who started the run is not passed to the node.
- `timestamp` is the orchestrator's local time in ISO format.
- When the workflow has stored trigger or key-value state, the backend adds `$trigger_state` / `$kv_state` to the input, so they also appear in the output.
- With sample data the engine skips the node and passes the sample input on `out` as is, without `triggered_by`, `timestamp` or `manual_payload`.


## Contracts (JSON Schema)

### All (`*.definition.js`)

```json
{
  "slug": "manual.trigger",
  "name": "Manual / Ad-Hoc Trigger",
  "category": "triggers",
  "version": "1.0.0",
  "description": "Allows a workflow to be started manually by a user or administrator.\n\n  This trigger defines the \"Start Button\" for a workflow. It is commonly used for testing, debugging, or workflows that require explicit human initiation (e.g., \"Run End of Month Report\").\n\n  **Features:**\n  - **Form Input:** Can define a schema for the input payload the user must provide when clicking \"Run\".\n  - **Testing:** Ideal for validating logic with disparate test datasets.\n\n  **Use Cases:**\n  - Launching a one-off database migration script.\n  - Testing a new workflow with mock customer data.",
  "capabilities": [
    "testing",
    "ad-hoc",
    "manual",
    "ui"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "payload_template": {
        "type": "object",
        "title": "Default/Sample Payload",
        "description": "Auto-fills the manual input form for convenience."
      },
      "execution": {
        "type": "object",
        "title": "Execution Settings",
        "properties": {
          "alwaysOutputData": {
            "type": "boolean",
            "title": "Always Output Data",
            "description": "Always output data, even on error (if configured).",
            "default": false
          },
          "retryOnFail": {
            "type": "boolean",
            "title": "Retry On Fail",
            "description": "Retry the execution if it fails.",
            "default": false
          },
          "maxTries": {
            "type": "integer",
            "title": "Max Retries",
            "description": "Number of retries.",
            "default": 3,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "waitBetweenTries": {
            "type": "integer",
            "title": "Wait Between Retries (ms)",
            "default": 1000,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "continueOnFail": {
            "type": "boolean",
            "title": "Continue On Fail",
            "description": "Do not crash workflow on error.",
            "default": false
          },
          "timeout_ms": {
            "type": "integer",
            "title": "Timeout (ms)",
            "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
            "default": 300000
          }
        }
      }
    }
  },
  "input_contract_schema": null,
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "triggered_by": {
        "type": "string",
        "description": "User who clicked Run."
      },
      "timestamp": {
        "type": "string",
        "format": "date-time"
      },
      "manual_payload": {
        "type": "object",
        "description": "Data entered by user."
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Started",
      "is_default": true
    },
    {
      "port_id": "error",
      "label": "Error"
    }
  ],
  "execution_mode": "sync",
  "tags": [
    "test",
    "manual",
    "debug",
    "start"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_sommatic_ai",
    "profile": {
      "name": "Sommatic AI",
      "verified": true,
      "url": "https://me.veripass.com/sommatic",
      "logo_url": null
    }
  }
}
```

### config_schema

```json
{
  "type": "object",
  "properties": {
    "payload_template": {
      "type": "object",
      "title": "Default/Sample Payload",
      "description": "Auto-fills the manual input form for convenience."
    },
    "execution": {
      "type": "object",
      "title": "Execution Settings",
      "properties": {
        "alwaysOutputData": {
          "type": "boolean",
          "title": "Always Output Data",
          "description": "Always output data, even on error (if configured).",
          "default": false
        },
        "retryOnFail": {
          "type": "boolean",
          "title": "Retry On Fail",
          "description": "Retry the execution if it fails.",
          "default": false
        },
        "maxTries": {
          "type": "integer",
          "title": "Max Retries",
          "description": "Number of retries.",
          "default": 3,
          "displayOptions": {
            "show": {
              "retryOnFail": [
                true
              ]
            }
          }
        },
        "waitBetweenTries": {
          "type": "integer",
          "title": "Wait Between Retries (ms)",
          "default": 1000,
          "displayOptions": {
            "show": {
              "retryOnFail": [
                true
              ]
            }
          }
        },
        "continueOnFail": {
          "type": "boolean",
          "title": "Continue On Fail",
          "description": "Do not crash workflow on error.",
          "default": false
        },
        "timeout_ms": {
          "type": "integer",
          "title": "Timeout (ms)",
          "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
          "default": 300000
        }
      }
    }
  }
}
```

### output_contract_schema

```json
{
  "type": "object",
  "properties": {
    "triggered_by": {
      "type": "string",
      "description": "User who clicked Run."
    },
    "timestamp": {
      "type": "string",
      "format": "date-time"
    },
    "manual_payload": {
      "type": "object",
      "description": "Data entered by user."
    }
  }
}
```

### ports

```json
[
  {
    "port_id": "out",
    "label": "Started",
    "is_default": true
  },
  {
    "port_id": "error",
    "label": "Error"
  }
]
```
