Nodes

Nodes are the building blocks of MindedJS flows - discrete processing units that handle different aspects of your agent's workflow.

Node Types Overview

Node Type
Purpose
Description

Entry Points

Start flows from various sources

LLM Processing

Generate responses using language models

Actions

Execute external functions and APIs

Flow Control

Route and organize flow logic

Flow Control

Jump to specific nodes or subflows

Trigger Nodes

Trigger nodes are entry points that start your flows and initialize them with memory and messages.

Trigger Types

Manual Trigger

- type: trigger
  triggerType: manual
  name: Customer Support Request

App Trigger

- type: trigger
  triggerType: app
  name: Zendesk Ticket Created
  appTriggerId: zendesk-new-ticket

Webhook Trigger

- type: trigger
  triggerType: webhook
  name: Payment Failed Notification

Trigger Implementation

import { events } from 'mindedjs/src/index';
import { HumanMessage } from '@langchain/core/messages';

agent.on(events.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
  if (triggerName === 'Customer Support Request') {
    return {
      memory: {
        customerQuery: triggerBody,
        timestamp: new Date().toISOString(),
      },
      messages: [new HumanMessage(triggerBody)],
    };
  }
});

Disqualifying Triggers

Return an object with isQualified: false to prevent flow execution:

agent.on(events.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
  // Only process during business hours
  const hour = new Date().getHours();
  if (hour < 9 || hour > 17) {
    return { isQualified: false };
  }

  return {
    isQualified: true,
    memory: { businessHours: true },
    messages: [new HumanMessage(triggerBody)],
  };
});

Prompt Nodes

Prompt nodes process input through LLM to generate intelligent responses or invoke tools.

Optional Properties:

  • humanInTheLoop?: boolean - When true, pauses execution after this node for human input before continuing

  • canStayOnNode?: boolean - When true, allows the node to route back to itself for iterative processing. Usually combined with humanInTheLoop: true to allow for iteration over human input.

Example Usage:

- type: promptNode
  name: Content Reviewer
  prompt: 'Ask user to review the content and approve or request changes.'
  humanInTheLoop: true # Pause for human approval before proceeding

- type: promptNode
  name: Research Assistant
  prompt: 'Request user for more information until you have gathered all necessary information.'
  canStayOnNode: true # Allow iterative research until complete
  humanInTheLoop: true # Pause for human approval before proceeding

Basic Configuration

- type: promptNode
  name: Customer Service Agent
  prompt: |
    You are a helpful customer service representative.
    Respond to customer inquiries professionally.

    Customer: {memory.customerName}
    Issue: {memory.issueCategory}
    Current Time: {system.currentTime}
  llmConfig:
    name: ChatOpenAI
    properties:
      model: gpt-4o
      temperature: 0.7
      max_tokens: 500

Placeholder Support

Prompt nodes support the following placeholder syntax:

  • Memory placeholders: {memory.propertyName} - Access values from the agent's memory state

  • Nested memory values: {memory.customer.name} - Access nested properties in memory

  • System placeholders: {system.currentTime} - Access system values like the current ISO timestamp

LLM Configuration Options

# OpenAI
llmConfig:
  name: ChatOpenAI
  properties:
    model: gpt-4o        # or gpt-4o-mini, gpt-3.5-turbo
    temperature: 0.7     # 0.0 (deterministic) to 1.0 (creative)
    max_tokens: 500

# Anthropic Claude
llmConfig:
  name: ChatAnthropic
  properties:
    model: claude-3-sonnet-20240229
    temperature: 0.5
    max_tokens: 1000

Tool Nodes

Tool nodes execute functions to perform actions like API calls or database queries.

Basic Tool Node

- type: tool
  name: Lookup Customer Order
  toolName: lookupOrder

Tool Implementation

import { z } from 'zod';
import { Tool } from 'mindedjs/src/types/Tools.types';

const schema = z.object({
  orderId: z.string(),
  customerEmail: z.string().optional(),
});

const lookupOrderTool: Tool<typeof schema, Memory> = {
  name: 'lookupOrder',
  description: 'Look up order details by order ID',
  input: schema,
  execute: async ({ input, memory }) => {
    const order = await fetchOrderById(input.orderId);

    if (!order) {
      throw new Error(`Order ${input.orderId} not found`);
    }

    return {
      memory: {
        orderInfo: order,
        orderStatus: order.status,
      },
      result: `Found order ${order.id} - Status: ${order.status}`,
    };
  },
};

export default lookupOrderTool;

Junction Nodes

Junction nodes provide flow control without processing, useful for organizing routing logic.

Basic Junction

- type: junction
  name: Customer Routing Hub

Routing Example

nodes:
  - type: junction
    name: Route Customer Request
  - type: promptNode
    name: VIP Support
  - type: promptNode
    name: Standard Support

edges:
  - source: Route Customer Request
    target: VIP Support
    type: logicalCondition
    condition: "({ memory }) => memory.customerTier === 'premium'"

  - source: Route Customer Request
    target: Standard Support
    type: logicalCondition
    condition: "({ memory }) => memory.customerTier === 'standard'"

Jump To Nodes

Jump To nodes provide direct navigation to specific nodes, enabling flow transitions and subflow execution.

Basic Jump To Node

- type: jumpToNode
  name: Go To Order Processing
  targetNodeId: Process Customer Order

Subflow Navigation

Jump To nodes are particularly useful for organizing complex workflows into multiple flows:

# Main flow
- type: jumpToNode
  name: Jump To Refund Subflow
  targetNodeId: Refund Processing Trigger

# In refund subflow
- type: trigger
  name: Refund Processing Trigger
  triggerType: manual

Multi-Flow Example

# flows/mainFlow.yaml
nodes:
  - type: trigger
    name: Customer Request
    triggerType: manual

  - type: promptNode
    name: Classify Request
    prompt: |
      Classify the customer request as either 'refund' or 'support'.
      Customer message: {{messages.last.content}}

  - type: jumpToNode
    name: Go To Refund Flow
    targetNodeId: Refund Processor

# flows/refundFlow.yaml
nodes:
  - type: trigger
    name: Refund Processor
    triggerType: manual

  - type: tool
    name: Process Refund
    toolName: processRefund

Implementation Notes

  • Direct Navigation: Jump To nodes create direct edges to their target nodes

  • Cross-Flow Support: Target nodes can exist in different flow files

  • State Preservation: Current memory and message state is maintained during jumps

  • No Processing: Jump To nodes perform no data processing, only navigation

Best Practices

Use Descriptive Names

# ✅ Good
- type: promptNode
  name: Technical Support Specialist

# ❌ Avoid
- type: promptNode
  name: Agent 1

Keep Prompts Focused

# ✅ Good - Specific role and context
- type: promptNode
  name: Order Refund Processor
  prompt: |
    You process customer refund requests for e-commerce orders.
    Order ID: {{memory.orderId}}
    Determine if refund should be approved based on order status and timing.

# ❌ Avoid - Too broad
- type: promptNode
  name: General Assistant
  prompt: 'Help the customer with anything they need'

Browser Task Nodes

Browser task nodes allow your agent to interact with web pages using AI-powered automation.

Basic Browser Task

- type: browserTask
  name: search_products
  displayName: Search Products
  prompt: 'Go to amazon.com and search for wireless headphones under $100'

Browser Task with Custom Model

You can specify which AI model to use for browser automation:

- type: browserTask
  name: complex_task
  displayName: Complex Web Task
  prompt: 'Navigate to the support page and fill out the contact form'
  model: 'gpt-4o' # Options: gpt-4o (default), gpt-4-turbo, claude-3-opus, etc.

The browser task will execute the prompt using the browser-use CLI tool, which provides AI-powered browser automation capabilities.

Next Steps

  • Edges - Connect nodes with intelligent routing

  • Tools - Build powerful tool functions

  • Memory Types - Design effective state management

Nodes are your building blocks - combine them strategically to create powerful AI workflows! 🔧

Last updated