# Triggers (/docs/triggers)





Triggers define how a flow starts. Flowlib includes three built-in trigger types, plus webhook triggers via the [Webhooks Plugin](/docs/plugins/webhooks).

## Manual trigger [#manual-trigger]

The default trigger type. Flows with a manual trigger are started from the UI "Run" button, the REST API, or programmatically.

| Param           | Description                                                                                                                                                           |
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `defaultInputs` | JSON object of default key/value pairs used when the flow is run manually. When triggered from code, the caller's inputs take precedence (merged on top of defaults). |

Downstream nodes access trigger outputs via `{{ manual_trigger.variableName }}`.

### API execution [#api-execution]

```bash
curl -X POST http://localhost:3000/flowlib/flows/{flowId}/run \
  -H "Content-Type: application/json" \
  -d '{ "inputs": { "topic": "Machine learning" } }'
```

### Programmatic execution [#programmatic-execution]

```ts
const core = flowlib.getCore();
const result = await core.runs.start(flowId, {
  topic: 'Machine learning',
});
```

## Cron trigger [#cron-trigger]

Schedule flows to run on a recurring basis using cron expressions.

| Param          | Description                                                   |
| -------------- | ------------------------------------------------------------- |
| `expression`   | Cron expression (e.g., `0 9 * * MON-FRI` for weekdays at 9am) |
| `timezone`     | IANA timezone (e.g., `America/New_York`)                      |
| `staticInputs` | Fixed input values passed to the flow on each run             |

Downstream nodes access the scheduled time via `{{ cron_trigger.scheduledTime }}`.

### Common cron expressions [#common-cron-expressions]

| Expression        | Schedule                |
| ----------------- | ----------------------- |
| `* * * * *`       | Every minute            |
| `0 * * * *`       | Every hour              |
| `0 9 * * *`       | Daily at 9:00 AM        |
| `0 9 * * MON-FRI` | Weekdays at 9:00 AM     |
| `0 0 1 * *`       | First day of each month |

<Callout type="info">
  Cron scheduling is enabled by default. Disable it globally by setting `triggers.cronEnabled:
    false` in your [config](/docs/reference/configuration).
</Callout>

<Callout type="info">
  Next.js deployments on Vercel need one dedicated Flowlib cron route, configured in `vercel.json`,
  to drive scheduled work. Use a single Flowlib cron endpoint such as `/api/flowlib/cron`; it will
  execute due Flowlib cron triggers and other background maintenance for the app.
</Callout>

## Webhook trigger [#webhook-trigger]

Trigger flows from external HTTP requests. Requires the [Webhooks Plugin](/docs/plugins/webhooks).

```ts title="config"
import { webhooks } from '@flowlib/webhooks';

const config = {
  // ...
  triggers: {
    webhookBaseUrl: 'https://your-app.com/flowlib',
  },
  plugins: [webhooks()],
};
```

Once configured, each flow with a webhook trigger gets a unique URL:

```
POST https://your-app.com/flowlib/webhooks/{webhookId}
```

The request body is passed as the trigger output, available to downstream nodes via template expressions.

See [Webhooks Plugin](/docs/plugins/webhooks) for details.

## Input node vs trigger [#input-node-vs-trigger]

The **Input** node (`core.input`) and **Manual Trigger** node (`trigger.manual`) serve similar purposes — they define flow inputs. The key differences:

|                 | Input Node                                       | Manual Trigger                       |
| --------------- | ------------------------------------------------ | ------------------------------------ |
| Purpose         | Define flow input schema with types and defaults | Entry point that initiates execution |
| Can be mid-flow | Yes                                              | No (always first)                    |
| UI behavior     | Shows input form when running                    | Shows input form when running        |
| Reference ID    | `input`                                          | `manual_trigger`                     |

For most flows, you'll use either one — they're largely interchangeable for simple use cases. Input nodes are more flexible because they can appear anywhere in the graph.
