Skip to content

Writing Triggers

Trigger conditions are JavaScript expressions that determine whether an action should run.

When an event matches a trigger’s module group and event name, the condition program is evaluated. If it returns a truthy value, the linked action runs.

Inside a trigger condition, you have access to:

GlobalDescription
eventThe full event object
triggerThe trigger itself
log(...)Log values for debugging
// event structure
{
id: "evt_abc123",
name: "ChatMessage",
payload: { user: "viewer42", message: "!hello" },
emitter_group: "twitch",
emitted_at: "2025-01-15T10:30:00Z"
}
true
event.payload.message.startsWith("!hello")
event.payload.message.toLowerCase().startsWith("!hello")
event.payload.user === "viewer42"
event.payload.user !== "nightbot"
event.payload.message.startsWith("!vip") && event.payload.user === "moderator1"
/^!(hello|hi|hey)/i.test(event.payload.message)
event.payload.amount > 100

If your trigger isn’t matching, use log() to inspect the event:

log("Event payload:", event.payload);
event.payload.message.startsWith("!hello")

The last expression is the return value. Logs will appear in the process details even if the condition returns false.

  • Keep conditions simple — complex logic belongs in the action, not the trigger
  • Use cooldowns to prevent triggers from firing too rapidly
  • Test with log() to see exactly what data the event contains
  • Trigger conditions have a 5-second timeout — they should be near-instant