@elizaos/plugin-workflow 2.0.0-beta.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/README.md +71 -0
- package/auto-enable.ts +18 -0
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +2 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/workflow.d.ts +23 -0
- package/dist/actions/workflow.d.ts.map +1 -0
- package/dist/actions/workflow.js +425 -0
- package/dist/actions/workflow.js.map +1 -0
- package/dist/data/defaultNodes.json +9887 -0
- package/dist/data/schemaIndex.json +1 -0
- package/dist/data/triggerSchemaIndex.json +1 -0
- package/dist/db/index.d.ts +2 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +2 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/schema.d.ts +588 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +59 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +126 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/automations-builder.d.ts +21 -0
- package/dist/lib/automations-builder.d.ts.map +1 -0
- package/dist/lib/automations-builder.js +557 -0
- package/dist/lib/automations-builder.js.map +1 -0
- package/dist/lib/automations-types.d.ts +153 -0
- package/dist/lib/automations-types.d.ts.map +1 -0
- package/dist/lib/automations-types.js +191 -0
- package/dist/lib/automations-types.js.map +1 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +3 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/legacy-task-migration.d.ts +20 -0
- package/dist/lib/legacy-task-migration.d.ts.map +1 -0
- package/dist/lib/legacy-task-migration.js +110 -0
- package/dist/lib/legacy-task-migration.js.map +1 -0
- package/dist/lib/legacy-text-trigger-migration.d.ts +18 -0
- package/dist/lib/legacy-text-trigger-migration.d.ts.map +1 -0
- package/dist/lib/legacy-text-trigger-migration.js +131 -0
- package/dist/lib/legacy-text-trigger-migration.js.map +1 -0
- package/dist/lib/workflow-clarification.d.ts +113 -0
- package/dist/lib/workflow-clarification.d.ts.map +1 -0
- package/dist/lib/workflow-clarification.js +425 -0
- package/dist/lib/workflow-clarification.js.map +1 -0
- package/dist/plugin-routes.d.ts +9 -0
- package/dist/plugin-routes.d.ts.map +1 -0
- package/dist/plugin-routes.js +147 -0
- package/dist/plugin-routes.js.map +1 -0
- package/dist/providers/activeWorkflows.d.ts +11 -0
- package/dist/providers/activeWorkflows.d.ts.map +1 -0
- package/dist/providers/activeWorkflows.js +72 -0
- package/dist/providers/activeWorkflows.js.map +1 -0
- package/dist/providers/index.d.ts +4 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +4 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/pendingDraft.d.ts +9 -0
- package/dist/providers/pendingDraft.d.ts.map +1 -0
- package/dist/providers/pendingDraft.js +48 -0
- package/dist/providers/pendingDraft.js.map +1 -0
- package/dist/providers/workflowStatus.d.ts +3 -0
- package/dist/providers/workflowStatus.d.ts.map +1 -0
- package/dist/providers/workflowStatus.js +69 -0
- package/dist/providers/workflowStatus.js.map +1 -0
- package/dist/register-routes.d.ts +2 -0
- package/dist/register-routes.d.ts.map +1 -0
- package/dist/register-routes.js +6 -0
- package/dist/register-routes.js.map +1 -0
- package/dist/routes/_helpers.d.ts +11 -0
- package/dist/routes/_helpers.d.ts.map +1 -0
- package/dist/routes/_helpers.js +22 -0
- package/dist/routes/_helpers.js.map +1 -0
- package/dist/routes/automations.d.ts +19 -0
- package/dist/routes/automations.d.ts.map +1 -0
- package/dist/routes/automations.js +32 -0
- package/dist/routes/automations.js.map +1 -0
- package/dist/routes/embedded-webhooks.d.ts +3 -0
- package/dist/routes/embedded-webhooks.d.ts.map +1 -0
- package/dist/routes/embedded-webhooks.js +47 -0
- package/dist/routes/embedded-webhooks.js.map +1 -0
- package/dist/routes/executions.d.ts +3 -0
- package/dist/routes/executions.d.ts.map +1 -0
- package/dist/routes/executions.js +58 -0
- package/dist/routes/executions.js.map +1 -0
- package/dist/routes/index.d.ts +4 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/index.js +14 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/nodes.d.ts +3 -0
- package/dist/routes/nodes.d.ts.map +1 -0
- package/dist/routes/nodes.js +168 -0
- package/dist/routes/nodes.js.map +1 -0
- package/dist/routes/validation.d.ts +3 -0
- package/dist/routes/validation.d.ts.map +1 -0
- package/dist/routes/validation.js +41 -0
- package/dist/routes/validation.js.map +1 -0
- package/dist/routes/workflow-routes.d.ts +27 -0
- package/dist/routes/workflow-routes.d.ts.map +1 -0
- package/dist/routes/workflow-routes.js +326 -0
- package/dist/routes/workflow-routes.js.map +1 -0
- package/dist/routes/workflows.d.ts +3 -0
- package/dist/routes/workflows.d.ts.map +1 -0
- package/dist/routes/workflows.js +252 -0
- package/dist/routes/workflows.js.map +1 -0
- package/dist/schemas/draftIntent.d.ts +22 -0
- package/dist/schemas/draftIntent.d.ts.map +1 -0
- package/dist/schemas/draftIntent.js +22 -0
- package/dist/schemas/draftIntent.js.map +1 -0
- package/dist/schemas/feasibility.d.ts +13 -0
- package/dist/schemas/feasibility.d.ts.map +1 -0
- package/dist/schemas/feasibility.js +9 -0
- package/dist/schemas/feasibility.js.map +1 -0
- package/dist/schemas/index.d.ts +5 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +5 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/keywordExtraction.d.ts +14 -0
- package/dist/schemas/keywordExtraction.d.ts.map +1 -0
- package/dist/schemas/keywordExtraction.js +12 -0
- package/dist/schemas/keywordExtraction.js.map +1 -0
- package/dist/schemas/workflowMatching.d.ts +36 -0
- package/dist/schemas/workflowMatching.d.ts.map +1 -0
- package/dist/schemas/workflowMatching.js +30 -0
- package/dist/schemas/workflowMatching.js.map +1 -0
- package/dist/services/embedded-workflow-service.d.ts +106 -0
- package/dist/services/embedded-workflow-service.d.ts.map +1 -0
- package/dist/services/embedded-workflow-service.js +1900 -0
- package/dist/services/embedded-workflow-service.js.map +1 -0
- package/dist/services/index.d.ts +5 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +5 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/workflow-credential-store.d.ts +27 -0
- package/dist/services/workflow-credential-store.d.ts.map +1 -0
- package/dist/services/workflow-credential-store.js +92 -0
- package/dist/services/workflow-credential-store.js.map +1 -0
- package/dist/services/workflow-dispatch.d.ts +41 -0
- package/dist/services/workflow-dispatch.d.ts.map +1 -0
- package/dist/services/workflow-dispatch.js +86 -0
- package/dist/services/workflow-dispatch.js.map +1 -0
- package/dist/services/workflow-service.d.ts +63 -0
- package/dist/services/workflow-service.d.ts.map +1 -0
- package/dist/services/workflow-service.js +492 -0
- package/dist/services/workflow-service.js.map +1 -0
- package/dist/trigger-routes.d.ts +153 -0
- package/dist/trigger-routes.d.ts.map +1 -0
- package/dist/trigger-routes.js +424 -0
- package/dist/trigger-routes.js.map +1 -0
- package/dist/types/index.d.ts +457 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +59 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/catalog.d.ts +16 -0
- package/dist/utils/catalog.d.ts.map +1 -0
- package/dist/utils/catalog.js +211 -0
- package/dist/utils/catalog.js.map +1 -0
- package/dist/utils/clarification.d.ts +17 -0
- package/dist/utils/clarification.d.ts.map +1 -0
- package/dist/utils/clarification.js +46 -0
- package/dist/utils/clarification.js.map +1 -0
- package/dist/utils/context.d.ts +4 -0
- package/dist/utils/context.d.ts.map +1 -0
- package/dist/utils/context.js +18 -0
- package/dist/utils/context.js.map +1 -0
- package/dist/utils/credentialResolver.d.ts +22 -0
- package/dist/utils/credentialResolver.d.ts.map +1 -0
- package/dist/utils/credentialResolver.js +146 -0
- package/dist/utils/credentialResolver.js.map +1 -0
- package/dist/utils/generation.d.ts +36 -0
- package/dist/utils/generation.d.ts.map +1 -0
- package/dist/utils/generation.js +701 -0
- package/dist/utils/generation.js.map +1 -0
- package/dist/utils/host-capabilities.d.ts +27 -0
- package/dist/utils/host-capabilities.d.ts.map +1 -0
- package/dist/utils/host-capabilities.js +59 -0
- package/dist/utils/host-capabilities.js.map +1 -0
- package/dist/utils/inferSyntheticOutputSchema.d.ts +20 -0
- package/dist/utils/inferSyntheticOutputSchema.d.ts.map +1 -0
- package/dist/utils/inferSyntheticOutputSchema.js +151 -0
- package/dist/utils/inferSyntheticOutputSchema.js.map +1 -0
- package/dist/utils/outputSchema.d.ts +26 -0
- package/dist/utils/outputSchema.d.ts.map +1 -0
- package/dist/utils/outputSchema.js +297 -0
- package/dist/utils/outputSchema.js.map +1 -0
- package/dist/utils/validateAndRepair.d.ts +41 -0
- package/dist/utils/validateAndRepair.d.ts.map +1 -0
- package/dist/utils/validateAndRepair.js +483 -0
- package/dist/utils/validateAndRepair.js.map +1 -0
- package/dist/utils/workflow-prompts/actionResponse.d.ts +2 -0
- package/dist/utils/workflow-prompts/actionResponse.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/actionResponse.js +17 -0
- package/dist/utils/workflow-prompts/actionResponse.js.map +1 -0
- package/dist/utils/workflow-prompts/draftIntent.d.ts +2 -0
- package/dist/utils/workflow-prompts/draftIntent.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/draftIntent.js +23 -0
- package/dist/utils/workflow-prompts/draftIntent.js.map +1 -0
- package/dist/utils/workflow-prompts/feasibilityCheck.d.ts +2 -0
- package/dist/utils/workflow-prompts/feasibilityCheck.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/feasibilityCheck.js +21 -0
- package/dist/utils/workflow-prompts/feasibilityCheck.js.map +1 -0
- package/dist/utils/workflow-prompts/fieldCorrection.d.ts +3 -0
- package/dist/utils/workflow-prompts/fieldCorrection.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/fieldCorrection.js +20 -0
- package/dist/utils/workflow-prompts/fieldCorrection.js.map +1 -0
- package/dist/utils/workflow-prompts/index.d.ts +8 -0
- package/dist/utils/workflow-prompts/index.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/index.js +8 -0
- package/dist/utils/workflow-prompts/index.js.map +1 -0
- package/dist/utils/workflow-prompts/keywordExtraction.d.ts +2 -0
- package/dist/utils/workflow-prompts/keywordExtraction.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/keywordExtraction.js +21 -0
- package/dist/utils/workflow-prompts/keywordExtraction.js.map +1 -0
- package/dist/utils/workflow-prompts/parameterCorrection.d.ts +3 -0
- package/dist/utils/workflow-prompts/parameterCorrection.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/parameterCorrection.js +29 -0
- package/dist/utils/workflow-prompts/parameterCorrection.js.map +1 -0
- package/dist/utils/workflow-prompts/workflowGeneration.d.ts +2 -0
- package/dist/utils/workflow-prompts/workflowGeneration.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/workflowGeneration.js +529 -0
- package/dist/utils/workflow-prompts/workflowGeneration.js.map +1 -0
- package/dist/utils/workflow-prompts/workflowMatching.d.ts +2 -0
- package/dist/utils/workflow-prompts/workflowMatching.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/workflowMatching.js +23 -0
- package/dist/utils/workflow-prompts/workflowMatching.js.map +1 -0
- package/dist/utils/workflow.d.ts +62 -0
- package/dist/utils/workflow.d.ts.map +1 -0
- package/dist/utils/workflow.js +712 -0
- package/dist/utils/workflow.js.map +1 -0
- package/package.json +87 -0
- package/src/actions/index.ts +1 -0
- package/src/actions/workflow.ts +494 -0
- package/src/data/defaultNodes.json +9887 -0
- package/src/data/schemaIndex.json +1 -0
- package/src/data/triggerSchemaIndex.json +1 -0
- package/src/db/index.ts +8 -0
- package/src/db/schema.ts +94 -0
- package/src/index.ts +179 -0
- package/src/lib/automations-builder.ts +679 -0
- package/src/lib/automations-types.ts +391 -0
- package/src/lib/index.ts +8 -0
- package/src/lib/legacy-task-migration.ts +143 -0
- package/src/lib/legacy-text-trigger-migration.ts +178 -0
- package/src/lib/workflow-clarification.ts +497 -0
- package/src/plugin-routes.ts +164 -0
- package/src/providers/activeWorkflows.ts +81 -0
- package/src/providers/index.ts +3 -0
- package/src/providers/pendingDraft.ts +55 -0
- package/src/providers/workflowStatus.ts +88 -0
- package/src/register-routes.ts +6 -0
- package/src/routes/_helpers.ts +27 -0
- package/src/routes/automations.ts +46 -0
- package/src/routes/embedded-webhooks.ts +64 -0
- package/src/routes/executions.ts +75 -0
- package/src/routes/index.ts +16 -0
- package/src/routes/nodes.ts +211 -0
- package/src/routes/validation.ts +51 -0
- package/src/routes/workflow-routes.ts +469 -0
- package/src/routes/workflows.ts +310 -0
- package/src/schemas/draftIntent.ts +21 -0
- package/src/schemas/feasibility.ts +8 -0
- package/src/schemas/index.ts +4 -0
- package/src/schemas/keywordExtraction.ts +11 -0
- package/src/schemas/workflowMatching.ts +29 -0
- package/src/services/embedded-workflow-service.ts +2224 -0
- package/src/services/index.ts +17 -0
- package/src/services/workflow-credential-store.ts +132 -0
- package/src/services/workflow-dispatch.ts +121 -0
- package/src/services/workflow-service.ts +839 -0
- package/src/trigger-routes.ts +714 -0
- package/src/types/index.ts +562 -0
- package/src/utils/catalog.ts +260 -0
- package/src/utils/clarification.ts +52 -0
- package/src/utils/context.ts +22 -0
- package/src/utils/credentialResolver.ts +234 -0
- package/src/utils/generation.ts +987 -0
- package/src/utils/host-capabilities.ts +81 -0
- package/src/utils/inferSyntheticOutputSchema.ts +163 -0
- package/src/utils/outputSchema.ts +372 -0
- package/src/utils/validateAndRepair.ts +610 -0
- package/src/utils/workflow-prompts/actionResponse.ts +16 -0
- package/src/utils/workflow-prompts/draftIntent.ts +22 -0
- package/src/utils/workflow-prompts/feasibilityCheck.ts +20 -0
- package/src/utils/workflow-prompts/fieldCorrection.ts +20 -0
- package/src/utils/workflow-prompts/index.ts +10 -0
- package/src/utils/workflow-prompts/keywordExtraction.ts +20 -0
- package/src/utils/workflow-prompts/parameterCorrection.ts +29 -0
- package/src/utils/workflow-prompts/workflowGeneration.ts +528 -0
- package/src/utils/workflow-prompts/workflowMatching.ts +22 -0
- package/src/utils/workflow.ts +895 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { ACTION_RESPONSE_SYSTEM_PROMPT } from './actionResponse';
|
|
2
|
+
export { DRAFT_INTENT_SYSTEM_PROMPT } from './draftIntent';
|
|
3
|
+
export { FEASIBILITY_CHECK_PROMPT } from './feasibilityCheck';
|
|
4
|
+
export { FIELD_CORRECTION_SYSTEM_PROMPT, FIELD_CORRECTION_USER_PROMPT } from './fieldCorrection';
|
|
5
|
+
export { KEYWORD_EXTRACTION_SYSTEM_PROMPT } from './keywordExtraction';
|
|
6
|
+
export {
|
|
7
|
+
PARAM_CORRECTION_SYSTEM_PROMPT,
|
|
8
|
+
PARAM_CORRECTION_USER_PROMPT,
|
|
9
|
+
} from './parameterCorrection';
|
|
10
|
+
export { WORKFLOW_GENERATION_SYSTEM_PROMPT } from './workflowGeneration';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const KEYWORD_EXTRACTION_SYSTEM_PROMPT = `You are an expert at extracting relevant search terms for finding workflows nodes.
|
|
2
|
+
|
|
3
|
+
Given a user prompt describing an workflow, extract up to 5 concise keywords or phrases that best represent the core actions, services, or data transformations involved.
|
|
4
|
+
|
|
5
|
+
Focus on terms likely to match workflows node names or functionalities. Avoid generic words.
|
|
6
|
+
|
|
7
|
+
Examples:
|
|
8
|
+
- request: Send me Stripe payment summaries via Gmail every Monday
|
|
9
|
+
keywords: stripe, gmail, send, email, schedule
|
|
10
|
+
- request: Post RSS feed updates to Slack channel
|
|
11
|
+
keywords: rss, slack, post, feed, webhook
|
|
12
|
+
- request: Summarize weekly GitHub issues and send to Notion
|
|
13
|
+
keywords: github, issues, notion, summarize
|
|
14
|
+
- request: Fetch weather data hourly and store in Google Sheets
|
|
15
|
+
keywords: weather, http, schedule, google sheets, store
|
|
16
|
+
- request: When new Stripe payment, create invoice in QuickBooks
|
|
17
|
+
keywords: stripe, webhook, quickbooks, invoice, payment
|
|
18
|
+
|
|
19
|
+
Respond with structured JSON-style fields:
|
|
20
|
+
keywords: 1-5 relevant search terms`;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const PARAM_CORRECTION_SYSTEM_PROMPT = `Fix workflows node parameters to match the node's property definition.
|
|
2
|
+
|
|
3
|
+
You receive:
|
|
4
|
+
1. The node type and its current parameters (generated by another LLM — may use wrong names or structure)
|
|
5
|
+
2. The node's valid property definitions from the catalog
|
|
6
|
+
|
|
7
|
+
Your job: map the current parameter VALUES to the correct parameter NAMES and STRUCTURE from the definition.
|
|
8
|
+
|
|
9
|
+
Rules:
|
|
10
|
+
- Use ONLY parameter names that exist in the property definitions
|
|
11
|
+
- Preserve the user's intent and values
|
|
12
|
+
- For "fixedCollection" type properties, values MUST be nested inside a "values" array of objects (see example below)
|
|
13
|
+
- Keep "resource" and "operation" values unchanged (already validated)
|
|
14
|
+
- If a parameter has no plausible match in the definitions, drop it
|
|
15
|
+
- Return ONLY a valid JSON object — no explanation, no markdown fences
|
|
16
|
+
|
|
17
|
+
Example — fixedCollection correction:
|
|
18
|
+
WRONG: { "prompt": "Say hello" }
|
|
19
|
+
If the definition has a fixedCollection property "responses" with sub-property "content":
|
|
20
|
+
RIGHT: { "responses": { "values": [{ "content": "Say hello" }] } }`;
|
|
21
|
+
|
|
22
|
+
export const PARAM_CORRECTION_USER_PROMPT = `Node: {nodeType}
|
|
23
|
+
Current parameters:
|
|
24
|
+
{currentParams}
|
|
25
|
+
|
|
26
|
+
Property definitions:
|
|
27
|
+
{propertyDefs}
|
|
28
|
+
|
|
29
|
+
Return corrected parameters JSON:`;
|
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
export const WORKFLOW_GENERATION_SYSTEM_PROMPT = `## Workflow AI Definition: Core Concepts
|
|
2
|
+
|
|
3
|
+
### 1. **Workflow**
|
|
4
|
+
|
|
5
|
+
A workflow is a collection of nodes and the connections between them.
|
|
6
|
+
|
|
7
|
+
\`\`\`json
|
|
8
|
+
{
|
|
9
|
+
"id": "uuid",
|
|
10
|
+
"name": "string",
|
|
11
|
+
"active": true,
|
|
12
|
+
"nodes": [/* array of Node objects */],
|
|
13
|
+
"connections": {/* see below */},
|
|
14
|
+
"settings": {/* workflow-specific settings, optional */},
|
|
15
|
+
"staticData": {/* optional */},
|
|
16
|
+
"pinData": {/* optional */}
|
|
17
|
+
}
|
|
18
|
+
\`\`\`
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
### 2. **Node**
|
|
23
|
+
|
|
24
|
+
A node is a single step in a workflow. Each node has:
|
|
25
|
+
|
|
26
|
+
| Field | Type | Description |
|
|
27
|
+
|:--------------|:----------|:----------------------------------|
|
|
28
|
+
| id | string | Unique node identifier |
|
|
29
|
+
| name | string | Node name (unique in workflow) |
|
|
30
|
+
| type | string | Node type (e.g. \`httpRequest\`) |
|
|
31
|
+
| typeVersion | number | Node type version |
|
|
32
|
+
| position | [number, number] | Canvas position |
|
|
33
|
+
| parameters | object | Node parameters (see below) |
|
|
34
|
+
| credentials | object | Credential references (optional) |
|
|
35
|
+
| disabled | boolean | If node is disabled (optional) |
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
### 3. **Connections**
|
|
40
|
+
|
|
41
|
+
Connections define how nodes are linked.
|
|
42
|
+
|
|
43
|
+
\`\`\`json
|
|
44
|
+
{
|
|
45
|
+
"NodeA": {
|
|
46
|
+
"main": [
|
|
47
|
+
[ { "node": "NodeB", "type": "main", "index": 0 } ]
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
\`\`\`
|
|
52
|
+
- Key: source node name
|
|
53
|
+
- Each connection has a \`type\` (commonly \`"main"\`)
|
|
54
|
+
- Each connection points to a destination node, with an index
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
### 4. **Node Parameters**
|
|
59
|
+
|
|
60
|
+
Each node has parameters, which are defined in its node type description. Parameters can be:
|
|
61
|
+
|
|
62
|
+
- Simple values (string, number, boolean)
|
|
63
|
+
- Complex objects (collections, fixedCollections, etc.)
|
|
64
|
+
- Resource locators (for referencing external resources)
|
|
65
|
+
- Options (select from a list)
|
|
66
|
+
|
|
67
|
+
**Parameter properties:**
|
|
68
|
+
| Field | Type | Description |
|
|
69
|
+
|:--------------|:----------|:----------------------------------|
|
|
70
|
+
| displayName | string | Label shown in UI |
|
|
71
|
+
| name | string | Internal parameter name |
|
|
72
|
+
| type | string | Parameter type (\`string\`, \`number\`, \`options\`, etc.) |
|
|
73
|
+
| default | any | Default value |
|
|
74
|
+
| description | string | Help text (optional) |
|
|
75
|
+
| required | boolean | Is required? (optional) |
|
|
76
|
+
| options | array | For \`options\` type: choices |
|
|
77
|
+
| displayOptions| object | Show/hide logic (optional) |
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
### 5. **Node Type Description**
|
|
82
|
+
|
|
83
|
+
Each node type (e.g. HTTP Request, Slack, Google Sheets) defines:
|
|
84
|
+
|
|
85
|
+
| Field | Type | Description |
|
|
86
|
+
|:--------------|:----------|:----------------------------------|
|
|
87
|
+
| name | string | Node type name |
|
|
88
|
+
| displayName | string | Human-readable name |
|
|
89
|
+
| group | array | Node group(s): e.g. input, output, trigger |
|
|
90
|
+
| description | string | Node description |
|
|
91
|
+
| version | number | Node version |
|
|
92
|
+
| inputs | array | Allowed input connection types |
|
|
93
|
+
| outputs | array | Allowed output connection types |
|
|
94
|
+
| properties | array | Parameter definitions |
|
|
95
|
+
| credentials | array | Credential requirements |
|
|
96
|
+
| documentationUrl | string | Docs link (optional) |
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
### 6. **Credentials — MANDATORY INVARIANT**
|
|
101
|
+
|
|
102
|
+
EVERY node whose definition has a non-empty \`credentials\` array MUST include a matching \`credentials\` block in the emitted node JSON. **This is a hard rule.** A workflow that omits the credentials block for a credentialed node is an invalid output.
|
|
103
|
+
|
|
104
|
+
**IMPORTANT:** Always use native workflows nodes (e.g. \`workflows-nodes-base.gmail\`, \`workflows-nodes-base.slack\`) rather than generic HTTP Request nodes.
|
|
105
|
+
|
|
106
|
+
**Exact shape — copy verbatim, do not omit, do not improvise:**
|
|
107
|
+
|
|
108
|
+
\`\`\`json
|
|
109
|
+
{
|
|
110
|
+
"name": "Send Gmail",
|
|
111
|
+
"type": "workflows-nodes-base.gmail",
|
|
112
|
+
"credentials": {
|
|
113
|
+
"<credentialTypeName>": {
|
|
114
|
+
"id": "{{CREDENTIAL_ID}}",
|
|
115
|
+
"name": "<Friendly Name>"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
\`\`\`
|
|
120
|
+
|
|
121
|
+
The host injects the real \`id\` after generation; you write the literal string \`"{{CREDENTIAL_ID}}"\`.
|
|
122
|
+
|
|
123
|
+
Pick \`<credentialTypeName>\` from the node definition's \`credentials[].name\` field. Common names: \`gmailOAuth2\`, \`slackOAuth2Api\`, \`discordApi\`, \`discordBotApi\`, \`telegramApi\`, \`googleSheetsOAuth2Api\`, \`googleCalendarOAuth2Api\`. **Never invent type names** — always use the value from the node definition. When the host publishes a \`## Available Credentials\` section below, prefer those names.
|
|
124
|
+
|
|
125
|
+
Pick \`<Friendly Name>\` to match what the user would see in workflows's UI: "Gmail Account", "Slack Workspace", "Discord Bot", "Telegram Bot", etc.
|
|
126
|
+
|
|
127
|
+
**Self-check before emitting:** for every node whose \`credentials\` array is non-empty in its definition, verify the emitted node has the \`credentials\` block. Missing this on a Gmail / Slack / Discord / Telegram node makes the workflow non-runnable.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### 6a. **\`typeVersion\` selection — MANDATORY INVARIANT**
|
|
132
|
+
|
|
133
|
+
Each node definition includes \`version: number[]\` listing the EXACT versions workflows knows about (e.g. \`[1, 2, 2.1]\` for Gmail). You MUST pick \`typeVersion\` from this array — pick the highest available value.
|
|
134
|
+
|
|
135
|
+
**Hard rule:** never invent versions not in the array. If the array is \`[1, 2, 2.1]\`, do NOT emit \`2.2\`, \`2.3\`, or \`3\`. workflows's runtime cannot find a node implementation for a version you invent and the workflow crashes at activation with \`Cannot read properties of undefined (reading 'execute')\`.
|
|
136
|
+
|
|
137
|
+
If a node definition lists \`version: [2]\` only, emit \`typeVersion: 2\`. If it lists \`version: [1, 2, 2.1]\`, emit \`typeVersion: 2.1\` (the highest).
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
### 6b. **\`parameters.authentication\` ↔ credentials coupling — MANDATORY INVARIANT**
|
|
142
|
+
|
|
143
|
+
Some nodes (Gmail, Discord, etc.) gate which credential type applies based on \`parameters.authentication\`. Each such node's definition includes a \`credentialAuthMatrix\` mapping credType to the required authentication value, e.g.:
|
|
144
|
+
|
|
145
|
+
\`\`\`json
|
|
146
|
+
"credentialAuthMatrix": {
|
|
147
|
+
"gmailOAuth2": "oAuth2",
|
|
148
|
+
"googleApi": "serviceAccount"
|
|
149
|
+
}
|
|
150
|
+
\`\`\`
|
|
151
|
+
|
|
152
|
+
**Hard rule:** when you attach a \`credentials\` block of type X, set \`parameters.authentication\` to the matching value from \`credentialAuthMatrix\`. Mismatched (or missing) \`authentication\` values mean workflows cannot bind the credential at activation time and the workflow crashes the same way as a missing typeVersion.
|
|
153
|
+
|
|
154
|
+
Example — attaching \`gmailOAuth2\` credentials to a Gmail node:
|
|
155
|
+
|
|
156
|
+
\`\`\`json
|
|
157
|
+
{
|
|
158
|
+
"name": "Get Gmail Messages",
|
|
159
|
+
"type": "workflows-nodes-base.gmail",
|
|
160
|
+
"typeVersion": 2.1,
|
|
161
|
+
"parameters": {
|
|
162
|
+
"authentication": "oAuth2",
|
|
163
|
+
"resource": "message",
|
|
164
|
+
"operation": "getAll"
|
|
165
|
+
},
|
|
166
|
+
"credentials": {
|
|
167
|
+
"gmailOAuth2": { "id": "{{CREDENTIAL_ID}}", "name": "Gmail Account" }
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
\`\`\`
|
|
171
|
+
|
|
172
|
+
If a node has no \`credentialAuthMatrix\` field, no \`authentication\` parameter is required.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
### 6c. **Resource and operation selection — match the user's verb to the operation, not just the node**
|
|
177
|
+
|
|
178
|
+
Each service node groups its capabilities under \`(resource, operation)\` pairs. The user's verb is the strongest signal for the operation:
|
|
179
|
+
|
|
180
|
+
| Verb in the user's prompt | Operation |
|
|
181
|
+
|:--|:--|
|
|
182
|
+
| "send", "post", "deliver" | \`send\` or \`post\` (NOT \`create\`) |
|
|
183
|
+
| "create", "make", "set up", "add" (when the object is a *container* like a channel, server, list) | \`create\` |
|
|
184
|
+
| "list", "get all", "fetch all" | \`getAll\` |
|
|
185
|
+
| "get", "fetch" (singular), "look up" | \`get\` |
|
|
186
|
+
| "delete", "remove" | \`delete\` |
|
|
187
|
+
| "update", "edit", "change" | \`update\` |
|
|
188
|
+
|
|
189
|
+
The **resource** is the *object* of the verb. "Send a meow message" → \`resource: "message"\`, \`operation: "send"\`. NOT \`resource: "channel"\`. Picking the wrong resource means picking from a wrong operation set entirely; verify resource first, then operation.
|
|
190
|
+
|
|
191
|
+
When the node definition lists multiple resources, pick the one whose name is the noun the user mentioned. Use \`channel\` only when the user wants to create / edit / delete the channel itself, not when they want to send a message *to* a channel. Use \`server\` / \`guild\` only when the user is acting on the workspace itself.
|
|
192
|
+
|
|
193
|
+
**Self-check before emitting:** read your chosen \`(resource, operation)\` pair back as English: does it describe what the user asked for? "Discord channel:create" reads as *"create a Discord channel"* — only correct if the user actually wants a new channel. For *"send a message to Discord"*, the correct read-back is "Discord message:send".
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
### 6d. **Self-monitoring workflows is a Schedule + execution-history loop, NEVER errorTrigger**
|
|
198
|
+
|
|
199
|
+
When the user wants to monitor their own workflows, accounts, or activity — phrasings like *"review my activity"*, *"check stuck or errored"*, *"ping me when X is broken"*, *"alert me if my workflows fail"*, *"audit recent executions"* — the canonical primitive is:
|
|
200
|
+
|
|
201
|
+
\`\`\`
|
|
202
|
+
Schedule Trigger (every N minutes)
|
|
203
|
+
↓
|
|
204
|
+
Execution-history node (Execution: getAll, filters: status=error)
|
|
205
|
+
↓
|
|
206
|
+
IF / Filter (e.g. only those with no output, or running > 30 min)
|
|
207
|
+
↓
|
|
208
|
+
Notification node (Discord / Slack / Gmail / Telegram)
|
|
209
|
+
\`\`\`
|
|
210
|
+
|
|
211
|
+
**Hard rules — \`errorTrigger\` is never the right answer for self-monitoring:**
|
|
212
|
+
|
|
213
|
+
- \`workflows-nodes-base.errorTrigger\` is a *callback*, not a *poller*. It only fires when another workflow that has registered THIS workflow as its error workflow throws. It cannot inspect its own workflow's history, cannot detect *stuck* runs (those produce no error event), and produces a dead workflow if no other workflow is wired to call it. Even the phrase *"monitor errors"* maps to **Schedule + execution-history**, not errorTrigger.
|
|
214
|
+
- A workflow whose only trigger is \`errorTrigger\` and whose intent is "review my activity / check for errors" is a **certain-broken output**. Refuse to emit it. Use \`scheduleTrigger\` as the trigger instead.
|
|
215
|
+
|
|
216
|
+
**Hard rules — generic external scanners are also wrong:**
|
|
217
|
+
|
|
218
|
+
- \`workflows-nodes-base.urlScanIoApi\` is a *URL-safety service*. It has nothing to do with workflow execution history. Never include it in a self-monitoring workflow.
|
|
219
|
+
- Any node whose displayName / description hits "scan" / "check" / "monitor" but whose category is *not* in {\`trigger\`, \`transform\`} or whose target service is not the workflow runtime itself — skip it.
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
### 7. **Workflow Settings (optional)**
|
|
224
|
+
|
|
225
|
+
Workflow-level settings, e.g. timezone, error workflow, execution options.
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## **Prompt Example for AI**
|
|
230
|
+
|
|
231
|
+
> You are an workflow generator. Given a user's intent, generate a workflow as a JSON object.
|
|
232
|
+
> Use the following structure:
|
|
233
|
+
> - \`nodes\`: List of nodes, each with \`id\`, \`name\`, \`type\`, \`typeVersion\`, \`position\`, \`parameters\`, and optional \`credentials\`.
|
|
234
|
+
> - \`connections\`: Object mapping node names to their output connections.
|
|
235
|
+
> - \`settings\`: Optional workflow settings.
|
|
236
|
+
|
|
237
|
+
> Reference [workflows node type documentation](https://docs.workflows.io/integrations/builtin/app-nodes/) for available node types and their parameters.
|
|
238
|
+
|
|
239
|
+
**CRITICAL: You MUST only use node types from the "Relevant Nodes Available" list provided below.**
|
|
240
|
+
Do not invent, guess, or use node types that are not in the provided list.
|
|
241
|
+
If a service the user mentioned is not in the available nodes, do NOT include it.
|
|
242
|
+
Use \`_meta.assumptions\` to document when you used an alternative integration.
|
|
243
|
+
|
|
244
|
+
**When creating nodes:**
|
|
245
|
+
- **CRITICAL: Use EXACTLY the parameter names from each node's "properties" definitions.** Do NOT guess or use names from your training data. If the definition says \`modelId\`, use \`modelId\` — not \`model\`. If it says \`responses\`, use \`responses\` — not \`prompt\`. The exact \`name\` field in each property definition is what goes into \`parameters\`.
|
|
246
|
+
- For \`fixedCollection\` type properties, values MUST be nested inside a \`"values"\` array of objects. Example: \`"responses": { "values": [{ "content": "..." }] }\`
|
|
247
|
+
- For \`options\` type parameters, pick the most common or user-specified value from the property's \`options\` array.
|
|
248
|
+
- Use unique names for each node.
|
|
249
|
+
- Connect nodes using the \`connections\` object, with \`"main"\` as the default connection type.
|
|
250
|
+
- For nodes requiring authentication, include the \`credentials\` field with the appropriate credential type.
|
|
251
|
+
- Use native workflows nodes (workflows-nodes-base.*) instead of generic HTTP Request nodes.
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## **Minimal Example Workflow**
|
|
256
|
+
|
|
257
|
+
\`\`\`json
|
|
258
|
+
{
|
|
259
|
+
"nodes": [
|
|
260
|
+
{
|
|
261
|
+
"id": "uuid-1",
|
|
262
|
+
"name": "Start",
|
|
263
|
+
"type": "workflows-nodes-base.start",
|
|
264
|
+
"typeVersion": 1,
|
|
265
|
+
"position": [0,0],
|
|
266
|
+
"parameters": {}
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
"id": "uuid-2",
|
|
270
|
+
"name": "Send Email",
|
|
271
|
+
"type": "workflows-nodes-base.emailSend",
|
|
272
|
+
"typeVersion": 1,
|
|
273
|
+
"position": [200,0],
|
|
274
|
+
"parameters": {
|
|
275
|
+
"to": "user@example.com",
|
|
276
|
+
"subject": "Hello",
|
|
277
|
+
"text": "This is a test"
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
],
|
|
281
|
+
"connections": {
|
|
282
|
+
"Start": { "main": [ [ { "node": "Send Email", "type": "main", "index": 0 } ] ] }
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
\`\`\`
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## **Example with Credentials**
|
|
290
|
+
|
|
291
|
+
\`\`\`json
|
|
292
|
+
{
|
|
293
|
+
"nodes": [
|
|
294
|
+
{
|
|
295
|
+
"id": "uuid-1",
|
|
296
|
+
"name": "Schedule Trigger",
|
|
297
|
+
"type": "workflows-nodes-base.scheduleTrigger",
|
|
298
|
+
"typeVersion": 1,
|
|
299
|
+
"position": [0,0],
|
|
300
|
+
"parameters": {
|
|
301
|
+
"rule": {
|
|
302
|
+
"interval": [
|
|
303
|
+
{
|
|
304
|
+
"field": "hours",
|
|
305
|
+
"hoursInterval": 24
|
|
306
|
+
}
|
|
307
|
+
]
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
"id": "uuid-2",
|
|
313
|
+
"name": "Get Gmail Messages",
|
|
314
|
+
"type": "workflows-nodes-base.gmail",
|
|
315
|
+
"typeVersion": 2,
|
|
316
|
+
"position": [200,0],
|
|
317
|
+
"parameters": {
|
|
318
|
+
"operation": "getAll",
|
|
319
|
+
"returnAll": false,
|
|
320
|
+
"limit": 10
|
|
321
|
+
},
|
|
322
|
+
"credentials": {
|
|
323
|
+
"gmailOAuth2": {
|
|
324
|
+
"id": "{{CREDENTIAL_ID}}",
|
|
325
|
+
"name": "Gmail Account"
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
"id": "uuid-3",
|
|
331
|
+
"name": "Post to Slack",
|
|
332
|
+
"type": "workflows-nodes-base.slack",
|
|
333
|
+
"typeVersion": 2,
|
|
334
|
+
"position": [400,0],
|
|
335
|
+
"parameters": {
|
|
336
|
+
"channel": "#notifications",
|
|
337
|
+
"text": "Daily email summary: {{ $json.subject }}"
|
|
338
|
+
},
|
|
339
|
+
"credentials": {
|
|
340
|
+
"slackOAuth2Api": {
|
|
341
|
+
"id": "{{CREDENTIAL_ID}}",
|
|
342
|
+
"name": "Slack Account"
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
],
|
|
347
|
+
"connections": {
|
|
348
|
+
"Schedule Trigger": { "main": [ [ { "node": "Get Gmail Messages", "type": "main", "index": 0 } ] ] },
|
|
349
|
+
"Get Gmail Messages": { "main": [ [ { "node": "Post to Slack", "type": "main", "index": 0 } ] ] }
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
\`\`\`
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## **Summary Table: Key Workflow Concepts**
|
|
357
|
+
|
|
358
|
+
| Concept | Description/Key Fields |
|
|
359
|
+
|:----------------|:----------------------------------------------------------|
|
|
360
|
+
| Workflow | id, name, active, nodes, connections, settings |
|
|
361
|
+
| Node | id, name, type, typeVersion, position, parameters, credentials, disabled |
|
|
362
|
+
| Connections | Map of node names to output connection arrays |
|
|
363
|
+
| Node Parameters | name, displayName, type, default, options, required, description |
|
|
364
|
+
| Node Type | name, displayName, group, description, version, inputs, outputs, properties, credentials |
|
|
365
|
+
| Credentials | Referenced in node, injected automatically by ID |
|
|
366
|
+
| Settings | Workflow-level options |
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
**Use only these fields and structures for AI workflow generation.**
|
|
371
|
+
For parameter validation and types, rely on the node's type definition and basic TypeScript types.
|
|
372
|
+
|
|
373
|
+
## **Workflow Naming**
|
|
374
|
+
|
|
375
|
+
The \`name\` field must be a short, descriptive label (3-6 words max) that summarizes what the workflow does.
|
|
376
|
+
|
|
377
|
+
**Good names:**
|
|
378
|
+
- "Gmail Résumé vers Proton"
|
|
379
|
+
- "Daily Stripe Summary via Gmail"
|
|
380
|
+
- "New GitHub Issue → Slack Alert"
|
|
381
|
+
- "Weekly Sales Report"
|
|
382
|
+
|
|
383
|
+
**Bad names (never do this):**
|
|
384
|
+
- "Workflow - Tu peux creer un workflow qui trigger a chaque fois que je recois un mail" (user prompt as name)
|
|
385
|
+
- "My Workflow" (too vague)
|
|
386
|
+
- "Automation" (meaningless)
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## **Runtime Facts — substitute, do not placeholder**
|
|
391
|
+
|
|
392
|
+
The host provides real values for the user's connectors in the optional \`## Runtime Facts\` block below. Use those values verbatim. NEVER emit a placeholder for a value the runtime has provided. Specifically, you must NOT emit:
|
|
393
|
+
|
|
394
|
+
- \`"={{YOUR_SERVER_ID}}"\`, \`"={{YOUR_GUILD_ID}}"\`, \`"={{YOUR_CHANNEL_ID}}"\`, or any \`"={{YOUR_…}}"\` template for an ID
|
|
395
|
+
- \`"<your-email-here>"\`, \`"<channel-name>"\`, or any \`<…>\`-bracketed pseudo-value for a fact the runtime has provided
|
|
396
|
+
- \`"PLACEHOLDER"\`, \`"REPLACE_ME"\`, \`"FILL_ME_IN"\`, or similar literal placeholder strings
|
|
397
|
+
|
|
398
|
+
When the runtime gives you a Discord guild id or channel id, write it verbatim as a JSON string of digits — e.g. \`"123456789012345678"\` — NOT as an unquoted number. Discord snowflake ids exceed JavaScript's safe-integer range (~17–20 digits), and workflows's Discord node expects them as JSON strings. \`"#general"\` is NOT a valid \`channelId\`. When the runtime gives you the user's Gmail email, write the email.
|
|
399
|
+
|
|
400
|
+
**Display-name → id resolution is mandatory when a fact line covers it.** When the user names a server, channel, chat, or contact by display name (e.g. *Cozy Devs*, *#general*, *#alerts*), search the \`## Runtime Facts\` block for a matching entry and use the id from that fact line verbatim. Compare names case-insensitively and ignore a leading \`#\` on channel names. Never emit a placeholder, a guessed id, or the display name itself as the parameter value when a fact line resolves it. If the user said *"Cozy Devs"* and a fact reads \`Discord guild "Cozy Devs" (id 1234567890) channels: #general (id 9876543210), …\`, then \`guildId\` is \`"1234567890"\` and \`channelId\` for *#general* is \`"9876543210"\` — no exceptions.
|
|
401
|
+
|
|
402
|
+
If a fact is genuinely missing AND the runtime did not provide it, do NOT guess. Emit a structured \`ClarificationRequest\` in \`_meta.requiresClarification\` (see "Handling Incomplete or Ambiguous Prompts" below) and stop populating the dependent node parameter rather than emitting a placeholder.
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## **Node Output Field Names — exact match only**
|
|
407
|
+
|
|
408
|
+
When you write \`{{ $json.someField }}\` or \`{{ $node["X"].json.someField }}\`, \`someField\` MUST be one of:
|
|
409
|
+
|
|
410
|
+
(a) a field listed in the optional \`## Node Output Schemas\` section for that node, OR
|
|
411
|
+
(b) a field you yourself created earlier in the same workflow (in a Set / Code / Function node's \`parameters\`).
|
|
412
|
+
|
|
413
|
+
If neither applies, you MUST NOT invent a field name from training data. Pick the closest documented field, OR pass the entire \`$json\` object, OR add an explicit \`Set\` node upstream that creates the field.
|
|
414
|
+
|
|
415
|
+
**Common Gmail mistake:** writing \`{{ $json.subject }}\` — Gmail's \`getAll\` operation returns \`snippet\` (top-level) and \`payload.headers\` (an array of \`{name, value}\` entries; extract Subject by filtering \`name == 'Subject'\`). Use the schema, not your guess.
|
|
416
|
+
|
|
417
|
+
**Reference your own intermediate nodes precisely.** If a Code or Function node emits a field named \`concatenated_snippet\`, downstream nodes must reference exactly \`concatenated_snippet\` — not \`concatenate_snippet\`, not \`concatenatedSnippet\`. Typos are not auto-corrected; copy the field name verbatim from the upstream node.
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
## **Handling Incomplete or Ambiguous Prompts**
|
|
422
|
+
|
|
423
|
+
The workflow will be shown to the user as a preview before deployment. Use the \`_meta\` field to communicate assumptions, suggestions, and clarification needs.
|
|
424
|
+
|
|
425
|
+
When the user prompt lacks specific details:
|
|
426
|
+
|
|
427
|
+
1. **Make reasonable assumptions** based on common use cases
|
|
428
|
+
2. **Use sensible defaults**:
|
|
429
|
+
- Email service: Prefer Gmail over generic SMTP
|
|
430
|
+
- Schedule: Default to daily at 9 AM if frequency not specified
|
|
431
|
+
- Data format: Use JSON for structured data
|
|
432
|
+
|
|
433
|
+
3. **Always include a \`_meta\` field** documenting your reasoning:
|
|
434
|
+
|
|
435
|
+
\`\`\`json
|
|
436
|
+
{
|
|
437
|
+
"name": "Workflow Name",
|
|
438
|
+
"nodes": [...],
|
|
439
|
+
"connections": {...},
|
|
440
|
+
"_meta": {
|
|
441
|
+
"assumptions": [
|
|
442
|
+
"Using Gmail as email service (not specified)",
|
|
443
|
+
"Running daily at 9 AM (frequency not specified)"
|
|
444
|
+
],
|
|
445
|
+
"suggestions": [
|
|
446
|
+
"Consider adding error notification to Slack",
|
|
447
|
+
"You may want to filter payments by status"
|
|
448
|
+
],
|
|
449
|
+
"requiresClarification": []
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
\`\`\`
|
|
453
|
+
|
|
454
|
+
4. **Use \`requiresClarification\` aggressively** when:
|
|
455
|
+
- The request is so vague that you cannot determine which services to use (e.g. "automate something", "help me with work")
|
|
456
|
+
- Critical parameters are missing AND cannot be reasonably inferred (e.g. "send data" — send where? what data?)
|
|
457
|
+
- Multiple fundamentally different interpretations exist (e.g. "connect my CRM" — which CRM? what operation?)
|
|
458
|
+
- The request names a service but gives no indication of what action to perform on it
|
|
459
|
+
- The user references a target (server, channel, chat, contact) by name OR generically (*"Discord"*, *"my channel"*) and \`## Runtime Facts\` does NOT contain a matching entry
|
|
460
|
+
|
|
461
|
+
5. **Do NOT use \`requiresClarification\`** for:
|
|
462
|
+
- Minor details that have sensible defaults (schedule frequency, email subject, timezone)
|
|
463
|
+
- Preferences that can be changed later (formatting, specific field mappings)
|
|
464
|
+
- Things you can reasonably infer from context
|
|
465
|
+
- Targets you can resolve directly from \`## Runtime Facts\` — those MUST be filled in, not asked about
|
|
466
|
+
|
|
467
|
+
6. **Structured ClarificationRequest format (preferred when a specific node parameter is unresolved).** Each item in \`requiresClarification\` may be a free-text string OR an object of the form:
|
|
468
|
+
|
|
469
|
+
\`\`\`json
|
|
470
|
+
{
|
|
471
|
+
"kind": "target_channel" | "target_server" | "recipient" | "value" | "free_text",
|
|
472
|
+
"platform": "discord" | "slack" | "telegram" | "gmail" | "...",
|
|
473
|
+
"scope": { "guildId": "<numeric id>" },
|
|
474
|
+
"question": "Short user-facing question.",
|
|
475
|
+
"paramPath": "nodes["Discord Send"].parameters.channelId"
|
|
476
|
+
}
|
|
477
|
+
\`\`\`
|
|
478
|
+
|
|
479
|
+
- Use \`kind: "target_server"\` when the platform is known but the server/guild/workspace is not.
|
|
480
|
+
- Use \`kind: "target_channel"\` when the server is known (set \`scope.guildId\` to the resolved guild id) but the specific channel is ambiguous or missing.
|
|
481
|
+
- Use \`kind: "recipient"\` for an unresolved DM target / email address.
|
|
482
|
+
- Use \`kind: "value"\` for any other unresolved scalar parameter.
|
|
483
|
+
- Use \`kind: "free_text"\` (or a plain string) when no specific node parameter maps to the missing information.
|
|
484
|
+
- \`paramPath\` MUST point at the exact JSON path inside the workflow draft where the user's choice should land. Use bracketed string syntax for keys with spaces or quotes (\`nodes["Discord Send"].parameters.channelId\`). Stop populating that parameter — leave it absent — so the host can patch it after the user picks.
|
|
485
|
+
- Always include a \`question\` short enough to fit above a row of buttons (≤ 60 chars when possible).
|
|
486
|
+
|
|
487
|
+
**Examples:**
|
|
488
|
+
|
|
489
|
+
Prompt: "Send me Stripe payment summaries via Gmail every Monday"
|
|
490
|
+
→ Clear enough. Generate workflow. \`requiresClarification: []\`. Document email address assumption in \`assumptions\`.
|
|
491
|
+
|
|
492
|
+
Prompt: "automate my business"
|
|
493
|
+
→ Too vague. Generate a minimal best-guess workflow and set \`requiresClarification: ["What specific task or process would you like to automate?", "Which services or tools are involved?"]\`.
|
|
494
|
+
|
|
495
|
+
Prompt: "connect Slack and Gmail"
|
|
496
|
+
→ Ambiguous action. \`requiresClarification: ["What should happen between Slack and Gmail? For example: forward emails to Slack, post Slack messages via email, etc."]\`. Still generate a best-guess workflow.
|
|
497
|
+
|
|
498
|
+
Prompt: "post a daily reminder to Cozy Devs" (Runtime Facts has Cozy Devs guild with channels #general, #alerts)
|
|
499
|
+
→ Server resolves to the Cozy Devs guild id, but channel is ambiguous. Use \`guildId\` from facts; leave \`channelId\` unset and emit:
|
|
500
|
+
|
|
501
|
+
\`\`\`json
|
|
502
|
+
{
|
|
503
|
+
"kind": "target_channel",
|
|
504
|
+
"platform": "discord",
|
|
505
|
+
"scope": { "guildId": "1234567890" },
|
|
506
|
+
"question": "Which channel in Cozy Devs?",
|
|
507
|
+
"paramPath": "nodes["Discord Send"].parameters.channelId"
|
|
508
|
+
}
|
|
509
|
+
\`\`\`
|
|
510
|
+
|
|
511
|
+
Prompt: "send me a daily reminder on Discord" (Runtime Facts lists user's Discord guilds)
|
|
512
|
+
→ No specific server named. Emit a server-picker clarification first:
|
|
513
|
+
|
|
514
|
+
\`\`\`json
|
|
515
|
+
{
|
|
516
|
+
"kind": "target_server",
|
|
517
|
+
"platform": "discord",
|
|
518
|
+
"question": "Which Discord server should I post to?",
|
|
519
|
+
"paramPath": "nodes["Discord Send"].parameters.guildId"
|
|
520
|
+
}
|
|
521
|
+
\`\`\`
|
|
522
|
+
|
|
523
|
+
Then a chained channel-picker clarification with \`scope.guildId\` and \`paramPath\` for \`channelId\`. Do not invent ids; the host will patch both after the user picks.
|
|
524
|
+
|
|
525
|
+
---
|
|
526
|
+
|
|
527
|
+
**IMPORTANT**: Always generate a complete, valid workflow even if assumptions are made. Never leave placeholders or incomplete nodes. The \`requiresClarification\` questions will be shown to the user alongside the preview — they can then refine their request.
|
|
528
|
+
`;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const WORKFLOW_MATCHING_SYSTEM_PROMPT = `You are a workflow matching assistant. Your job is to analyze a user's request and match it to the most appropriate workflow from their available workflows.
|
|
2
|
+
|
|
3
|
+
Consider:
|
|
4
|
+
- Keywords and phrases in the workflow name that match the request
|
|
5
|
+
- The semantic meaning and intent of the user's request
|
|
6
|
+
- Context clues about what the workflow might do
|
|
7
|
+
|
|
8
|
+
Rules:
|
|
9
|
+
- Only return "high" confidence if the match is obvious and unambiguous
|
|
10
|
+
- Return "medium" if there's a likely match but some ambiguity
|
|
11
|
+
- Return "low" if there's a weak connection
|
|
12
|
+
- Return "none" if no workflow matches the request
|
|
13
|
+
- If multiple workflows match equally well, include all in matches array and set lower confidence
|
|
14
|
+
|
|
15
|
+
Respond with structured JSON-style fields:
|
|
16
|
+
matchedWorkflowId: best matching workflow ID, or null if no good match
|
|
17
|
+
confidence: high | medium | low | none
|
|
18
|
+
matches:
|
|
19
|
+
- id: workflow ID
|
|
20
|
+
name: workflow name
|
|
21
|
+
score: 0-100
|
|
22
|
+
reason: brief explanation`;
|