⚡ Workflow Engine

Visual Drag'n'Drop Editor für Event → Condition → Action Chains. Das Herz der Plattform — verbindet alle Module.

💡 Konzept

Wie IFTTT/Zapier, aber für Streaming — visuell, real-time, self-hosted

🎯 Trigger

Ein Event das den Workflow startet. Kann von jedem Modul kommen: Twitch Follow, Donation, OBS Scene Change, Chat Command, Timer Ablauf, Shop Purchase.

🔀 Condition

Optional: Prüfe ob der Workflow weiter ausgeführt wird. Betrag > X? User hat Rolle Y? Stream ist live? Cooldown nicht aktiv?

⚙️ Action

Was passiert: OBS Scene Switch, Overlay Alert zeigen, Chat Nachricht senden, Sound abspielen, Discord Nachricht, Timer starten.

Warum ist das wichtig?

Ohne Workflow Engine müsste jedes Feature (Twitch Bot, Overlay, Discord Bot, OBS Plugin) seine eigene Automatisierung haben. Mit der Engine: ein System für alles. Neues Feature = neuer Trigger/Action → sofort in jedem Workflow nutzbar. Kein Duplicate Code, maximale Flexibilität.

🖥 Visual Workflow Editor — Mockup

Drag'n'Drop mit React Flow. Nodes verbinden = Workflow bauen.

⚡ Donation Alert + Subathon | 💾 Save ▶ Test 📋 Duplicate ● Active
🎯 Triggers
Twitch Event
Discord Event
Donation
Shop Purchase
OBS Event
Chat Command
Timer / Schedule
Webhook
🔀 Logic
If / Condition
Delay
Cooldown
Random
⚙️ Actions
Show Alert
OBS Control
Chat Message
Discord Message
Play Sound
Timer Control
Set Variable
HTTP Request
🎯 Trigger
Donation Received
Any amount · Any donor
🔀 Condition
Amount ≥ €5?
Check donation amount
↙ ↘
✓ Yes
⚙️ Action
Show Alert
Big Alert + TTS
⚙️ Action
Subathon +Time
+{amount} minutes
⚙️ Action
Discord #donations
{user} donated €{amount}
✗ No
⚙️ Action
Show Alert
Small Alert (no TTS)
Node Properties
Node Type
🎯 Trigger: Donation
Event
Min Amount
Donor Filter
Available Variables
{user} Donor name
{amount} € Amount
{message} Message
{currency} Currency
{tts} TTS enabled
🎯 Triggers — Aus allen Modulen

Jedes Modul liefert Triggers. Die Liste wächst automatisch mit neuen Features.

📺 Twitch (~40)

  • stream.online / offline
  • channel.update (title/game)
  • channel.follow
  • channel.subscribe / gift / resub
  • channel.cheer
  • channel.raid
  • channel.poll / prediction
  • channel.hype_train
  • channel.points.redemption
  • chat.command
  • + alle anderen EventSub

🤖 Discord

  • member.join / leave
  • message.create
  • reaction.add / remove
  • voice.join / leave
  • level.up
  • role.change
  • command.executed

💝 Donations

  • donation.completed
  • donation.refunded
  • goal.reached

🛒 Shop

  • order.paid
  • order.completed
  • order.refunded
  • subscription.start
  • subscription.renew
  • subscription.cancel
  • download.completed

📡 OBS

  • obs.scene.changed
  • obs.streaming.start / stop
  • obs.recording.start / stop
  • obs.source.muted
  • obs.source.visibility
  • obs.stats (CPU/FPS/dropped)

⏱ Timer / Schedule

  • timer.finished (countdown = 0)
  • subathon.ended
  • schedule.cron (recurring)
  • schedule.once (einmalig)

🎬 Media

  • recording.started / stopped
  • clip.created
  • clip.exported

🌐 External

  • webhook.received
  • api.called
⚙️ Actions — Was passieren kann

🎨 Overlay

  • Show Alert (event-specific)
  • Toggle Widget (show/hide)
  • Update Widget Text
  • Play Media (sound/video)
  • Update Goal Value

📡 OBS

  • Switch Scene
  • Toggle Source
  • Mute/Unmute
  • Toggle Filter
  • Update Source Text
  • Trigger Transition
  • Take Screenshot

💬 Chat / Bots

  • Twitch Chat Message
  • Discord Channel Message
  • Discord DM
  • Discord Role Add/Remove

⏱ Timer

  • Start/Stop/Pause Timer
  • Add Time (Subathon)
  • Set Counter Value
  • Increment/Decrement

📊 Variables

  • Set Custom Variable
  • Increment/Decrement
  • Store to DB
  • Read from DB

🎬 Media

  • Create Clip
  • Start/Stop Recording
  • Play Sound (in Overlay)

🌐 External

  • HTTP Webhook
  • Send Email

🔀 Flow Control

  • Delay (wait X seconds)
  • Cooldown (prevent spam)
  • Random (pick branch)
  • Loop (repeat X times)
🔀 Conditions — Entscheidungslogik

📊 Value Check

  • {amount} > / < / = / ≥ / ≤ Wert
  • {user} equals / contains / regex
  • {message} contains keyword
  • {tier} = 1 / 2 / 3

👤 User Check

  • Hat Discord Rolle X?
  • Ist Twitch Sub/Mod/VIP?
  • Ist registrierter User?
  • Viewer seit X Tagen?

🔧 System Check

  • Stream ist live?
  • OBS Scene = X?
  • Aktuelle Game Category = X?
  • Uhrzeit zwischen X und Y?
  • Variable X hat Wert Y?

⏱ Cooldown

  • Global Cooldown (X Sekunden)
  • Per-User Cooldown
  • Per-Workflow Cooldown
  • Burst: Max X in Y Sekunden

🔗 Logic Gates

  • AND: Alle Conditions müssen true sein
  • OR: Eine reicht
  • NOT: Invertiert
  • Nested: Conditions in Conditions

🎲 Random

  • X% Chance (z.B. 25% Bonus Alert)
  • Random Pick aus Liste
  • Weighted Random
📋 Beispiel-Workflows

Was damit alles möglich ist

🎉 Donation mit Tiered Alerts

TRIGGER donation.completed
IF amount ≥ 50 → Big Video + TTS + Subathon +50min
ELIF amount ≥ 20 → Medium Alert + TTS + Subathon +{amount}min
ELIF amount ≥ 5 → Small Alert + TTS
ELSE → Tiny Alert only
ALWAYS → Discord #donations "{user} donated €{amount}"

⚔️ Raid → Full Production

TRIGGER channel.raid
IF viewers ≥ 50
OBS: Switch to "Raid Welcome" scene
Overlay: Play raid video
Chat: "Welcome raiders from {user}! 🎉"
DELAY 15 seconds
OBS: Switch back to "Gaming" scene

🛒 VIP Purchase → Full Access

TRIGGER subscription.start (product: "VIP")
Discord: Add role "VIP"
Discord: DM "Welcome to VIP! 🌟"
Overlay: Show "New VIP: {user}!" alert
Chat: "/announce {user} just became VIP! 🎉"

💀 Death Counter + Sound

TRIGGER chat.command "!death"
IF user is Mod or Broadcaster
Counter "deaths" +1
Overlay: Update text "{deaths} Deaths"
Play sound "oof.mp3"
IF deaths = 69
Chat: "nice. 😏"

📡 Stream Start Routine

TRIGGER obs.streaming.started
Discord: Post in #live "Stream is live! 🔴"
Reset counter "deaths" to 0
Reset donation goal (session)
OBS: Switch to "Starting Soon" scene
DELAY 60 seconds
OBS: Switch to "Gaming" scene

🎵 Channel Points → Sound

TRIGGER channel.points.redemption
IF reward = "Play Sound"
Play sound from Media Library (random)
COOLDOWN 30 seconds per-user

🔧 Technische Architektur

Frontend: React Flow

  • React Flow Library für den Visual Editor
  • Custom Node Types (Trigger, Condition, Action, Delay)
  • Drag'n'Drop aus der Sidebar
  • Edge Connections mit Validation
  • Undo/Redo
  • Export als JSON (Workflow Definition)

Backend: Event-Driven Executor

  • Redis Pub/Sub → Events ankommen
  • Workflow Matcher: welche Workflows matchen dieses Event?
  • Executor: traversiert den Graphen (BFS/DFS)
  • Conditions evaluieren mit Context (Event Data + Variables)
  • Actions per BullMQ dispatchen (reliable)
  • Execution Log (welcher Node, wann, Ergebnis)
🗄 Datenmodell
workflow id text PK userId text FK name text // "Donation Alert + Subathon" description text? isActive boolean definition jsonb // React Flow graph: { nodes: [...], edges: [...] } triggerType text // "donation.completed" (indexed for fast lookup) triggerConfig jsonb // { minAmount: 5, ... } (pre-filter before full eval) executionCount integer lastExecutedAt timestamp? cooldownMs integer? // global cooldown for this workflow createdAt timestamp updatedAt timestamp workflowExecution id text PK workflowId text FK triggeredBy text // event type that triggered eventData jsonb // snapshot of trigger event status enum // RUNNING, COMPLETED, FAILED, CANCELLED nodeResults jsonb // [{ nodeId, type, result, duration }] error text? durationMs integer startedAt timestamp completedAt timestamp? workflowVariable id text PK userId text FK key text // "deaths", "donation_total", custom name value text // stored as string, parsed by type type enum // NUMBER, STRING, BOOLEAN scope enum // SESSION (reset per stream), PERSISTENT updatedAt timestamp
💡 Key Principle

Triggers + Actions sind nicht hartcodiert

Jedes Modul registriert seine Triggers und Actions bei der Workflow Engine. Wenn ein neues Feature gebaut wird (z.B. Spotify Integration), registriert es:

TRIGGER spotify.track.changed{ track, artist, album, artUrl }
ACTION spotify.skip → Skips current track
ACTION spotify.pause → Pauses playback

→ Sofort im Workflow Editor verfügbar. Kein Engine-Update nötig. Plugin-Architektur — die Engine weiß nicht was die Module tun, sie verbindet sie nur.

Codenull Platform · Workflow Engine Module Planning · 2026-03-18