Use Behaviors to respond to a new card connection in a 2D diagram or to queue changes and messages in the Process Simulator. Behaviors are available by default in the production workspace. On staging and in development, add ?behaviors=1 to the editor address. For grammar, supported versions and execution limits, see the Visual Nerve Script Language Reference
.
Get started
- Open Visual Nerve and open or create a local diagram in 2D. Choose Behavior library in the toolbar. Choose New behavior and enter a name and source, or expand Reusable templates, select a built-in template and choose Copy as editable draft.
- Check the language version and edit the Working draft. Save draft keeps unfinished work. Activate source saves valid code and approves this revision for the open diagram in this tab.
- Attach, configure and try the Behavior as described below. An editor connection and its accepted changes can be undone together. A simulator run records a result you can inspect or replay. To try the model without the Behavior, disable its binding and start a new run.
Version 3 also supports a manual workflow started explicitly from the library.
Attach and configure
- For editor rules, attach to the card where a new connection starts. For simulator rules, attach to a Work node. Drag an active definition onto a compatible card, or select the card and use Behavior to add → Add behavior in its Behaviors properties. You can also use Add to selected node in the library.
- Set required parameters in that binding. Choose node and resource parameters from the available objects. Check Enabled and review the source if the library asks for approval.
- Test an editor rule by drawing a new connection from the bound card. Opening or importing a diagram, writing graph data through REST/MCP, reconnecting an existing edge and pressing Undo or Redo do not rerun it. Test a simulator rule with Play or MAX and check Replay and compare runs.
- A definition can be attached in several places. Each binding has its own parameters and simulator state. Disable a binding to keep its configuration for later. Conflicting title or status proposals for a new edge leave the previous value in place.
Recipes
The following sources are built-in templates. Choose the stated Template version and Copy as editable draft, then use the recipe’s test data to compare its output with the trace.
Rename a connected card
Choose Name a connected card, template version 1 (language version 1). In a blank 2D diagram add Intake and To review. Attach to Intake, leave nextName as Quality check, and connect Intake to To review. The target becomes Quality check. Undo restores To review and removes the edge. For a second binding, set a different nextName to see its independent value.
parameter nextName as text = "Quality check"
on connectionAdded
rename event.target to nextName
end
Set status on connection
Choose Set status on connection (language version 2). Give a target card the Planned status, then attach the template to a separate source card and draw an edge to the target. The target changes to In progress. Undo restores Planned and removes the edge.
parameter nextStatus as text = "in-progress"
on connectionAdded
set status of event.target to nextStatus
end
Open shared checkout capacity
Choose Open shared checkout capacity (language version 1). In the Process Simulator
, set up 17 simultaneous arrivals, one Work step named Checkout, one regular slot, and 60 seconds per item. Give Checkout a one-unit requirement from a shared Staff pool with capacity 2. Run for 75 seconds with random seed 42. Attach once to Checkout, choose Checkout for receiver and Staff for staffing, and leave threshold at 15. The same definition handles the queue change and the message at Checkout.
The change from 15 to 16 waiting items sends one message and opens one reserve slot. Expect two completions by 75 seconds. Reduce staff capacity to 1 and run again to see Staff busy and one completion. With 16 arrivals there is no crossing and no send.

parameter threshold as number = 15
parameter receiver as node
parameter staffing as resource
on queueChanged
if queue.previousLength <= threshold and queue.length > threshold then
send "open checkout" to node receiver
end if
end
on "open checkout"
open reserve slot using resource staffing
end
Delay a reserve request
Choose Delay a reserve request (language version 2). Use the same checkout fixture and bindings, enable only this recipe, and leave the delay at five seconds. The send at simulated time 0 is due at 5 seconds. The regular checkout finishes at 60 seconds and the reserve finishes at 65 seconds. Set delay to zero for immediate delivery. A 4-second run with Finish all generated work off records the pending message as beyond the horizon.
parameter threshold as number = 15
parameter delay as number = 5
parameter receiver as node
parameter staffing as resource
on queueChanged
if queue.previousLength <= threshold and queue.length > threshold then
send "open checkout" to node receiver after delay
end if
end
on "open checkout"
open reserve slot using resource staffing
end
Count queue increases per binding
Choose Count queue increases per binding (language version 2). Create two independent flows, each with a three-item burst, one Work slot, and a 60-second processing time. Use a single shared Staff pool with capacity 4 and require one unit per item at each Work node. Attach this same definition once to each Work node. Set receiver to that binding’s own Work node and staffing to Staff. Keep the 75-second run and seed 42.
Each binding begins with its own increases value of zero. Each sends one message on its second queue increase and opens its own reserve slot. The two sends have different binding IDs. Expect four completions by 75 seconds. A new run initializes both counters again. Falling queues do not increment the counters.
parameter receiver as node
parameter staffing as resource
property increases as number = 0
on queueChanged
if queue.length > queue.previousLength then
set increases to increases + 1
if increases == 2 then
send "open checkout" to node receiver
end if
end if
end
on "open checkout"
open reserve slot using resource staffing
end
Troubleshoot a Behavior
| What you see | Check |
|---|---|
| A source diagnostic with a line and column | Select the location to open the corresponding source. Check the language version, types and syntax . Save the fix as a draft until you are ready to activate it. |
| No change on a new connection or in a run | Check the binding’s Enabled state, required parameters, attachment to the initiating card or Work node, and approval for the exact saved source. For a scenario, check its Behavior participation and overrides. |
| One field remains unchanged | Open Behavior trace. Competing valid names or statuses leave that field unchanged. Use the trace to identify the definitions and the proposed values. |
| Staff busy or no reserve allocation | Check the waiting queue, resource and Work schedules, and available units in the shared pool. The reserve action requires ordinary one-unit staffing. |
| A limit or early run end | Check the source, action and message limits . For delayed messages, compare the due time with the run length and the Finish all generated work setting. |
| A replay differs from a new run | Use the same model assumptions, scenario, seed and duration for a new comparison. Replay uses the original captured inputs and source. Inspect a saved run to open the recorded source at its line. Reopened archives may need Allow replay of captured source to recompute a moment. |
| Imported source is visible but does not execute | Open the definition, review Saved source and choose Allow saved source. Approval is specific to the source version and current open tab and ends on lock, close, or live collaboration. A build that does not support a saved version can still show its source. |
API, migration and trust
The REST and MCP guide
covers capabilities, syntax validation and portable Behavior definitions. Read only allows discovery, reads and validation. Changing definitions or bindings requires Read + write, the current diagram baseVersion and a supported action. A definition retains its stored language version. Active collaboration rooms reject diagram Behavior commands. An API write or enabling a binding leaves source approval with the user in the open browser tab.
Native diagram imports and workspace backups preserve source, drafts, versions and ordered bindings. Whole-diagram copies remap typed node references. When you copy only part of a diagram to another, references outside the copied selection may be cleared and the affected binding disabled. Review imported references and source before enabling execution. Unknown language versions remain inspectable and require a compatible build to run.