$ cat workspace-template.yaml
Social Content generator
// generate social media content post
// Canvas Preview
// Instruction
社交媒体产品图片生成器
Overview
This workflow generates a comprehensive set of social media marketing images for a product, categorized into "Scene," "Close-up," and "With Person" styles. It requires a source product image from Google Drive and optional reference images to produce a user-defined number of variations per category, with unique prompt variations for each node to ensure visual diversity.
Workflow Chain
Node Reference
- File: Selects the source product image from Drive; feeds
Drive Image Reader. - Drive Image Reader: Converts the selected file into an image format; feeds all
Image Editnodes. - Image Edit: Processes reference images with a unique prompt to generate stylized output; configurable via
prompt,aspect_ratio, andseed. - Image Creation: Generates a new avatar image from a text prompt; feeds
With Personnodes. - Workspace Picker: Selects an external workspace to source an avatar; feeds
With Personnodes. - Reference Image Readers: Optional nodes to provide specific style guidance for Scene or Close-up generations.
Execution Strategy
You MUST complete all 3 phases in order: Phase 1 -> Phase 2 -> Phase 3. Do NOT skip any phase.
Phase 1: Initialization and User Input
- Call
requestUserDecisionto gather:- "What is the core theme/environment for the images?" (Context: Base theme for all prompts).
- "How many images per group (1-5)?" (Context: Determines node count).
- "What is the source product image?" (Context: Sets
driveItemId). - "Do you want to publish these images to social media upon completion?" (Context: Terminal side-effect).
- Phase 1 complete. Now proceed to Phase 2. Do NOT skip to Phase 3.
Phase 2: Configuration and Node Management
3. Use nodeFinder to locate the File node and upsertNode to set the driveItemId.
4. For each category (Scene, Close-up, With Person), compare the current node count against the user's requested number:
- If current count < requested: Use
batchCloneNodesto add missing nodes. - If current count > requested: Use
nodeFinderto identify and remove extra nodes.
- For EACH
Image Editnode, useupsertNodeto update thepromptfield with unique stylistic modifiers. - Perform layout maintenance:
- Use
sectionFinderto identify the relevant section IDs. - For each section, call
sectionManager(ungroup, { sectionId }). - Call
organizeNodesto arrange the updated node set. - Call
sectionManager(group, { nodeIds, label })to re-group the nodes. - Call
autoLayout()to finalize the canvas.
- Use
- Phase 2 complete. Now proceed to Phase 3. Do NOT skip to Phase 3.
Phase 3: Execution and Finalization
8. Use nodeExecutor to trigger the Image Edit nodes for all active groups.
9. If the publish decision in Phase 1 was "Yes", perform the final post-generation action.
10. Call followUp to present the generated images to the user for review.
Configuration Tips
Error Handling
- Missing Drive File: Ensure the
driveItemIdis valid; usesearchDriveItemsto verify existence. - Connection Failure: If
upsertEdgefails, usenodeFinderto verify theportTypematches between source and target. - Generation Timeout: If
Image Editfails, reducemegapixelto 1.0 and retry.
Incremental Edits to an Existing Workflow
- Detection: If the canvas already contains nodes, treat the request as an edit.
- Add / remove / reorder recipes: Use
batchCloneNodesfor additions; usenodeFinder+deleteNodefor removals. Always re-run the layout sequence (ungroup->organizeNodes->group->autoLayout) after structural changes. - Post-edit: Re-run pre-execution verification, then honor the publish decision (re-present the gate under the post-build pattern).
// Dependencies
1from input import File2from input import DriveImageReader3from process import ImageEdit4from process import ImageCreation5from input import WorkspacePicker$ git log --oneline