Skip to content

Triggers

All 36 events that can start a flow, with their fields and examples.

A trigger is the hat a flow hangs from: the blocks snapped underneath it run when the trigger fires. A flow can hold many triggers, each with its own stack of actions.

Every example on this page is drawn the way the editor draws it: a green hat with the blocks that run beneath it. White boxes are the fields you fill in.

Three rules apply to every trigger here.

  • One firing at a time. While a trigger's actions are still running, the same trigger ignores further events until it finishes. A chat trigger that takes eight seconds does not queue up eight seconds of backlog.
  • Blocks must be snapped under the hat. A block left floating on the canvas is not saved. The editor warns you before you lose it.
  • Some triggers hand values to the actions, written {{var:name}} in any text field. Each section below says which.

Sections are ordered exactly as the editor's Triggers palette lists them.

join

Runs once, each time the client finishes connecting to the server. The usual home for a login command or an announcement.

No fields.

on join
command /login {{password}}

Fires again on every reconnect, so anything here must be safe to repeat.

timer

Runs the blocks underneath repeatedly, on a fixed interval or on a random interval between two values.

FieldTypeRequiredNotes
everyMs1 second to 1 dayyesThe editor takes a number plus a unit.
everyMaxMs1 second to 1 daynoTurns the interval random: each wait is picked between everyMs and this value.
every 10 minutes
chat still here

The every … to …, random block in the palette sets both values. Before each firing it picks a new wait anywhere between the two, so a timer of 3 to 7 minutes might wait 4, then 6, then 3. A higher end that is not above the lower one leaves the interval fixed.

every 3 to 7 minutes, random
move forward for 1 seconds

The interval is the gap between firings, not a guaranteed rate: if the actions take longer than the interval, a tick that comes while they still run is dropped, not queued, and the timer fires again on the next tick after they finish.

schedule

Runs at a wall-clock time, optionally only on the days you tick. Use this instead of a timer for "every day at 20:00": a timer drifts, a schedule does not.

FieldTypeRequiredNotes
atHH:MM, 24-houryesThe time you type is your local time.
daysany of Sun to SatnoAll seven ticked, or none, means every day.
offsetMinutes−840…840noFilled in from your own clock by the editor.
at 18:00 on Mon Tue Wed Thu Fri
command /warp shop

The offset is a fixed number of minutes, not a timezone: daylight saving cannot silently move the schedule under you, but you do have to re-set it yourself when your own clock changes.

death

Runs when the client dies.

No fields.

on death
notify owner: the client died

Dying and coming back are two separate events, so pair this with respawn.

respawn

Runs each time the client respawns, after a death or a dimension change.

No fields.

on respawn
go to at coords x 100 y 64 z -200

health

Runs when health drops below a threshold. 20 is full hearts.

FieldTypeRequiredNotes
below1–20yesFires when health falls under this value.

Fires once on the way down, when health goes from this value or more to less than it. It fires again only after health has been back at or above the value, so regeneration ticks while it stays low do not repeat it. below 8 does not fire at exactly 8.

on health below 8
command /spawn

food

Runs when hunger drops below a threshold. 20 is full.

FieldTypeRequiredNotes
below1–20yesFires when food falls under this value.

Fires once when food drops under the value, and again only after food has been back at or above it.

on food below 12
notify owner: the client is hungry

damage

Runs whenever the client takes damage, from any source.

No fields.

on damage taken
sprint on
go to at coords x 0 y 64 z 0

Fires on every hit, so keep the stack short. A long one will still be running when the next hit lands, and that hit is ignored.

level_up

Runs when the client's XP level increases.

FieldTypeRequiredNotes
level1–1000noFires only at or above this level. Blank fires on every level up.

Hands over {{var:level}}, the new level.

on XP level up (at least 30)
notify owner: reached level {{var:level}}

player_near

Runs when any player comes within the radius. Edge-triggered: it fires on entry, not continuously while someone stands there. If someone enters again while the actions are still running, the trigger runs once more when they finish, as long as that player is still in range.

FieldTypeRequiredNotes
radius1–64yesBlocks.
on player within 16 blocks
notify owner: someone is close

mob_near

Runs when a hostile mob enters the radius. Edge-triggered, like player_near.

FieldTypeRequiredNotes
radius1–64yesBlocks.
on hostile mob within 6 blocks
attack hostile

player_join

Runs when a player joins the server.

FieldTypeRequiredNotes
playerplayer namenoBlank fires for anyone.

Hands over {{var:player}}.

on player joins
chat welcome {{var:player}}

player_leave

Runs when a player leaves the server.

FieldTypeRequiredNotes
playerplayer namenoBlank fires for anyone.

Hands over {{var:player}}.

on player leaves Notch
stop client

low_on_item

Fires once when the carried count of an item drops below a threshold, and re-arms when the count recovers. For restocking blocks, food or ammunition.

FieldTypeRequiredNotes
itemregistry nameyesFor example cooked_beef.
below1–2304yesFires when the carried count falls under this.
when low on cooked_beef (below 8)
open container nearest container · radius 6
take cooked_beef x 32 from container
close container

Edge-triggered, so it will not fire again while the count stays low. It waits for a recovery first.

inventory_full

Fires once when no empty inventory slot is left, and re-arms when a slot frees.

No fields.

on inventory full
drop cobblestone — the whole stack

item_collected

Runs when the client picks an item up off the ground.

FieldTypeRequiredNotes
itemregistry namenoBlank fires for any item.

Hands over {{var:item}} and {{var:count}}.

on item picked up diamond
notify owner: picked up {{var:count}} x {{var:item}}

night

Fires once when the in-game day turns to night.

No fields.

on nightfall (in game)
notify owner: night has fallen

In the editor this is one option on the world-state block, which also emits day, rain and weather_clear.

day

Fires once when the in-game night turns to day.

No fields.

on daybreak (in game)
notify owner: daybreak

rain

Fires once when it starts raining.

No fields.

on rain starting
notify owner: rain started

weather_clear

Fires once when the rain stops. The counterpart to rain.

No fields.

on rain stopping
log clear again

goal_reached

Fires when a go-to or a follow finishes its path. This is how a flow walks somewhere and then acts, instead of guessing with a wait.

No fields.

on destination reached
use block at x 0 y 64 z 0

goto_failed

Fires when a path cannot be found, or pathfinding times out.

No fields. Hands over {{var:reason}}.

on pathfinding failure
notify owner: could not get there: {{var:reason}}

kicked

Runs when the server kicks the client.

No fields.

on kicked
notify owner: kicked

The client's own auto-reconnect already handles getting back on. Use this to be told about it, or to change something before the next attempt.

before_stop

The last chance to act before a commanded stop: empty the inventory into a chest, log out cleanly, send a notification.

No fields.

before the client stops
open container nearest container · radius 8
put everything into container
close container

Two limits matter. It runs on a five-second budget (a stop must never hang waiting for a flow), and it does not fire for a kick or a dropped connection, only for a deliberate stop.

flow_error

Runs when any other trigger's actions fail. One central place to be alerted, instead of wrapping every trigger in a try.

No fields. Hands over {{var:error}} (the message) and {{var:reason}} (the event that failed).

on flow error
notify owner: {{var:reason}} failed: {{var:error}}

It never fires for its own failures, since that would loop.

chat

Runs when a chat line arrives and matches an optional pattern.

FieldTypeRequiredNotes
filterregular expression, ≤200 charsnoBlank matches every line.
fromup to 64 player namesnoFire only for lines sent by these players. Blank = anyone.

Hands over {{var:player}} (the sender, empty when none was found), {{var:message}}, plus {{var:m1}} … {{var:m9}} for the pattern's capture groups.

on chat matching ^!home (\w+)$ — only when sent by Alice, Bob
command /home {{var:m1}}

When the line has a sender, the filter sees only the message after the name: for <Alice> !home base it tests !home base, which is also what {{var:message}} holds, so ^ anchors at the start of what Alice typed. A line with no sender, like a server broadcast, is tested whole. Matching is case-sensitive, so write [Hh]ome where the case can vary.

from matches the sender, read out of the rendered line's <name> or [rank] name: prefix. Private messages count too: in [Steve -> me] hi and Steve whispers to you: hi the sender is Steve and the message is hi, while the messages the client sends itself ([me -> Steve] hi) have no sender. A line that merely mentions a listed name is not a match. Because the sender is read from the rendered text, this works on custom-plugin chat formats that mineflayer cannot parse, which is why, on a plugin server, the chat trigger with a player list is the combination that works, and whisper often is not.

whisper

Runs on a vanilla private message.

FieldTypeRequiredNotes
filterregular expression, ≤200 charsnoBlank matches any whisper.
fromup to 64 player namesnoRestrict senders. Blank = anyone.

Hands over {{var:player}} (the sender), {{var:message}} and the capture groups.

on whisper matching ^come$ — only from Alice
follow on player Alice at 2 blocks

Only vanilla whispers reach this. On servers whose plugins render private messages as ordinary chat lines, use the chat trigger instead.

actionbar

Runs on text the server pushes to the action bar, the line above the hotbar. Plugin servers commonly put balances, timers and queue positions there.

FieldTypeRequiredNotes
filterregular expression, ≤200 charsnoBlank matches any action-bar text.

Hands over {{var:message}} and {{var:m1}} … {{var:m9}}.

on action bar text matching Balance: (\d+)
set variable balance to {{var:m1}}

In the editor this is one option on the HUD-text block, which also emits title, bossbar and scoreboard.

title

Runs on a title or subtitle the server sends.

FieldTypeRequiredNotes
filterregular expression, ≤200 charsnoBlank matches any title.

Hands over {{var:message}} and the capture groups.

on title text matching ^Welcome
log {{var:message}}

bossbar

Runs on boss-bar text, often a countdown or an event announcement.

FieldTypeRequiredNotes
filterregular expression, ≤200 charsnoBlank matches any boss bar.

Hands over {{var:message}} and the capture groups.

on boss bar text matching Event in (\d+)s
command /event join

scoreboard

Runs when a scoreboard line changes.

FieldTypeRequiredNotes
filterregular expression, ≤200 charsnoBlank matches any scoreboard text.

Hands over {{var:message}} and the capture groups.

on scoreboard text matching Queue: (\d+)
set variable queue to {{var:m1}}

Runs when a server GUI or menu opens: a shop, a kit picker, a warp list.

No fields.

on menu opens
click menu item diamond

window_closed

Runs when a server GUI closes. The counterpart to menu_open, so a shop flow can tell the menu went away instead of guessing with a wait.

No fields.

on menu closes
log menu gone

signal

Runs when another client of the account sends a signal on this channel.

FieldTypeRequiredNotes
channellowercase name, [a-z0-9_]{1,40}yesFire only for this channel.
fromarray of client names, max 50noOnly from these senders. Leave out for any of the account's clients.
on signal regroup only from clients leader
go to at coords x {{signal_x}} y {{signal_y}} z {{signal_z}}

The firing gets {{signal_from}} (the sender's client name), {{signal_message}} (empty, without a warning, when the signal carried no message), {{signal_x}}, {{signal_y}}, {{signal_z}} (where the sender stood when it sent, whole numbers) and {{signal_dimension}}. So "come here" is this trigger with a goto to those coordinates.

Signals come from the signal action, and only from clients of the same account. A client that starts after a signal was sent never sees it. Like any trigger it ignores a new signal while its own firing is still running. In Try it you can fire it by hand with the fields filled in.

task

Runs only when something outside the game asks for it: Run now on clients or the flow's webhook URL. Nothing in the game fires it.

No fields.

when run manually or by webhook
command /sell all

The event is named task for historical reasons: it predates Run now on clients, and stored flows use it.

Any other trigger can be started by hand too, on one client, with Run a flow on the client's page or Run on server in the editor. See Run any trigger now.

routine

A named stack of blocks that other blocks call with run routine. It never fires on its own; it is how you write a sequence once and reuse it.

FieldTypeRequiredNotes
namelowercase name, ≤40 charsyesWhat the run-routine block refers to.
routine stow
open container nearest container · radius 8
put everything into container
close container
on inventory full
run routine stow
Triggers · CubeMind docs