Loading...
Loading...
Generates production-ready FastGPT workflow JSON from natural language requirements. Uses AI-powered semantic template matching from built-in workflows (document translation, sales training, resume screening, financial news). Performs three-layer validation (format, connections, logic completeness). Supports incremental modifications to add/remove/modify nodes. Activates when user asks to "create FastGPT workflow", "generate workflow JSON", "design FastGPT application", or mentions workflow automation, multi-agent systems, or FastGPT templates.
npx skill4agent add yyh211/claude-meta-skill fastgpt-workflow-generatorAutomatically generate production-ready FastGPT workflow JSON from natural language requirements
{
"purpose": "Workflow objective (e.g., 'Travel planning assistance')",
"domain": "Application domain (travel/event/document/data/general)",
"complexity": "simple | medium | complex",
"features": ["aiChat", "knowledgeBase", "httpRequest", "parallel"],
"inputs": ["userChatInput", "city", "date"],
"outputs": ["Complete plan", "Recommendations"],
"externalIntegrations": ["Weather API", "Feishu API"],
"specialRequirements": ["Multi-agent", "Real-time data"]
}templates/templates/文档翻译助手.jsontemplates/销售陪练大师.jsontemplates/简历筛选助手_飞书.jsontemplates/AI金融日报.jsonCalculate similarity scores:
- Domain match: travel vs travel = 1.0, travel vs event = 0.3
- Complexity match: simple vs simple = 1.0, simple vs complex = 0.3
- Feature overlap: Jaccard similarity of feature sets
- Node count similarity: 1 - |count1 - count2| / max(count1, count2)
Combined score = 0.3 * domain + 0.2 * complexity + 0.3 * features + 0.2 * nodeCount
Select Top 3 candidate templatesFor Top 3 candidates:
1. Analyze user requirements vs template characteristics
2. Evaluate workflow structure similarity
3. Calculate comprehensive score
Final score = 0.3 * domain + 0.2 * complexity + 0.3 * features + 0.2 * semantic- Highest score < 0.5: Start from blank template
- Highest score 0.5-0.7: Use template as reference, major modifications
- Highest score > 0.7: Use template as base, minor adjustments1. Copy template structure
2. Modify nodes
- Keep: structurally similar nodes (workflowStart, userGuide)
- Modify: nodes requiring prompt/parameter adjustments
- Delete: unnecessary nodes
- Add: new requirement nodes
3. Regenerate NodeId
function generateNodeId(nodeType, nodeName, existingIds) {
// Fixed ID mapping
if (nodeType === 'workflowStart') return 'workflowStart';
if (nodeType === 'userGuide' || nodeType === 'systemConfig') return 'userGuide';
// Generate semantic ID (camelCase)
const baseName = nodeName.replace(/[\s\u4e00-\u9fa5]+/g, '');
let nodeId = baseName ? `${baseName}Node` : `${nodeType}Node`;
// Ensure uniqueness
let counter = 1;
while (existingIds.has(nodeId)) {
nodeId = `${baseName}Node_${counter}`;
counter++;
}
return nodeId;
}
4. Update references
- Traverse all inputs, replace old nodeId with new nodeId
- Update edges' source/target
- Handle two reference formats:
- Array: ["nodeId", "key"]
- Template: {{$nodeId.key$}} (Note: double braces with single $)
5. Auto-layout positions (hierarchical layout algorithm)
function autoLayout(nodes, edges) {
// Topological sort to determine layers
const layers = topologicalLayering(nodes, edges);
// Calculate positions for each layer
const LAYER_GAP_X = 350;
const NODE_GAP_Y = 150;
layers.forEach((layer, layerIndex) => {
const x = -200 + layerIndex * LAYER_GAP_X;
const totalHeight = (layer.length - 1) * NODE_GAP_Y;
const startY = -totalHeight / 2;
layer.forEach((nodeId, nodeIndex) => {
positions[nodeId] = {
x: x,
y: startY + nodeIndex * NODE_GAP_Y
};
});
});
// Fixed position for special nodes
positions['userGuide'] = { x: -600, y: -250 };
}
6. Update configuration
- Modify chatConfig.welcomeText
- Update chatConfig.variables1. Determine node list
- Required: workflowStart, userGuide
- Add based on features: chatNode, datasetSearchNode, httpRequest468, etc.
- Required: answerNode (output node)
2. Generate nodes and connections
- Use standard node templates
- Fill required fields
- Customize inputs/outputs based on requirements
3. Calculate positions and generate configuration✅ JSON is parseable
✅ Top level contains nodes, edges, chatConfig
✅ Each node contains: nodeId, name, flowNodeType, position, inputs, outputs
✅ flowNodeType is in valid type list (40+ types)
✅ position contains x, y numeric coordinates✅ edges' source/target nodes exist
✅ sourceHandle/targetHandle format correct (nodeId-source-right, nodeId-target-left)
✅ Node input references' nodes and output keys exist
✅ Reference types match (string → string)
✅ Template references {{$nodeId.key$}} nodes and keys exist
✅ No self-loops, no duplicate connections✅ Required nodes exist (workflowStart, userGuide, at least one output node)
✅ All nodes reachable from workflowStart (connectivity)
✅ No illegal cycles (unless using loop node)
✅ loop nodes correctly configured with parentNodeId and childrenNodeIdList
✅ No dead ends (non-output nodes without outgoing edges)
✅ All required inputs have valuesUse AI to analyze user request, extract:
{
"action": "add" | "delete" | "modify" | "reconnect",
"targetNodes": ["aiChatNode"],
"insertBefore": "aiChatNode",
"newNodes": [{ "type": "datasetSearchNode", "name": "Knowledge Base Search" }],
"modifications": {
"aiChatNode": {
"inputs": { "quoteQA": ["knowledgeBaseSearch", "searchResult"] }
}
}
}- Add node: generate new node, reconnect, calculate position
- Delete node: remove node, bypass reconnect, clean references
- Modify node: update inputs/outputs, validate references"Create a simple AI Q&A workflow where users input questions and AI responds directly"{
"purpose": "AI question answering",
"domain": "general",
"complexity": "simple",
"features": ["aiChat"],
"inputs": ["userChatInput"],
"outputs": ["AI response"]
}文档翻译助手.json{
"nodes": [
{
"nodeId": "userGuide",
"name": "System Configuration",
"flowNodeType": "userGuide",
"position": {"x": -600, "y": -250}
},
{
"nodeId": "workflowStart",
"name": "Start",
"flowNodeType": "workflowStart",
"position": {"x": -150, "y": 100},
"outputs": [
{"key": "userChatInput", "type": "static", "valueType": "string"}
]
},
{
"nodeId": "aiChatNode",
"name": "AI Response",
"flowNodeType": "chatNode",
"position": {"x": 200, "y": 100},
"inputs": [
{
"key": "model",
"valueType": "string",
"value": "gpt-4"
},
{
"key": "systemPrompt",
"valueType": "string",
"value": "You are a professional AI assistant that can answer various questions. Please provide accurate and helpful answers based on user questions."
},
{
"key": "userChatInput",
"valueType": "string",
"value": ["workflowStart", "userChatInput"]
}
],
"outputs": [
{"key": "answerText", "type": "static", "valueType": "string"}
]
},
{
"nodeId": "outputNode",
"name": "Output Answer",
"flowNodeType": "answerNode",
"position": {"x": 550, "y": 100},
"inputs": [
{
"key": "text",
"valueType": "string",
"value": ["aiChatNode", "answerText"]
}
]
}
],
"edges": [
{
"source": "workflowStart",
"target": "aiChatNode",
"sourceHandle": "workflowStart-source-right",
"targetHandle": "aiChatNode-target-left"
},
{
"source": "aiChatNode",
"target": "outputNode",
"sourceHandle": "aiChatNode-source-right",
"targetHandle": "outputNode-target-left"
}
],
"chatConfig": {
"welcomeText": "Welcome to the AI Q&A assistant! Please enter your question.",
"variables": []
}
}"Create a document translation workflow that translates user-uploaded documents from Chinese to English"{
"purpose": "Document translation",
"domain": "document",
"complexity": "medium",
"features": ["readFiles", "aiChat", "textOutput"],
"inputs": ["userFiles"],
"outputs": ["translated document"]
}文档翻译助手.jsonworkflowStart → readFiles → translateNode → outputNode"I have an existing AI Q&A workflow (simple_qa_workflow.json),
I want to search the knowledge base first before AI answers,
find relevant information then generate response"workflowStart → aiChatNode → outputNodeworkflowStart → knowledgeBaseSearch → aiChatNode → outputNode{
"action": "add",
"targetNodes": ["aiChatNode"],
"insertBefore": "aiChatNode",
"newNodes": [
{
"type": "datasetSearchNode",
"name": "Knowledge Base Search"
}
],
"modifications": {
"aiChatNode": {
"inputs": {
"quoteQA": ["knowledgeBaseSearch", "searchResult"]
}
}
}
}knowledgeBaseSearchworkflowStart → knowledgeBaseSearchknowledgeBaseSearch → aiChatNode{
"nodes": [
{
"nodeId": "knowledgeBaseSearch",
"name": "Knowledge Base Search",
"flowNodeType": "datasetSearchNode",
"position": {"x": 50, "y": 100},
"inputs": [
{
"key": "datasetIds",
"valueType": "selectDataset",
"value": [],
"required": true
},
{
"key": "searchQuery",
"valueType": "string",
"value": ["workflowStart", "userChatInput"],
"required": true
},
{
"key": "similarity",
"valueType": "number",
"value": 0.5
},
{
"key": "limitCount",
"valueType": "number",
"value": 5
}
],
"outputs": [
{
"key": "searchResult",
"type": "static",
"valueType": "datasetQuote"
}
]
},
{
"nodeId": "aiChatNode",
"inputs": [
{
"key": "quoteQA",
"valueType": "datasetQuote",
"value": ["knowledgeBaseSearch", "searchResult"]
}
]
}
],
"edges": [
{
"source": "workflowStart",
"target": "knowledgeBaseSearch"
},
{
"source": "knowledgeBaseSearch",
"target": "aiChatNode"
},
{
"source": "aiChatNode",
"target": "outputNode"
}
]
}knowledgeBaseSearchaiChatNodeknowledgeBaseSearch → aiChatNodeworkflowStart → knowledgeBaseSearchworkflowStart → aiChatNodeworkflowStartuserGuide_1_2generateNodeId('chatNode', 'Travel Planning Assistant')TravelPlanningAssistantNodegenerateNodeId('httpRequest468', 'Weather Query')WeatherQueryNodegenerateNodeId('chatNode', 'Assistant', {TravelPlanningAssistantNode})AssistantNode_1"value": ["workflowStart", "userChatInput"]"value": "Please create a plan for me.\n\nDestination: {{$workflowStart.userChatInput$}}\n\nWeather: {{$weatherQueryNode.httpRawResponse$}}"{{$nodeId.key$}}childrenNodeIdListparentNodeIdweatherQueryNode["nodeId", "key"]{{$nodeId.key$}}{{nodeId.key}}flowNodeTypereferences/node_types_reference.mdchatNodeaiChathttpRequest468["workflowStart", "userChatInput"]{{$workflowStart.userChatInput$}}{$workflowStart.userChatInput$}flowNodeType: "loop"parentNodeIdchildrenNodeIdList## Phase 1: JSON Format Check
- [ ] JSON is parseable
- [ ] Contains nodes, edges, chatConfig
- [ ] All strings use double quotes
- [ ] No trailing commas
## Phase 2: Node Check
- [ ] workflowStart node exists
- [ ] At least one output node exists
- [ ] All flowNodeType valid
- [ ] All nodeId unique
- [ ] All position contains x, y
## Phase 3: Connection Check
- [ ] All edges' source and target exist
- [ ] All handle format correct
- [ ] No duplicate edges, no self-loops
## Phase 4: Reference Check
- [ ] All array references' nodes and keys exist
- [ ] All template references' nodes and keys exist
- [ ] Reference types match
## Phase 5: Logic Check
- [ ] All nodes reachable from workflowStart
- [ ] No illegal cycles
- [ ] No dead-end nodes
- [ ] All required inputs have values
## Phase 6: Runtime Test
- [ ] Import to FastGPT without errors
- [ ] Configure necessary parameters
- [ ] Run test cases
- [ ] Check output meets expectationstemplates/文档翻译助手.jsontemplates/销售陪练大师.jsontemplates/简历筛选助手_飞书.jsontemplates/AI金融日报.jsonreferences/node_types_reference.mdreferences/validation_rules.mdreferences/template_matching.mdreferences/json_structure_spec.mdexamples/example1_simple_qa.mdexamples/example2_travel_planning.mdexamples/example3_incremental_modify.md# Validate workflow JSON
node scripts/validate_workflow.js path/to/workflow.json
# Copy template
cp templates/文档翻译助手.json my_workflow.json
# View template list
ls -lh templates/