Trigger Nodes
Trigger nodes are entry points for automations. They fire when an external event occurs (webhook) or when a periodic check finds new data (polling).
Trigger modes
| Mode | Description | Use case |
|---|---|---|
webhook | External service sends HTTP POST to a generated URL | Shopify orders, GitHub events, Stripe payments |
polling | Worker periodically calls your handler to check for events | RSS feeds, API endpoints without webhooks |
both | Support both webhook and polling | Services that offer webhooks but need a fallback |
Create a project
lumio init my-trigger
When prompted:
- Category:
automation_node - Node type: Trigger
- Trigger mode: Choose webhook, polling, or both
Handler
Trigger handlers use defineAutomationTrigger with onWebhook and/or onPoll methods:
import { defineAutomationTrigger } from "@zaflun/lumio-sdk/server";
defineAutomationTrigger({
onWebhook: async (ctx) => {
const payload = ctx.webhookBody;
if (payload.event !== "order.created") {
return { fired: false };
}
return {
fired: true,
output: {
order_id: payload.id,
customer_name: payload.customer.name,
total: payload.total_price,
currency: payload.currency,
},
};
},
onPoll: async (ctx) => {
const lastCheck = await ctx.cache.get("last_check_ts");
const res = await ctx.fetch(
`https://api.example.com/events?since=${lastCheck}`
);
const events = await res.json();
if (events.length === 0) return null;
await ctx.cache.set("last_check_ts", Date.now().toString());
return {
fired: true,
output: events[0],
};
},
});
Return value
Both onWebhook and onPoll return a TriggerResult (or null):
| Field | Type | Required | Description |
|---|---|---|---|
fired | boolean | Yes | Whether the trigger should start the automation |
output | Record<string, unknown> | Only when fired: true | Event data. Must match the output_schema from the manifest. |
Returning null or { fired: false } silently ignores the event. No automation runs.
Webhook flow
When a user enables an automation with your trigger:
- Lumio generates a unique webhook URL and a 64-character hex secret
- The user configures the external service with this URL and secret
- External service sends
POST /v1/automation/webhooks/{extension_id}/{install_id}withX-Webhook-Secretheader - The API validates the secret and forwards to the Automation Worker
- Your
onWebhookhandler runs in V8 - If
fired: true, the automation engine runs the full flow
The webhook URL is displayed in the Automation Builder when the user selects a webhook trigger node.
Polling flow
For polling triggers, the Automation Worker runs your onPoll handler at the configured interval:
- User enables the automation
- The Worker starts a poll loop at
poll_interval_seconds(10-300, default 30) - Each iteration calls your
onPollhandler - If
fired: true, the automation engine runs the full flow - On disable, the poll loop stops
Use ctx.cache to track the last-checked timestamp and avoid re-processing events.
Manifest configuration
{
"node_type": "trigger",
"node": {
"trigger_mode": "webhook",
"poll_interval_seconds": null,
"input_schema": {
"type": "object",
"properties": {
"shop_domain": { "type": "string", "title": "Shop Domain" }
},
"required": ["shop_domain"]
},
"output_schema": {
"type": "object",
"properties": {
"order_id": { "type": "string" },
"customer_name": { "type": "string" },
"total": { "type": "number" },
"currency": { "type": "string" }
}
}
}
}
For polling triggers, set poll_interval_seconds to a value between 10 and 300.
Next steps
- Config Panel -- build a custom config UI
- Testing -- simulate webhooks and polls locally