词元之母TOK.MOM - 平台充值汇率 1:1 即 1 人民币充值到账 1 美元,支持一个 Key 调用近 600+ 海内外模型,限时特价模型低至 1 折,欢迎上岸!
提示:本文示例默认用于“表达式模式”。请将输入框切换为 Expression,并用 {{ ... }}包裹表达式。
{{ 表达式 }}json/binary 数据{{ $json.title || $json.name || "未命名" }}$input.item:当前正在处理的输入项(包含 json 与可选 binary)$input.all():返回所有输入项数组$input.first() / $input.last():第一项 / 最后一项$input.params:上游节点的设置快照(如结果限制、操作类型)$json:$input.item.json 的简写$binary:$input.item.binary 的简写$input.context.noItemsLeft:仅在“Loop Over Items”场景下,是否无剩余项{{ $json.name }}
{{ $input.all().map(i => i.json.id) }}
{{ $input.first().json.title }}$("<node-name>") 访问指定节点:$("节点名").all(branchIndex?, runIndex?)$("节点名").first(branchIndex?, runIndex?)$("节点名").last(branchIndex?, runIndex?)$("节点名").item:与当前项相连的那一条输出$("节点名").params:该节点的配置参数快照$("节点名").itemMatching(currentNodeInputIndex):在 Code 节点追溯输入来源{{ $("HTTP Request").first().json.title }}
{{ $("Create User").item.json.id }}$env:读取环境变量(如 .env)$execution.*:本次执行上下文(id、mode、resumeUrl、customData)$getWorkflowStaticData(type):读写工作流级静态数据(global/node)$("节点名").isExecuted:该节点是否已执行$itemIndex:当前项的索引(从 0 开始)$nodeVersion:当前节点版本$prevNode.*:上一个节点信息(name/outputIndex/runIndex)$runIndex:当前节点运行轮次$secrets:密钥集合$vars:可用的变量集合$version:n8n 版本$workflow.*:工作流信息(id/name/active){{ $env["API_KEY"] }}
{{ $workflow.id }}
{{ $execution.mode }}$now:当前时间(Luxon DateTime)$today:今日(去时分秒的 DateTime){{ $now.toISO() }}
{{ $today.toFormat('yyyy-LL-dd') }}$http.pagination.page / perPage / total / totalPages{{ $http.pagination.page }}$llmInput:模型输入$generateText():生成文本的方法$memory:记忆对象{{ $generateText($llmInput) }}$jmespath(expression, data){
"users": [
{ "id": 1, "name": "John", "email": "john@example.com" },
{ "id": 2, "name": "Jane", "email": "jane@example.com" }
]
}{{ $jmespath('users[*].email', $json) }} // => ["john@example.com","jane@example.com"]
{{ $jmespath('users[?id > `1`]', $json) }} // => 过滤出 id>1 的用户$evaluateExpression(expression, itemIndex?):把字符串当表达式求值$ifEmpty(value, defaultValue):空值兜底$if(condition, valueIfTrue, valueIfFalse):条件分支$max(...numbers) / $min(...numbers):求最大/最小{{ $evaluateExpression('1 + 2') }} // 3
{{ $ifEmpty($json.description, 'No description') }}
{{ $if($json.status === 'success', 'OK', 'Error') }}
{{ $max(3, 5, 1) }} {{ $min(3, 5, 1) }}{{ ($json.title || '').toLowerCase() }}
{{ ($json.text || '').includes('关键字') }}
{{ ($json.slug || '').trim().replace(/\s+/g,'-') }}{{ Number($json.count || 0) }}
{{ (Number($json.price)||0).toFixed(2) }}{{ ($json.items || []).map(i => i.id) }}
{{ ($json.items || [])[0] }} // 第一项
{{ ($json.items || []).filter(i => i.ok) }}
{{ Array.from(new Set(($json.tags||[]))) }} // 唯一化{{ Object.keys($json) }}
{{ JSON.stringify($json.payload || {}) }}{{ $now.plus({ days: 7 }).toISO() }}
{{ $now.setZone('Asia/Shanghai').toFormat('yyyy-LL-dd HH:mm') }}{{ $json.email }}{{ $("Webhook").first().json.message }}{{ $workflow.name }} - {{ $execution.id }}{{ $today.toFormat('yyyy-LL-dd') }} / {{ $now.plus({days:7}).toFormat('yyyy-LL-dd') }}{{ $jmespath('data.items[?active==`true`].name', $json) }}$json、$binary、$input.item、$input.all()、$input.first()、$input.last()$("节点名").first().json、$("节点名").item.json$env、$workflow.*、$execution.*、$runIndex、$itemIndex$now、$today(配合 toISO() / toFormat())$jmespath(expr, data)$if()、$ifEmpty()$evaluateExpression()、$max()、$min(){{ }} 包裹表达式;字符串内的花括号请转义toFormat('yyyy-LL-dd') 等新式 tokens,避免 YYYY-MM-DDfirst(runIndex) 精确定位参考官方文档可获取最准确的行为说明。如遇表达式报错,先在“执行数据”面板检查上游结构与字段名是否存在,再逐步缩小表达式范围定位问题。