Werkende voorbeelden

Autoflow voorbeelden (copy/paste basis)

Hieronder staan complete flowdefinities die aansluiten op het huidige schema met id, sourceId, targetId en correcte branches.

1. Wekelijkse omzetvergelijking met if/else alert

Doel: vergelijk de laatste 7 dagen met de 7 dagen daarvoor. Als omzet daalt, stuur warn; anders info.

{
  "id": "auto_weekly_revenue_compare",
  "name": "Weekly Revenue Compare",
  "description": "Waarschuwing wanneer omzet lager is dan vorige week",
  "nodes": [
    {
      "id": "trigger_weekly",
      "type": "trigger",
      "title": "Wekelijks maandag 08:00",
      "position": { "x": 120, "y": 120 },
      "trigger": { "schedule": "0 8 * * 1" }
    },
    {
      "id": "ds_testdata",
      "type": "datasource",
      "title": "Facturen",
      "position": { "x": 420, "y": 120 },
      "data": { "dataSourceId": "testdata" }
    },
    {
      "id": "flt_current",
      "type": "filter",
      "title": "Huidige 7 dagen",
      "position": { "x": 720, "y": 40 },
      "filter": {
        "rules": [
          { "field": "status", "type": "text", "values": ["paid"], "enabled": true },
          { "field": "invoice_date", "type": "date", "datePreset": "past7", "enabled": true }
        ]
      }
    },
    {
      "id": "flt_previous",
      "type": "filter",
      "title": "Vorige 7 dagen",
      "position": { "x": 720, "y": 210 },
      "filter": {
        "rules": [
          { "field": "status", "type": "text", "values": ["paid"], "enabled": true },
          { "field": "invoice_date", "type": "date", "datePreset": "past7_shift1w", "enabled": true }
        ]
      }
    },
    {
      "id": "metric_revenue_current",
      "type": "metric",
      "title": "Omzet huidig",
      "position": { "x": 1040, "y": 40 },
      "metric": {
        "key": "revenue_current",
        "label": "Omzet huidig",
        "aggregation": "sum",
        "measureField": "line_total"
      }
    },
    {
      "id": "metric_revenue_previous",
      "type": "metric",
      "title": "Omzet vorige",
      "position": { "x": 1040, "y": 210 },
      "metric": {
        "key": "revenue_previous",
        "label": "Omzet vorige",
        "aggregation": "sum",
        "measureField": "line_total"
      }
    },
    {
      "id": "cond_revenue_down",
      "type": "condition",
      "title": "Omzet lager?",
      "position": { "x": 1320, "y": 120 },
      "condition": {
        "operator": "<",
        "left": { "source": "metric", "nodeId": "metric_revenue_current", "key": "revenue_current" },
        "right": { "source": "metric", "nodeId": "metric_revenue_previous", "key": "revenue_previous" }
      }
    },
    {
      "id": "action_warn",
      "type": "action",
      "title": "Omzet daalt",
      "description": "Omzet daalt: huidig={{revenue_currentValue}}, vorige={{revenue_previousValue}}",
      "position": { "x": 1600, "y": 50 },
      "action": { "channel": "Notification", "target": "all", "severity": "warn" }
    },
    {
      "id": "action_ok",
      "type": "action",
      "title": "Omzet stabiel",
      "description": "Omzet is stabiel of hoger. huidig={{revenue_currentValue}}",
      "position": { "x": 1600, "y": 220 },
      "action": { "channel": "Notification", "target": "all", "severity": "info" }
    }
  ],
  "connections": [
    { "id": "e1", "sourceId": "trigger_weekly", "targetId": "ds_testdata", "branch": "default" },
    { "id": "e2", "sourceId": "ds_testdata", "targetId": "flt_current", "branch": "default" },
    { "id": "e3", "sourceId": "ds_testdata", "targetId": "flt_previous", "branch": "default" },
    { "id": "e4", "sourceId": "flt_current", "targetId": "metric_revenue_current", "branch": "default" },
    { "id": "e5", "sourceId": "flt_previous", "targetId": "metric_revenue_previous", "branch": "default" },
    { "id": "e6", "sourceId": "metric_revenue_current", "targetId": "cond_revenue_down", "branch": "default" },
    { "id": "e7", "sourceId": "metric_revenue_previous", "targetId": "cond_revenue_down", "branch": "default" },
    { "id": "e8", "sourceId": "cond_revenue_down", "targetId": "action_warn", "branch": "if" },
    { "id": "e9", "sourceId": "cond_revenue_down", "targetId": "action_ok", "branch": "else" }
  ]
}

2. AI outlier detectie met LLM condition

Doel: AI beslist true/false of een metric een outlier is. True stuurt critical notificatie, false stuurt informatieve melding.

{
  "id": "auto_ai_outlier_guard",
  "name": "AI Outlier Guard",
  "nodes": [
    {
      "id": "trigger_daily",
      "type": "trigger",
      "title": "Dagelijks 07:00",
      "position": { "x": 120, "y": 120 },
      "trigger": { "schedule": "0 7 * * *" }
    },
    {
      "id": "ds_testdata",
      "type": "datasource",
      "title": "Factuurbron",
      "position": { "x": 380, "y": 120 },
      "data": { "dataSourceId": "testdata" }
    },
    {
      "id": "flt_last_30d",
      "type": "filter",
      "title": "Laatste 30 dagen",
      "position": { "x": 650, "y": 120 },
      "filter": {
        "rules": [
          { "field": "invoice_date", "type": "date", "datePreset": "past30", "enabled": true }
        ]
      }
    },
    {
      "id": "metric_invoice_count",
      "type": "metric",
      "title": "Aantal facturen",
      "position": { "x": 920, "y": 120 },
      "metric": {
        "key": "invoice_count",
        "label": "Aantal facturen",
        "aggregation": "count",
        "measureField": "invoice_id"
      }
    },
    {
      "id": "llm_outlier_gate",
      "type": "llmcondition",
      "title": "Outlier check",
      "position": { "x": 1200, "y": 120 },
      "llm": {
        "systemPrompt": "Je bent een data quality agent. Antwoord alleen true of false.",
        "userTemplate": "Metric aantal facturen={{invoice_countValue}}. Is dit een significante outlier t.o.v. recente trend?",
        "responseKey": "outlierDecision",
        "temperature": 0.1,
        "maxTokens": 100,
        "includeHistory": true
      }
    },
    {
      "id": "action_critical",
      "type": "action",
      "title": "Outlier gedetecteerd",
      "description": "Outlier alert. Aantal facturen={{invoice_countValue}}",
      "position": { "x": 1480, "y": 40 },
      "action": { "channel": "Notification", "target": "all", "severity": "critical" }
    },
    {
      "id": "action_normal",
      "type": "action",
      "title": "Geen outlier",
      "description": "Geen outlier volgens AI. route={{outlierDecisionRoute}}",
      "position": { "x": 1480, "y": 210 },
      "action": { "channel": "Notification", "target": "all", "severity": "info" }
    }
  ],
  "connections": [
    { "id": "a1", "sourceId": "trigger_daily", "targetId": "ds_testdata", "branch": "default" },
    { "id": "a2", "sourceId": "ds_testdata", "targetId": "flt_last_30d", "branch": "default" },
    { "id": "a3", "sourceId": "flt_last_30d", "targetId": "metric_invoice_count", "branch": "default" },
    { "id": "a4", "sourceId": "metric_invoice_count", "targetId": "llm_outlier_gate", "branch": "default" },
    { "id": "a5", "sourceId": "llm_outlier_gate", "targetId": "action_critical", "branch": "if" },
    { "id": "a6", "sourceId": "llm_outlier_gate", "targetId": "action_normal", "branch": "else" }
  ]
}

3. Element processing + Element action

Doel: voer eerst een Element uit voor transformatie, en daarna een Element action voor rapport/verzending.

{
  "id": "auto_element_pipeline",
  "name": "Element Enrichment Pipeline",
  "nodes": [
    {
      "id": "trigger_daily",
      "type": "trigger",
      "title": "Dagelijks",
      "position": { "x": 120, "y": 120 },
      "trigger": { "schedule": "0 9 * * *" }
    },
    {
      "id": "ds_orders",
      "type": "datasource",
      "title": "Orders",
      "position": { "x": 380, "y": 120 },
      "data": { "dataSourceId": "testdata" }
    },
    {
      "id": "elem_enrich",
      "type": "elementnode",
      "title": "Enrichment",
      "position": { "x": 660, "y": 120 },
      "element": {
        "elementId": "orders_enrichment",
        "entrypoint": "run",
        "timeoutSeconds": 120,
        "responseKey": "enrichedRows",
        "params": {
          "source": "{{dataSourceId}}",
          "limit": 500
        }
      }
    },
    {
      "id": "elem_send_report",
      "type": "elementaction",
      "title": "Rapport versturen",
      "position": { "x": 980, "y": 120 },
      "element": {
        "elementId": "send_management_report",
        "entrypoint": "run",
        "timeoutSeconds": 90,
        "responseKey": "reportDispatch",
        "params": {
          "rows": "{{enrichedRowsRows}}",
          "target": "management"
        }
      }
    },
    {
      "id": "action_done",
      "type": "action",
      "title": "Pipeline klaar",
      "description": "Element pipeline klaar. records={{enrichedRowsRows}}",
      "position": { "x": 1290, "y": 120 },
      "action": { "channel": "Notification", "target": "all", "severity": "info" }
    }
  ],
  "connections": [
    { "id": "p1", "sourceId": "trigger_daily", "targetId": "ds_orders", "branch": "default" },
    { "id": "p2", "sourceId": "ds_orders", "targetId": "elem_enrich", "branch": "default" },
    { "id": "p3", "sourceId": "elem_enrich", "targetId": "elem_send_report", "branch": "default" },
    { "id": "p4", "sourceId": "elem_send_report", "targetId": "action_done", "branch": "default" }
  ]
}

4. Prompt templates voor Ask AI

Template: condition flow

Maak een Autoflow met:
- trigger daily 08:00
- datasource testdata
- 2 filters: past7 en past7_shift1w
- 2 metrics: sum(line_total)
- condition: current < previous
- actions: warn if, info else

Gebruik:
- node id op elke node
- connections met sourceId en targetId
- branch if/else op condition edges

Template: AI + action

Bouw flow met:
- trigger dagelijks
- datasource + metric count
- llmcondition die true/false antwoordt
- if: critical notification
- else: info notification

Belangrijk:
- llm.userTemplate verplicht invullen
- llmcondition moet twee outgoing branches hebben: if en else
- geen extra onbekende node types of velden