NodesCore
AI Agent
Run an LLM-backed workflow step with a prompt, chat model, and optional tools.
AI Agent
Description
AIAgent runs a model against each workflow item. It is the main built-in node for classification, extraction, summarization, routing, and tool-enabled agent flows.
Examples
Basic usage: classify inbound mail into RFQ or other
new AIAgent<{ subject: string; body: string }, { outcome: "rfq" | "other"; reasoning: string }>(
"Classify RFQ vs other",
'Respond with strict JSON only. Shape: {"outcome":"rfq"|"other","reasoning":"..."}',
(item) => JSON.stringify(item.json),
openAiChatModelPresets.demoGpt4oMini,
);Example input:
{
"subject": "RFQ for 1000 widgets",
"body": "Please send pricing and lead times."
}Example output:
{
"outcome": "rfq",
"reasoning": "The sender is explicitly requesting a quote."
}Advanced usage: use tools before returning a structured answer
new AIAgent(
"Answer with product context",
"Use the available tools when needed, then answer with a final structured result.",
(item) => JSON.stringify(item.json),
openAiChatModelPresets.demoGpt4oMini,
[new SearchDocsToolConfig(), new PricingLookupToolConfig()],
);Example input:
{
"question": "Can the Pro plan process Gmail attachments, and what does it cost?"
}Example output:
{
"answer": "Yes. The Pro plan supports Gmail attachment processing.",
"recommendedPlan": "pro",
"monthlyPrice": 99
}