Academy
⌘K
Getting Started
  • Platform Overview
  • AWS Marketplace Setup
  • Quickstart Guide
Connections
  • Overview
Workflow Builder
  • Overview
  • Nodes Catalog
Helix AI Assistant
  • Overview
Mapping Engine
  • Overview
Workflow Library
  • Overview
  • HL7
  • FHIR
  • Insurance
  • Agentic
  • Mapping
Security & Infrastructure
  • Architecture
  • HIPAA Compliance
  • Performance & Scalability
← Back to ConnectHealth
Get Started
Back to Nodes
AI Agent1 input → 1 output

AI Tool (Function)

payload (any)aiagent (object)AI AgentAI Tool (Function)payload (any)aiagent.tools (array)Data flowProperty

Creates a JavaScript function-based tool that the AI Agent can call to execute custom logic.

Inputs

payload any
Message from upstream node
aiagent object
AI configuration passed through the flow

Outputs

  1. Output 1 - To Next Node
    payload any
    Original payload passed through
    aiagent.tools array
    Updated tools array with this function tool added
  2. Output 2

    Not used during initial message pass. Function executes inline when AI calls the tool.

Details

Function tools let you write custom JavaScript that the AI can invoke. Perfect for:

  • Data transformations
  • Calculations
  • Calling external APIs
  • Database operations

Configuration

Tool Name
Unique identifier (letters, numbers, underscores, hyphens only)
Description
Tell the AI what this function does
Function Code
JavaScript code to execute. Has access to:
  • input - Arguments provided by the AI
  • context - Node-RED context object
  • node - The Node-RED node instance

Examples

Calculate Age:

// Tool: calculate_age
// Description: Calculate age from date of birth
const dob = new Date(input.dateOfBirth);
const today = new Date();
const age = today.getFullYear() - dob.getFullYear();
return { age: age };

Format Currency:

// Tool: format_currency
const amount = parseFloat(input.amount);
const formatted = new Intl.NumberFormat('en-US', {
  style: 'currency',
  currency: 'USD'
}).format(amount);
return formatted;

Best Practices

  • Use new Date() instead of Date()
  • Always return a value (AI receives this as tool result)
  • Handle errors gracefully with try/catch
  • Keep functions focused on single tasks