Multi Step Workflow
Learn how to handle complex execution flow orchestrating the execution of multiple nodes
Multiple steps are created by defining custom events that can be emitted by nodes and trigger other nodes. Let's define a simple 3-step workflow.
Custom Events
We define two custom events, FirstEvent and SecondEvent. These classes can have any names and properties, but must implement Event:
vendor/bin/neuron make:event App\\Neuron\\FirstEvent.\vendor\bin\neuron make:event App\Neuron\FirstEventnamespace App\Neuron;
class FirstEvent implements Event
{
public function __construct(protected string $firstMsg){}
}
class SecondEvent implements Event
{
public function __construct(protected string $secondMsg){}
}Defining the workflow
Now we define the workflow itself. We do this by defining the input and output types on each node. Here is the minimal implementation of the nodes for the purpose of this demo.

InitialNode
NodeOne
NodeTwo
Define the Workflow attaching the nodes:
The full output will be:
Of course there is still not much point to a workflow if you just run through it from beginning to end! Let's do some branching and looping.
Monitoring & Debugging
Many of the applications you build with Neuron will contain multiple steps with multiple invocations of LLM calls. As these applications get more and more complex, it becomes crucial to be able to inspect what exactly is going on inside your agentic system. The best way to do this is with Inspector.
Last updated

