Skip to main content
A node handler is the runtime behaviour behind one kind of node on the flow canvas. It implements Fapost\Foundation\Contracts\NodeHandlerInterface.

Identity

type() is the node’s unique identifier, such as send_message. It must be unique across every registered handler, including those from other extensions: a Solution’s types start with its id and a dot (feedback.collect), which Core’s never contain. version() is the handler’s current version; the engine resolves a handler by the pair (type, version) from an in-memory registry, with no database query on the hot path. label() and category() are what the builder shows: the node’s name and the group it appears under. The group is a value of Fapost\Foundation\Flow\Enums\NodeCategory or, for a Solution’s node, the Solution’s id — see Registering node types. Override category(): the default of AbstractVersionedHandler, Core, is not a palette group, so a handler that keeps it fails the boot. That default is deprecated and becomes abstract in Foundation 1.0.

Configuration

configSchema() returns the schema the builder uses to validate the node and draw its form. This is the mechanism that lets an extension be configurable without shipping any front-end code — see Builder UI extensions.

Execution

execute() receives three things: A flow started by a schedule, a webhook, an API call or a Core event runs without a contact. A node needs a contact unless its handler says otherwise, so such a flow cannot be published while it holds your node; nodes in flows started by a message or by another flow’s event are unaffected. A handler that can run without a contact implements Fapost\Foundation\Flow\Contracts\DeclaresContextRequirementInterface:
On a run without a contact, $context->contactId and $context->platform are null, reading contact.* or module.* through the state reader throws, and so does every write through the contact writer. A node whose config reads the contact or uses a contact variable is refused in such a flow whatever its handler declares. The interface needs fapost/foundation ^0.42. execute() returns a NodeExecutionResult, built through one of its named constructors:
delayed() has two forms: Without resumeAt, the session waits exactly as after waiting(): the contact’s next message runs your handler again, and the handler decides whether it is time to move on — the built-in delay node works this way. Nothing wakes the node without an inbound message. With resumeAt, nothing the contact sends reaches your handler until that time: the engine wakes the node itself, and only then does the flow resume. Your handler tells the two situations apart through NodeExecutionContext::$resumedAfterDelay — true only on the run the engine triggered for this resumeAt, false on every other call, including the one that first asked for it:
Do not read the resume_at you asked for back out of $state. The marker the engine uses to schedule and match the wake-up is an internal detail, not part of the handler contract, and may change — rely on $resumedAfterDelay.

Data for the run trace

Every node writes a trace row when it completes. In an automation run that row holds the node’s input (the incoming message) and output (state changes and result metadata). A handler can add what only it knows (the request it sent, the response it received) through the trace argument of NodeExecutionResult:
The trace is written nowhere else: not to the flow log, not to the session state. Core masks values under sensitive key names (authorization, password, token, api_key, secret and the like), passwords and sensitive query parameters in URLs, and cuts a row to 1 MB. Masking goes by key name, not by content, so never put a raw secret under an innocent name. A conversation’s trace keeps no input or output. trace needs fapost/foundation ^0.44 and is experimental.

The handler must be graph-unaware

A handler returns a sourceHandle, never the id of the next node.
The engine resolves what comes next from the flow’s edges, using the source node id together with the handle the handler returned. A handler that decides which node runs next has taken a decision that belongs to the flow definition, and the same handler can then no longer be reused in a differently-shaped flow. sourceHandle defaults to 'default'. A node with several outcomes — a branch, a validation that can fail — returns a different handle per outcome, and the person building the flow wires each handle where they want it to go.

Writing outside the session

State changes go back through stateChanges on the result. Mutations that live outside the session JSON — contact attributes, contact language — are performed by the handler through the writer it receives on NodeExecutionContext, such as ContactWriterInterface.
Do not return a legacy effects[] array. It was removed; handlers use the writer or port from the execution context instead.