@addai/flows-mcp 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +1 -0
- package/dist/client.js +1 -0
- package/dist/client.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/instructions.d.ts +6 -0
- package/dist/instructions.js +139 -0
- package/dist/instructions.js.map +1 -0
- package/dist/node-defaults.js +398 -26
- package/dist/node-defaults.js.map +1 -1
- package/dist/prompts.d.ts +2 -0
- package/dist/prompts.js +721 -0
- package/dist/prompts.js.map +1 -0
- package/dist/tools/custom-nodes.js +14 -9
- package/dist/tools/custom-nodes.js.map +1 -1
- package/dist/tools/nodes.js +3 -3
- package/dist/tools/nodes.js.map +1 -1
- package/dist/tools/reference.js +6 -3
- package/dist/tools/reference.js.map +1 -1
- package/dist/tools/runs.js +112 -1
- package/dist/tools/runs.js.map +1 -1
- package/dist/tools/variables.js +1 -1
- package/dist/tools/variables.js.map +1 -1
- package/dist/types.d.ts +13 -0
- package/package.json +11 -3
package/dist/prompts.js
ADDED
|
@@ -0,0 +1,721 @@
|
|
|
1
|
+
export function registerPrompts(server) {
|
|
2
|
+
server.prompt('flow-guide', 'Complete reference for building +Ai Flows. Covers every node type, variable syntax, form elements, conditions, handles, and common patterns. Load this before building or modifying flows.', async () => ({
|
|
3
|
+
messages: [{
|
|
4
|
+
role: 'user',
|
|
5
|
+
content: {
|
|
6
|
+
type: 'text',
|
|
7
|
+
text: FLOW_GUIDE
|
|
8
|
+
}
|
|
9
|
+
}]
|
|
10
|
+
}));
|
|
11
|
+
}
|
|
12
|
+
const FLOW_GUIDE = `
|
|
13
|
+
# +Ai Flows — Complete Builder Reference
|
|
14
|
+
|
|
15
|
+
## MCP Tools Overview
|
|
16
|
+
|
|
17
|
+
| Tool | Purpose |
|
|
18
|
+
|------|---------|
|
|
19
|
+
| \`list_flows\` | List all flows in workspace |
|
|
20
|
+
| \`get_flow\` | Get full flow (nodes, edges, variables) |
|
|
21
|
+
| \`create_flow\` | Create new flow with trigger type |
|
|
22
|
+
| \`update_flow\` | Save full flow state |
|
|
23
|
+
| \`delete_flow\` / \`duplicate_flow\` | Delete or clone |
|
|
24
|
+
| \`add_nodes\` | Add nodes + edges in one call |
|
|
25
|
+
| \`update_node\` | Update node data (merged with existing) |
|
|
26
|
+
| \`remove_nodes\` | Remove nodes + connected edges |
|
|
27
|
+
| \`connect_nodes\` / \`disconnect_nodes\` | Manage edges |
|
|
28
|
+
| \`validate_flow\` | Check for errors before publishing |
|
|
29
|
+
| \`publish_flow\` | Publish as production version |
|
|
30
|
+
| \`run_flow\` | Start a production run |
|
|
31
|
+
| \`list_runs\` / \`get_run\` / \`get_node_output\` | Inspect runs |
|
|
32
|
+
| \`manage_run\` | Cancel/pause/unpause/delete runs |
|
|
33
|
+
| \`set_variable\` / \`list_variables\` / \`delete_variable\` | Flow variables |
|
|
34
|
+
| \`list_node_types\` / \`get_node_type_info\` | Node reference |
|
|
35
|
+
| \`list_page_elements\` / \`get_page_element_info\` | Form elements |
|
|
36
|
+
| \`list_custom_nodes\` / \`create_custom_node\` | Custom nodes |
|
|
37
|
+
| \`create_version\` / \`list_versions\` / \`revert_to_version\` | Versioning |
|
|
38
|
+
| \`create_split_test\` / \`start_split_test\` / \`stop_split_test\` | A/B testing |
|
|
39
|
+
| \`get_flow_stats\` / \`get_runs_stats\` / \`get_outcome_breakdown\` | Analytics |
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Variable Syntax — Three Distinct Systems
|
|
44
|
+
|
|
45
|
+
### 1. Config Fields (node data: URL, body, conditions, element defaults, etc.)
|
|
46
|
+
|
|
47
|
+
Template syntax resolved at runtime:
|
|
48
|
+
|
|
49
|
+
\`\`\`
|
|
50
|
+
{{nodeId.fieldName}} → Field from upstream node output
|
|
51
|
+
{{nodeId.nested.path}} → Dot notation for nested data
|
|
52
|
+
{{nodeId.array[0]}} → Array index access
|
|
53
|
+
{{nodeId.array[#]}} → Shorthand for [0]
|
|
54
|
+
{{Variables.myVar}} → Flow variable value
|
|
55
|
+
\`\`\`
|
|
56
|
+
|
|
57
|
+
### 2. Code Nodes (inline JavaScript sandbox)
|
|
58
|
+
|
|
59
|
+
\`\`\`javascript
|
|
60
|
+
// Access upstream node outputs by node ID
|
|
61
|
+
const data = $("abc-123-node-id");
|
|
62
|
+
const name = $("trigger-id").body.name;
|
|
63
|
+
|
|
64
|
+
// Logging
|
|
65
|
+
console.log("Debug:", data);
|
|
66
|
+
|
|
67
|
+
// HTTP requests (localhost/private IPs blocked)
|
|
68
|
+
const response = await fetch("https://api.example.com/data");
|
|
69
|
+
const json = await response.json();
|
|
70
|
+
|
|
71
|
+
// MUST return an object — keys become node output fields
|
|
72
|
+
return {
|
|
73
|
+
result: json,
|
|
74
|
+
count: json.items.length
|
|
75
|
+
};
|
|
76
|
+
\`\`\`
|
|
77
|
+
|
|
78
|
+
In \`runForEachItem\` mode: \`item\` (current array element) and \`index\` (current position) are available.
|
|
79
|
+
|
|
80
|
+
**NEVER use \`{{}}\` template syntax in code. NEVER use \`$input\`.**
|
|
81
|
+
|
|
82
|
+
### 3. Custom Node Code (separate sandbox)
|
|
83
|
+
|
|
84
|
+
\`\`\`javascript
|
|
85
|
+
// Inputs pre-resolved from input_schema ({{}} templates already resolved)
|
|
86
|
+
const url = inputs.api_url;
|
|
87
|
+
const apiKey = secrets.api_key;
|
|
88
|
+
|
|
89
|
+
const response = await fetch(url, {
|
|
90
|
+
headers: { 'Authorization': \\\`Bearer \\\${apiKey}\\\` }
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// MUST return object matching output_schema keys
|
|
94
|
+
return {
|
|
95
|
+
data: await response.json(),
|
|
96
|
+
status: response.status
|
|
97
|
+
};
|
|
98
|
+
\`\`\`
|
|
99
|
+
|
|
100
|
+
**NEVER use \`$("nodeId")\` in custom node code. Use \`inputs.keyName\` instead.**
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Edge Handles — Connecting Branching Nodes
|
|
105
|
+
|
|
106
|
+
Most nodes have a single default output (no \`source_handle\` needed). Branching nodes require specific handles:
|
|
107
|
+
|
|
108
|
+
| Node Type | Source Handles | Notes |
|
|
109
|
+
|-----------|---------------|-------|
|
|
110
|
+
| \`if\` | \`"true"\`, \`"false"\` | Based on condition evaluation |
|
|
111
|
+
| \`switch\` | Case \`outputLabel\` values, \`"default"\` | outputLabel defined per case |
|
|
112
|
+
| \`loop\` | \`"loop"\`, \`"done"\`, \`"fail"\` | "fail" only if \`enableFailRoute: true\` |
|
|
113
|
+
| \`review\` | \`"option_0"\`, \`"option_1"\`, ... | One handle per review option |
|
|
114
|
+
| \`page\` | \`"right"\` (submission), abandonment IDs | Abandonment handles from \`abandonments\` array |
|
|
115
|
+
| \`splitTest\` | Variant labels: \`"Variant A"\`, \`"Variant B"\` | Match the variant label strings |
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## All Node Types — Complete Reference
|
|
120
|
+
|
|
121
|
+
### Trigger Nodes
|
|
122
|
+
|
|
123
|
+
Every flow must start with one trigger node.
|
|
124
|
+
|
|
125
|
+
#### Webhook Trigger (\`trigger\`)
|
|
126
|
+
- Starts flow on HTTP request
|
|
127
|
+
- Output: \`{ body, headers, query, method, url }\`
|
|
128
|
+
- Downstream: \`{{triggerId.body.fieldName}}\`
|
|
129
|
+
|
|
130
|
+
#### Schedule Trigger (\`scheduleTrigger\`)
|
|
131
|
+
- Runs on interval or cron
|
|
132
|
+
- Data: \`scheduleType: "interval"|"cron"\`, \`intervalValue\`, \`intervalUnit\` (seconds/minutes/hours/days), \`cronExpression\`, \`timezone\`
|
|
133
|
+
- Output: \`{ scheduledTime, scheduleType }\`
|
|
134
|
+
|
|
135
|
+
#### Email Trigger (\`emailTrigger\`)
|
|
136
|
+
- Starts flow on email receipt
|
|
137
|
+
- Output: \`{ from, to, subject, text, html, attachments }\`
|
|
138
|
+
|
|
139
|
+
#### Start Form (\`startForm\`)
|
|
140
|
+
- Public form URL triggers flow
|
|
141
|
+
- Data: \`elements\` array (form fields), \`pageStyle\`, \`formSlug\`
|
|
142
|
+
- Output: \`{ formData: { "Element Label": value }, urlParams, submittedAt }\`
|
|
143
|
+
- Downstream: \`{{startFormId.formData.Email}}\`
|
|
144
|
+
|
|
145
|
+
#### Table Triggers (\`tableTrigger\`, \`tableButton\`, \`tableActionTrigger\`, \`batchActionTrigger\`, \`tablesSchedule\`)
|
|
146
|
+
- Fire on +Ai Table events (INSERT/UPDATE/DELETE, button clicks, batch actions, schedules)
|
|
147
|
+
- Output includes: \`row\`, \`rowId\`, \`tableId\`, \`databaseId\`, event-specific fields
|
|
148
|
+
|
|
149
|
+
### Processing Nodes
|
|
150
|
+
|
|
151
|
+
#### HTTP Request (\`httpRequest\`)
|
|
152
|
+
- Makes external API calls
|
|
153
|
+
- Key data fields:
|
|
154
|
+
- \`url\`: string (supports \`{{}}\` templates)
|
|
155
|
+
- \`method\`: GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS
|
|
156
|
+
- \`headers\`: \`[{key, value, enabled: true}]\`
|
|
157
|
+
- \`queryParams\`: \`[{key, value, enabled: true}]\`
|
|
158
|
+
- \`bodyType\`: none|json|text|xml|form|file
|
|
159
|
+
- \`body\`: string (for json/text/xml — supports \`{{}}\`)
|
|
160
|
+
- \`formFields\`: \`[{key, value, type: "text"|"file", enabled}]\` (for form)
|
|
161
|
+
- \`fileBody\`: variable reference (for file), \`fileContentType\`: MIME type
|
|
162
|
+
- \`authentication\`: \`{type: "none"|"bearer"|"basic"|"apikey", token?, username?, password?, apiKeyHeader?, apiKeyValue?}\`
|
|
163
|
+
- \`timeout\`: ms (default 30000), \`retries\`: 0-10
|
|
164
|
+
- \`storeHeaders\`: boolean, \`onError\`: "stop"|"continue"
|
|
165
|
+
- Output: \`{ status, body, headers?, success, error? }\`
|
|
166
|
+
|
|
167
|
+
#### Code (\`code\`)
|
|
168
|
+
- Inline JavaScript sandbox
|
|
169
|
+
- Data: \`mode: "runOnce"|"runForEachItem"\`, \`code\`, \`itemsPath\` (for runForEachItem), \`onError: "stop"|"continue"\`
|
|
170
|
+
- Globals: \`$("nodeId")\`, \`console\`, \`fetch()\`
|
|
171
|
+
- runForEachItem: \`item\`, \`index\` available
|
|
172
|
+
- Output: whatever the code returns (spread into output)
|
|
173
|
+
|
|
174
|
+
#### Respond to Webhook (\`respondToWebhook\`)
|
|
175
|
+
- Sends HTTP response to webhook caller
|
|
176
|
+
- Data: \`statusCode\`, \`responseBody\` (string, supports \`{{}}\`), \`bodyType: "json"|"text"|"html"\`, \`headers: [{key, value}]\`
|
|
177
|
+
- Only works in Webhook Trigger flows
|
|
178
|
+
|
|
179
|
+
#### Map Data (\`map\`)
|
|
180
|
+
- Transforms data fields
|
|
181
|
+
- Data: \`mappings\` array, \`transformMode: "standard"|"batch"|"merge"|"restructure"\`
|
|
182
|
+
- Each mapping: \`{id, inputExpression: "{{nodeId.field}}", outputName: "key", transformType, enabled, description}\`
|
|
183
|
+
- Transform types (17): direct, toString, toNumber, toBoolean, toJson, stringify, lowercase, uppercase, trim, length, split (delimiter), join (separator), extract (pattern), replace (find+replaceWith), template (template), calculate (expression), custom (customCode)
|
|
184
|
+
- Output: \`{ [outputName]: transformedValue, _metadata: {successfulMappings, failedMappings, totalMappings} }\`
|
|
185
|
+
|
|
186
|
+
### Logic Nodes
|
|
187
|
+
|
|
188
|
+
#### If Condition (\`if\`)
|
|
189
|
+
- Binary branching
|
|
190
|
+
- Data: \`conditions\` array, \`conditionLogic: "and"|"or"\`
|
|
191
|
+
- Each condition: \`{id, leftValue: "{{nodeId.field}}", operator, rightValue, dataType, range?, expression?}\`
|
|
192
|
+
- Operators (23): equals, not_equals, greater_than, greater_than_or_equal, less_than, less_than_or_equal, contains, not_contains, starts_with, ends_with, matches_regex, is_empty, is_not_empty, is_null, is_not_null, is_true, is_false, in_array, not_in_array, array_contains, array_length, between, custom_expression
|
|
193
|
+
- dataType: auto, string, number, boolean, array, object, date
|
|
194
|
+
- \`between\` operator: add \`range: {min, max}\`. \`custom_expression\`: add \`expression\`
|
|
195
|
+
- Handles: \`"true"\`, \`"false"\`
|
|
196
|
+
- Output: \`{ conditionMet, evaluatedConditions, logicOperator }\`
|
|
197
|
+
|
|
198
|
+
#### Switch (\`switch\`)
|
|
199
|
+
- Multi-path branching
|
|
200
|
+
- Data: \`cases\` array, \`mode: "first"|"all"\`, \`hasDefault: true\`
|
|
201
|
+
- Each case: \`{id: "case_<ts>", label, outputLabel: "case-0", conditions: [...], logicOperator: "AND"|"OR", enabled: true}\`
|
|
202
|
+
- Same condition format as If node
|
|
203
|
+
- Handles: \`"<outputLabel>"\` per case + \`"default"\`
|
|
204
|
+
- Output: \`{ matchedHandles, matchedCaseLabels, hasDefault, mode }\`
|
|
205
|
+
|
|
206
|
+
#### Loop (\`loop\`)
|
|
207
|
+
- Iterates over arrays
|
|
208
|
+
- Data: \`arraySources: ["{{nodeId.field}}"]\`, \`enableFailRoute: false\`
|
|
209
|
+
- During iteration, downstream nodes access: \`{{loopId.currentItem}}\`, \`{{loopId.currentIndex}}\`, \`{{loopId.totalItems}}\`
|
|
210
|
+
- Handles: \`"loop"\` (per item), \`"done"\` (after all), \`"fail"\` (on error if enableFailRoute)
|
|
211
|
+
- Output: \`{ items, totalItems, currentItem, currentIndex }\`
|
|
212
|
+
|
|
213
|
+
#### Wait (\`wait\`)
|
|
214
|
+
- Pauses execution
|
|
215
|
+
- Data: \`waitType: "duration"|"until"\`, \`duration\`, \`durationUnit: "seconds"|"minutes"|"hours"|"days"\`
|
|
216
|
+
- Waits >30s persist to database and auto-resume
|
|
217
|
+
|
|
218
|
+
#### Flow (\`flow\`)
|
|
219
|
+
- Executes another flow as sub-flow
|
|
220
|
+
- Data: \`flowId\`, \`flowName\`, \`waitForCompletion: true\`, \`body: "{}"\` (JSON string, supports \`{{}}\`)
|
|
221
|
+
- Output: \`{ flowId, flowName, runId, waitedForCompletion, status, success, outputs }\`
|
|
222
|
+
|
|
223
|
+
#### Variable (\`variable\`)
|
|
224
|
+
- Manages flow variables
|
|
225
|
+
- **Create**: \`action: "create"\`, \`variables: [{name, type, defaultValue, isList, deduplicate}]\`
|
|
226
|
+
- **Update**: \`action: "update"\`, \`variableName\`, \`operator\`, \`value\` (supports \`{{}}\`)
|
|
227
|
+
- **Delete**: \`action: "delete"\`, \`variableName\`
|
|
228
|
+
- Types: string, number, boolean, object
|
|
229
|
+
- String operators: set, concat, append
|
|
230
|
+
- Number operators: set, add, subtract, multiply, divide
|
|
231
|
+
- List operators (isList: true): set, push, pop, shift, unshift, concat, unique, reverse, sort
|
|
232
|
+
- Variables accessed as \`{{Variables.varName}}\` in config fields
|
|
233
|
+
|
|
234
|
+
#### Review (\`review\`)
|
|
235
|
+
- Human approval gate
|
|
236
|
+
- Data: \`title\`, \`description\`, \`fields: [{id, label, value: "{{nodeId.field}}"}]\`, \`options: [{id: "option_0", label: "Approve", color: "green"}]\`
|
|
237
|
+
- Colors: green, red, blue, yellow, orange, purple, gray
|
|
238
|
+
- Handles: \`"option_0"\`, \`"option_1"\`, etc.
|
|
239
|
+
- Output: \`{ selectedOption, selectedOptionLabel, reviewData: {label: value}, respondedBy, respondedDate }\`
|
|
240
|
+
|
|
241
|
+
#### Page (\`page\`)
|
|
242
|
+
- Public form page, pauses flow until submission
|
|
243
|
+
- Data: \`elements\` array, \`abandonments: [{id, name, delay, delayUnit}]\`, \`pageStyle\`, \`loadingConfig\`
|
|
244
|
+
- Elements: see Form Elements section below
|
|
245
|
+
- Handles: \`"right"\` (submitted), abandonment IDs
|
|
246
|
+
- Output: \`{ submissionData: {"Element Label": value}, submittedDate, status, activeHandle }\`
|
|
247
|
+
- Downstream: \`{{pageId.submissionData.Email}}\`
|
|
248
|
+
|
|
249
|
+
#### Split Test (\`splitTest\`)
|
|
250
|
+
- A/B traffic routing
|
|
251
|
+
- Data: \`variants: [{id: "v_0", label: "Variant A", percentage: 50}, ...]\` (must sum to 100)
|
|
252
|
+
- Handles: variant labels \`"Variant A"\`, \`"Variant B"\`
|
|
253
|
+
- Output: \`{ selectedHandle, selectedLabel, selectedVariantId }\`
|
|
254
|
+
|
|
255
|
+
#### Goal (\`goal\`) / Exit (\`exit\`)
|
|
256
|
+
- Terminal nodes (no output handles)
|
|
257
|
+
- Goal = success outcome, Exit = alternative outcome
|
|
258
|
+
- Data: \`goalName\` / \`exitName\` (for analytics)
|
|
259
|
+
|
|
260
|
+
#### Subflow (\`subflow\`)
|
|
261
|
+
- Visual grouping only — no execution effect
|
|
262
|
+
|
|
263
|
+
#### Note (\`note\`)
|
|
264
|
+
- Canvas annotation — not connected to flow
|
|
265
|
+
|
|
266
|
+
#### Custom Node (\`customNode\`)
|
|
267
|
+
- Uses published custom node definition
|
|
268
|
+
- Data: \`customNodeId\`, \`customVersionId\`, \`onError: "stop"|"continue"\`, plus input values matching input_schema keys
|
|
269
|
+
- Input values support \`{{nodeId.field}}\` templates (resolved before code runs)
|
|
270
|
+
- Code receives: \`inputs.keyName\`, \`secrets.keyName\`, \`fetch()\`
|
|
271
|
+
- Output: keys from output_schema
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Form Elements Reference
|
|
276
|
+
|
|
277
|
+
Used in \`page\` and \`startForm\` nodes' \`elements\` array. Each element needs:
|
|
278
|
+
|
|
279
|
+
\`\`\`javascript
|
|
280
|
+
{
|
|
281
|
+
id: crypto.randomUUID(), // unique ID
|
|
282
|
+
type: "shortText", // element type
|
|
283
|
+
label: "Field Name", // display label AND the key in submissionData
|
|
284
|
+
// ...type-specific config
|
|
285
|
+
}
|
|
286
|
+
\`\`\`
|
|
287
|
+
|
|
288
|
+
### Input Elements (produce submission data)
|
|
289
|
+
|
|
290
|
+
| Type | Description | Key Config |
|
|
291
|
+
|------|-------------|------------|
|
|
292
|
+
| \`shortText\` | Single-line text | \`placeholder\`, \`required\`, \`defaultValue\`, \`helpText\`, \`width\` |
|
|
293
|
+
| \`longText\` | Multi-line textarea | \`placeholder\`, \`required\`, \`defaultValue\`, \`rows: 4\` |
|
|
294
|
+
| \`email\` | Email input | \`placeholder\`, \`required\`, \`defaultValue\` |
|
|
295
|
+
| \`url\` | URL input | \`placeholder\`, \`required\`, \`defaultValue\` |
|
|
296
|
+
| \`number\` | Numeric input | \`placeholder\`, \`required\`, \`min\`, \`max\`, \`step\` |
|
|
297
|
+
| \`date\` | Date picker | \`placeholder\`, \`required\`, \`includeTime: false\` |
|
|
298
|
+
| \`dateOfBirth\` | Day/Month/Year | \`required\` |
|
|
299
|
+
| \`dropdown\` | Select from options | \`required\`, \`options: [{id, label, value}]\`, \`allowMultiple\` |
|
|
300
|
+
| \`multipleChoice\` | Radio/checkbox | \`required\`, \`options: [{id, label, value}]\`, \`allowMultiple\` |
|
|
301
|
+
| \`fileUpload\` | File upload | \`required\`, \`accept\` (MIME), \`maxSize\` (MB), \`maxFiles\` |
|
|
302
|
+
| \`signature\` | Signature pad | \`required\` |
|
|
303
|
+
| \`audioRecorder\` | Audio recording | \`required\`, \`maxDuration: 120\`, \`audioFormat: "webm"\` |
|
|
304
|
+
| \`button\` | Submit/action button | \`buttonText\`, \`buttonColor\`, \`buttonAlign\`, \`buttonAction: "submit"|"link"|"stop"|"restart"\`, \`buttonLink\` |
|
|
305
|
+
|
|
306
|
+
### Display Elements (no submission data)
|
|
307
|
+
|
|
308
|
+
| Type | Description | Key Config |
|
|
309
|
+
|------|-------------|------------|
|
|
310
|
+
| \`textBlock\` | Formatted text/markdown | \`content\` |
|
|
311
|
+
| \`image\` | Display image | \`src\` (URL or \`{{}}\`), \`alt\`, \`maxHeight\` |
|
|
312
|
+
| \`file\` | Downloadable file | \`src\`, \`fileName\` |
|
|
313
|
+
| \`video\` | Embedded video | \`src\`, \`autoplay\` |
|
|
314
|
+
| \`embed\` | External content | \`url\`, \`height\` |
|
|
315
|
+
|
|
316
|
+
### Layout: \`columns\` — \`{columns: [], gap: "1rem"}\`
|
|
317
|
+
### Width: \`"full"\` | \`"twoThirds"\` | \`"half"\` | \`"third"\`
|
|
318
|
+
|
|
319
|
+
### Form Styling
|
|
320
|
+
|
|
321
|
+
\`\`\`javascript
|
|
322
|
+
// pageStyle (on node.data)
|
|
323
|
+
{ backgroundColor: '#ffffff', backgroundImage: '', maxWidth: '640px', padding: '2rem',
|
|
324
|
+
showProgressBar: true, submitButtonText: 'Continue', submitButtonColor: '#3b82f6' }
|
|
325
|
+
|
|
326
|
+
// loadingConfig (Page node only)
|
|
327
|
+
{ enabled: true, text: 'Processing...', subtext: 'Please wait', animation: 'spinner', backgroundColor: '#ffffff' }
|
|
328
|
+
\`\`\`
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## Custom Node Schemas
|
|
333
|
+
|
|
334
|
+
### Input Schema
|
|
335
|
+
\`\`\`json
|
|
336
|
+
[{
|
|
337
|
+
"key": "fieldName",
|
|
338
|
+
"label": "Display Label",
|
|
339
|
+
"type": "string | number | boolean | object | array | select | code | textarea",
|
|
340
|
+
"required": true,
|
|
341
|
+
"default": "",
|
|
342
|
+
"description": "Help text in editor",
|
|
343
|
+
"options": [{ "label": "Option", "value": "val" }],
|
|
344
|
+
"condition": { "field": "otherKey", "value": "someValue", "operator": "equals" }
|
|
345
|
+
}]
|
|
346
|
+
\`\`\`
|
|
347
|
+
|
|
348
|
+
### Output Schema
|
|
349
|
+
\`\`\`json
|
|
350
|
+
[{ "key": "fieldName", "label": "Display Label", "type": "string", "description": "What this outputs" }]
|
|
351
|
+
\`\`\`
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## Concrete Examples — Actual Tool Calls
|
|
356
|
+
|
|
357
|
+
### Example 1: Build a Webhook → If → HTTP Request flow
|
|
358
|
+
|
|
359
|
+
**Step 1: Create the flow**
|
|
360
|
+
\`\`\`
|
|
361
|
+
create_flow({ name: "Order Processor", description: "Process incoming orders", trigger_type: "trigger" })
|
|
362
|
+
→ Returns: { id: "flow-abc-123" }
|
|
363
|
+
\`\`\`
|
|
364
|
+
|
|
365
|
+
**Step 2: Get the flow to find the trigger node ID**
|
|
366
|
+
\`\`\`
|
|
367
|
+
get_flow({ flow_id: "flow-abc-123" })
|
|
368
|
+
→ Returns flow with nodes: [{ id: "trigger-node-id", type: "trigger", ... }]
|
|
369
|
+
\`\`\`
|
|
370
|
+
|
|
371
|
+
**Step 3: Add all nodes + edges in one call using temp_id**
|
|
372
|
+
\`\`\`
|
|
373
|
+
add_nodes({
|
|
374
|
+
flow_id: "flow-abc-123",
|
|
375
|
+
nodes: [
|
|
376
|
+
{
|
|
377
|
+
type: "if",
|
|
378
|
+
temp_id: "my-if",
|
|
379
|
+
data: {
|
|
380
|
+
label: "Check Order Value",
|
|
381
|
+
conditions: [{
|
|
382
|
+
id: "cond-1",
|
|
383
|
+
leftValue: "{{trigger-node-id.body.total}}",
|
|
384
|
+
operator: "greater_than",
|
|
385
|
+
rightValue: "100",
|
|
386
|
+
dataType: "number"
|
|
387
|
+
}],
|
|
388
|
+
conditionLogic: "and"
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
type: "httpRequest",
|
|
393
|
+
temp_id: "my-api",
|
|
394
|
+
data: {
|
|
395
|
+
label: "Send to Fulfillment",
|
|
396
|
+
url: "https://api.example.com/fulfill",
|
|
397
|
+
method: "POST",
|
|
398
|
+
bodyType: "json",
|
|
399
|
+
body: "{\\"orderId\\": \\"{{trigger-node-id.body.id}}\\", \\"total\\": \\"{{trigger-node-id.body.total}}\\"}",
|
|
400
|
+
headers: [{ key: "Authorization", value: "Bearer {{Variables.apiKey}}", enabled: true }]
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
type: "goal",
|
|
405
|
+
temp_id: "my-goal",
|
|
406
|
+
data: { label: "Fulfilled", goalName: "Order Fulfilled" }
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
type: "exit",
|
|
410
|
+
temp_id: "my-exit",
|
|
411
|
+
data: { label: "Low Value", exitName: "Below Threshold" }
|
|
412
|
+
}
|
|
413
|
+
],
|
|
414
|
+
edges: [
|
|
415
|
+
{ source: "trigger-node-id", target: "my-if" },
|
|
416
|
+
{ source: "my-if", target: "my-api", source_handle: "true" },
|
|
417
|
+
{ source: "my-if", target: "my-exit", source_handle: "false" },
|
|
418
|
+
{ source: "my-api", target: "my-goal" }
|
|
419
|
+
]
|
|
420
|
+
})
|
|
421
|
+
\`\`\`
|
|
422
|
+
|
|
423
|
+
### Example 2: Page node with form elements
|
|
424
|
+
|
|
425
|
+
\`\`\`
|
|
426
|
+
add_nodes({
|
|
427
|
+
flow_id: "flow-abc-123",
|
|
428
|
+
nodes: [{
|
|
429
|
+
type: "page",
|
|
430
|
+
temp_id: "my-page",
|
|
431
|
+
data: {
|
|
432
|
+
label: "Contact Form",
|
|
433
|
+
elements: [
|
|
434
|
+
{
|
|
435
|
+
id: "elem-1",
|
|
436
|
+
type: "textBlock",
|
|
437
|
+
content: "Please fill in your details below"
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
id: "elem-2",
|
|
441
|
+
type: "shortText",
|
|
442
|
+
label: "Full Name",
|
|
443
|
+
placeholder: "Enter your name",
|
|
444
|
+
required: true,
|
|
445
|
+
width: "half"
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
id: "elem-3",
|
|
449
|
+
type: "email",
|
|
450
|
+
label: "Email",
|
|
451
|
+
placeholder: "your@email.com",
|
|
452
|
+
required: true,
|
|
453
|
+
width: "half"
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
id: "elem-4",
|
|
457
|
+
type: "dropdown",
|
|
458
|
+
label: "Department",
|
|
459
|
+
required: true,
|
|
460
|
+
options: [
|
|
461
|
+
{ id: "opt-1", label: "Sales", value: "sales" },
|
|
462
|
+
{ id: "opt-2", label: "Support", value: "support" },
|
|
463
|
+
{ id: "opt-3", label: "Billing", value: "billing" }
|
|
464
|
+
],
|
|
465
|
+
width: "full"
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
id: "elem-5",
|
|
469
|
+
type: "longText",
|
|
470
|
+
label: "Message",
|
|
471
|
+
placeholder: "How can we help?",
|
|
472
|
+
required: false,
|
|
473
|
+
rows: 4,
|
|
474
|
+
width: "full"
|
|
475
|
+
}
|
|
476
|
+
],
|
|
477
|
+
pageStyle: {
|
|
478
|
+
backgroundColor: "#f9fafb",
|
|
479
|
+
maxWidth: "640px",
|
|
480
|
+
padding: "2rem",
|
|
481
|
+
showProgressBar: false,
|
|
482
|
+
submitButtonText: "Submit",
|
|
483
|
+
submitButtonColor: "#3b82f6"
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}],
|
|
487
|
+
edges: [{ source: "previous-node-id", target: "my-page" }]
|
|
488
|
+
})
|
|
489
|
+
\`\`\`
|
|
490
|
+
|
|
491
|
+
After submission, downstream nodes access: \`{{my-page-real-id.submissionData.Full Name}}\`, \`{{my-page-real-id.submissionData.Email}}\`, \`{{my-page-real-id.submissionData.Department}}\`, \`{{my-page-real-id.submissionData.Message}}\`
|
|
492
|
+
|
|
493
|
+
### Example 3: Switch with multiple cases
|
|
494
|
+
|
|
495
|
+
\`\`\`
|
|
496
|
+
update_node({
|
|
497
|
+
flow_id: "flow-abc-123",
|
|
498
|
+
node_id: "switch-node-id",
|
|
499
|
+
data: {
|
|
500
|
+
label: "Route by Department",
|
|
501
|
+
mode: "first",
|
|
502
|
+
hasDefault: true,
|
|
503
|
+
cases: [
|
|
504
|
+
{
|
|
505
|
+
id: "case_1",
|
|
506
|
+
label: "Sales",
|
|
507
|
+
outputLabel: "case-0",
|
|
508
|
+
conditions: [{
|
|
509
|
+
id: "c1",
|
|
510
|
+
leftValue: "{{page-node-id.submissionData.Department}}",
|
|
511
|
+
operator: "equals",
|
|
512
|
+
rightValue: "sales",
|
|
513
|
+
dataType: "string"
|
|
514
|
+
}],
|
|
515
|
+
logicOperator: "AND",
|
|
516
|
+
enabled: true
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
id: "case_2",
|
|
520
|
+
label: "Support",
|
|
521
|
+
outputLabel: "case-1",
|
|
522
|
+
conditions: [{
|
|
523
|
+
id: "c2",
|
|
524
|
+
leftValue: "{{page-node-id.submissionData.Department}}",
|
|
525
|
+
operator: "equals",
|
|
526
|
+
rightValue: "support",
|
|
527
|
+
dataType: "string"
|
|
528
|
+
}],
|
|
529
|
+
logicOperator: "AND",
|
|
530
|
+
enabled: true
|
|
531
|
+
}
|
|
532
|
+
]
|
|
533
|
+
}
|
|
534
|
+
})
|
|
535
|
+
|
|
536
|
+
// Then connect edges:
|
|
537
|
+
connect_nodes({ flow_id: "...", source: "switch-node-id", target: "sales-handler-id", source_handle: "case-0" })
|
|
538
|
+
connect_nodes({ flow_id: "...", source: "switch-node-id", target: "support-handler-id", source_handle: "case-1" })
|
|
539
|
+
connect_nodes({ flow_id: "...", source: "switch-node-id", target: "default-handler-id", source_handle: "default" })
|
|
540
|
+
\`\`\`
|
|
541
|
+
|
|
542
|
+
### Example 4: Code node accessing upstream data
|
|
543
|
+
|
|
544
|
+
\`\`\`
|
|
545
|
+
update_node({
|
|
546
|
+
flow_id: "flow-abc-123",
|
|
547
|
+
node_id: "code-node-id",
|
|
548
|
+
data: {
|
|
549
|
+
label: "Process Data",
|
|
550
|
+
mode: "runOnce",
|
|
551
|
+
code: \`
|
|
552
|
+
// Get the HTTP response from upstream node
|
|
553
|
+
const apiData = $("http-request-node-id");
|
|
554
|
+
|
|
555
|
+
// Get the trigger input
|
|
556
|
+
const trigger = $("trigger-node-id");
|
|
557
|
+
|
|
558
|
+
// Process the data
|
|
559
|
+
const filtered = apiData.body.items.filter(item => item.active);
|
|
560
|
+
|
|
561
|
+
// MUST return an object
|
|
562
|
+
return {
|
|
563
|
+
items: filtered,
|
|
564
|
+
count: filtered.length,
|
|
565
|
+
requestedBy: trigger.body.userId
|
|
566
|
+
};
|
|
567
|
+
\`
|
|
568
|
+
}
|
|
569
|
+
})
|
|
570
|
+
\`\`\`
|
|
571
|
+
|
|
572
|
+
Downstream nodes access: \`{{code-node-id.items}}\`, \`{{code-node-id.count}}\`, \`{{code-node-id.requestedBy}}\`
|
|
573
|
+
|
|
574
|
+
### Example 5: Loop with array processing
|
|
575
|
+
|
|
576
|
+
\`\`\`
|
|
577
|
+
add_nodes({
|
|
578
|
+
flow_id: "flow-abc-123",
|
|
579
|
+
nodes: [
|
|
580
|
+
{
|
|
581
|
+
type: "loop",
|
|
582
|
+
temp_id: "my-loop",
|
|
583
|
+
data: {
|
|
584
|
+
label: "Process Each User",
|
|
585
|
+
arraySources: ["{{http-node-id.body.users}}"],
|
|
586
|
+
enableFailRoute: false
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
type: "httpRequest",
|
|
591
|
+
temp_id: "loop-api",
|
|
592
|
+
data: {
|
|
593
|
+
label: "Update User",
|
|
594
|
+
url: "https://api.example.com/users/{{my-loop.currentItem.id}}",
|
|
595
|
+
method: "PUT",
|
|
596
|
+
bodyType: "json",
|
|
597
|
+
body: "{\\"status\\": \\"processed\\"}"
|
|
598
|
+
}
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
type: "goal",
|
|
602
|
+
temp_id: "done-goal",
|
|
603
|
+
data: { label: "All Done", goalName: "Batch Complete" }
|
|
604
|
+
}
|
|
605
|
+
],
|
|
606
|
+
edges: [
|
|
607
|
+
{ source: "http-node-id", target: "my-loop" },
|
|
608
|
+
{ source: "my-loop", target: "loop-api", source_handle: "loop" },
|
|
609
|
+
{ source: "my-loop", target: "done-goal", source_handle: "done" }
|
|
610
|
+
]
|
|
611
|
+
})
|
|
612
|
+
\`\`\`
|
|
613
|
+
|
|
614
|
+
Note: Inside the loop body, access current item via \`{{loop-real-id.currentItem}}\` and \`{{loop-real-id.currentIndex}}\`.
|
|
615
|
+
|
|
616
|
+
### Example 6: Review node with context fields
|
|
617
|
+
|
|
618
|
+
\`\`\`
|
|
619
|
+
add_nodes({
|
|
620
|
+
flow_id: "flow-abc-123",
|
|
621
|
+
nodes: [{
|
|
622
|
+
type: "review",
|
|
623
|
+
temp_id: "my-review",
|
|
624
|
+
data: {
|
|
625
|
+
label: "Manager Approval",
|
|
626
|
+
title: "Expense Approval Required",
|
|
627
|
+
description: "Please review this expense report",
|
|
628
|
+
fields: [
|
|
629
|
+
{ id: "f1", label: "Employee", value: "{{trigger-id.body.employeeName}}" },
|
|
630
|
+
{ id: "f2", label: "Amount", value: "{{trigger-id.body.amount}}" },
|
|
631
|
+
{ id: "f3", label: "Category", value: "{{trigger-id.body.category}}" }
|
|
632
|
+
],
|
|
633
|
+
options: [
|
|
634
|
+
{ id: "option_0", label: "Approve", color: "green" },
|
|
635
|
+
{ id: "option_1", label: "Reject", color: "red" },
|
|
636
|
+
{ id: "option_2", label: "Request Info", color: "yellow" }
|
|
637
|
+
]
|
|
638
|
+
}
|
|
639
|
+
}],
|
|
640
|
+
edges: [
|
|
641
|
+
{ source: "previous-node-id", target: "my-review" }
|
|
642
|
+
]
|
|
643
|
+
})
|
|
644
|
+
|
|
645
|
+
// Connect each option to a different path:
|
|
646
|
+
connect_nodes({ flow_id: "...", source: "review-real-id", target: "approve-node", source_handle: "option_0" })
|
|
647
|
+
connect_nodes({ flow_id: "...", source: "review-real-id", target: "reject-node", source_handle: "option_1" })
|
|
648
|
+
connect_nodes({ flow_id: "...", source: "review-real-id", target: "info-node", source_handle: "option_2" })
|
|
649
|
+
\`\`\`
|
|
650
|
+
|
|
651
|
+
### Example 7: Variables — create, update, and reference
|
|
652
|
+
|
|
653
|
+
\`\`\`
|
|
654
|
+
// Create flow variables
|
|
655
|
+
set_variable({ flow_id: "...", name: "totalProcessed", type: "number", default_value: "0" })
|
|
656
|
+
set_variable({ flow_id: "...", name: "results", type: "string", default_value: "", is_list: true })
|
|
657
|
+
|
|
658
|
+
// Add a Variable node to update during flow
|
|
659
|
+
add_nodes({
|
|
660
|
+
flow_id: "...",
|
|
661
|
+
nodes: [{
|
|
662
|
+
type: "variable",
|
|
663
|
+
temp_id: "my-var",
|
|
664
|
+
data: {
|
|
665
|
+
label: "Increment Counter",
|
|
666
|
+
action: "update",
|
|
667
|
+
variableName: "totalProcessed",
|
|
668
|
+
operator: "add",
|
|
669
|
+
value: "1"
|
|
670
|
+
}
|
|
671
|
+
}]
|
|
672
|
+
})
|
|
673
|
+
|
|
674
|
+
// Reference variables in other nodes via {{Variables.totalProcessed}}
|
|
675
|
+
\`\`\`
|
|
676
|
+
|
|
677
|
+
### Example 8: update_flow — saving full flow state
|
|
678
|
+
|
|
679
|
+
\`\`\`
|
|
680
|
+
update_flow({
|
|
681
|
+
flow_id: "flow-abc-123",
|
|
682
|
+
name: "My Flow",
|
|
683
|
+
description: "Updated description",
|
|
684
|
+
nodes: [...], // Full nodes array from get_flow
|
|
685
|
+
edges: [...], // Full edges array from get_flow
|
|
686
|
+
end_conditions: {
|
|
687
|
+
goals: [{ id: "g1", label: "Converted", nodeId: "goal-node-id" }],
|
|
688
|
+
exits: [{ id: "e1", label: "Dropped Off", nodeId: "exit-node-id" }]
|
|
689
|
+
}
|
|
690
|
+
})
|
|
691
|
+
\`\`\`
|
|
692
|
+
|
|
693
|
+
---
|
|
694
|
+
|
|
695
|
+
## Building Flows Step-by-Step
|
|
696
|
+
|
|
697
|
+
1. \`create_flow(name, description, trigger_type)\` — creates flow with trigger node
|
|
698
|
+
2. \`get_flow(flow_id)\` — get trigger node ID
|
|
699
|
+
3. \`add_nodes(flow_id, nodes, edges)\` — add processing nodes with \`temp_id\` + edges
|
|
700
|
+
4. \`update_node(flow_id, node_id, data)\` — configure conditions, mappings, forms
|
|
701
|
+
5. \`set_variable(flow_id, name, type, defaultValue)\` — set up variables if needed
|
|
702
|
+
6. \`validate_flow(flow_id)\` — check for errors
|
|
703
|
+
7. \`publish_flow(flow_id)\` — publish
|
|
704
|
+
8. \`run_flow(flow_id, input_data)\` — test
|
|
705
|
+
|
|
706
|
+
---
|
|
707
|
+
|
|
708
|
+
## Key Rules
|
|
709
|
+
|
|
710
|
+
1. **Every flow needs exactly one trigger node** — auto-created by \`create_flow\`
|
|
711
|
+
2. **Use \`temp_id\` in \`add_nodes\`** to reference new nodes in edges before IDs are assigned
|
|
712
|
+
3. **Config fields use \`{{nodeId.field}}\`** — Code nodes use \`$("nodeId")\`
|
|
713
|
+
4. **Custom nodes use \`inputs.keyName\`** — NOT \`$("nodeId")\`
|
|
714
|
+
5. **Form submission data keyed by LABEL** — \`{{pageId.submissionData.Email}}\` not element UUID
|
|
715
|
+
6. **Branching nodes need \`source_handle\`** — if (true/false), switch (outputLabel/default), loop (loop/done/fail), review (option_N), page (right), splitTest (variant labels)
|
|
716
|
+
7. **Always \`validate_flow\` before \`publish_flow\`**
|
|
717
|
+
8. **Variables accessed as \`{{Variables.varName}}\`**
|
|
718
|
+
9. **Code must \`return { key: value }\`** — returned keys become node output fields
|
|
719
|
+
10. **Use \`get_node_type_info(type)\`** for detailed guides on any specific node type
|
|
720
|
+
`.trim();
|
|
721
|
+
//# sourceMappingURL=prompts.js.map
|