{ "kind": "open-flow-workflow", "version": 1, "name": "Create and Update a WordPress Draft", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_9cad13df0dfa9884": { "name": "Create a WordPress draft", "kind": "start", "inputDefs": [] }, "n_cc5c3d266c33f295": { "inputs": { "title": { "kind": "value", "value": "created from n8n" }, "status": { "kind": "value", "value": "draft" } }, "name": "Create the titled draft", "kind": "task", "task": { "inputs": [ { "description": "The post title.", "jsonSchema": { "type": "string", "description": "The post title." }, "nullable": true, "handle": "title", "value": null }, { "description": "The post content.", "jsonSchema": { "type": "string", "description": "The post content." }, "nullable": true, "handle": "content", "value": null }, { "description": "The post excerpt.", "jsonSchema": { "type": "string", "description": "The post excerpt." }, "nullable": true, "handle": "excerpt", "value": null }, { "description": "The WordPress URL slug.", "jsonSchema": { "type": "string", "pattern": "\\S", "minLength": 1, "description": "The WordPress URL slug." }, "nullable": true, "handle": "slug", "value": null }, { "description": "The WordPress publication status.", "jsonSchema": { "type": "string", "enum": [ "publish", "future", "draft", "pending", "private" ], "description": "The WordPress publication status." }, "nullable": true, "handle": "status", "value": null }, { "description": "Category IDs assigned to the post; an empty array clears all assignments.", "jsonSchema": { "type": "array", "items": { "type": "integer", "exclusiveMinimum": 0, "description": "The numeric WordPress resource ID." }, "description": "Category IDs assigned to the post; an empty array clears all assignments." }, "nullable": true, "handle": "categories", "value": null }, { "description": "Tag IDs assigned to the post; an empty array clears all assignments.", "jsonSchema": { "type": "array", "items": { "type": "integer", "exclusiveMinimum": 0, "description": "The numeric WordPress resource ID." }, "description": "Tag IDs assigned to the post; an empty array clears all assignments." }, "nullable": true, "handle": "tags", "value": null }, { "description": "The featured media attachment ID; zero removes the featured image.", "jsonSchema": { "type": "integer", "minimum": 0, "description": "The featured media attachment ID; zero removes the featured image." }, "nullable": true, "handle": "featuredMedia", "value": null }, { "description": "Meta fields to send to WordPress.", "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "Meta fields to send to WordPress." }, "nullable": true, "handle": "meta", "value": null } ], "outputs": [ { "description": "A WordPress post object.", "jsonSchema": { "type": "object", "properties": { "id": { "type": "integer", "exclusiveMinimum": 0, "description": "The numeric WordPress post ID." }, "slug": { "type": "string", "description": "The WordPress post slug." }, "status": { "type": "string", "description": "The WordPress post status." }, "title": { "type": "object", "properties": { "rendered": { "type": "string", "description": "The rendered HTML value returned by WordPress." } }, "additionalProperties": true, "description": "A WordPress rendered object." } }, "required": [ "id", "slug", "status", "title" ], "additionalProperties": true, "description": "A WordPress post object." }, "nullable": false, "handle": "post" } ], "name": "Create the titled draft", "executor": { "kind": "connector", "action": "wordpress.create_post" } } }, "n_a8715ac44d9f23b6": { "inputs": { "post": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_cc5c3d266c33f295", "output": "post" } ] }, "content": { "kind": "value", "value": "This post was created using the n8n workflow." } }, "name": "Prepare the draft content", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "properties": { "id": { "type": "integer", "exclusiveMinimum": 0, "description": "The numeric WordPress post ID." }, "slug": { "type": "string", "description": "The WordPress post slug." }, "status": { "type": "string", "description": "The WordPress post status." }, "title": { "type": "object", "properties": { "rendered": { "type": "string", "description": "The rendered HTML value returned by WordPress." } }, "additionalProperties": true, "description": "A WordPress rendered object." } }, "required": [ "id", "slug", "status", "title" ], "additionalProperties": true, "description": "A WordPress post object." }, "nullable": false, "handle": "post" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "content" } ], "outputs": [ { "jsonSchema": { "type": "integer", "exclusiveMinimum": 0 }, "nullable": false, "handle": "postId" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "content" } ], "name": "Prepare the draft content", "moduleId": "n_fd6417d8abbb0c30", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_7e774ff2b3bbe5a9": { "inputs": { "id": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_a8715ac44d9f23b6", "output": "postId" } ] }, "content": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_a8715ac44d9f23b6", "output": "content" } ] } }, "name": "Update the same draft", "kind": "task", "task": { "inputs": [ { "description": "The post title.", "jsonSchema": { "type": "string", "description": "The post title." }, "nullable": true, "handle": "title", "value": null }, { "description": "The post content.", "jsonSchema": { "type": "string", "description": "The post content." }, "nullable": true, "handle": "content", "value": null }, { "description": "The post excerpt.", "jsonSchema": { "type": "string", "description": "The post excerpt." }, "nullable": true, "handle": "excerpt", "value": null }, { "description": "The WordPress URL slug.", "jsonSchema": { "type": "string", "pattern": "\\S", "minLength": 1, "description": "The WordPress URL slug." }, "nullable": true, "handle": "slug", "value": null }, { "description": "The WordPress publication status.", "jsonSchema": { "type": "string", "enum": [ "publish", "future", "draft", "pending", "private" ], "description": "The WordPress publication status." }, "nullable": true, "handle": "status", "value": null }, { "description": "Category IDs assigned to the post; an empty array clears all assignments.", "jsonSchema": { "type": "array", "items": { "type": "integer", "exclusiveMinimum": 0, "description": "The numeric WordPress resource ID." }, "description": "Category IDs assigned to the post; an empty array clears all assignments." }, "nullable": true, "handle": "categories", "value": null }, { "description": "Tag IDs assigned to the post; an empty array clears all assignments.", "jsonSchema": { "type": "array", "items": { "type": "integer", "exclusiveMinimum": 0, "description": "The numeric WordPress resource ID." }, "description": "Tag IDs assigned to the post; an empty array clears all assignments." }, "nullable": true, "handle": "tags", "value": null }, { "description": "The featured media attachment ID; zero removes the featured image.", "jsonSchema": { "type": "integer", "minimum": 0, "description": "The featured media attachment ID; zero removes the featured image." }, "nullable": true, "handle": "featuredMedia", "value": null }, { "description": "Meta fields to send to WordPress.", "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "Meta fields to send to WordPress." }, "nullable": true, "handle": "meta", "value": null }, { "description": "The numeric WordPress resource ID.", "jsonSchema": { "type": "integer", "exclusiveMinimum": 0, "description": "The numeric WordPress resource ID." }, "nullable": false, "handle": "id" } ], "outputs": [ { "description": "A WordPress post object.", "jsonSchema": { "type": "object", "properties": { "id": { "type": "integer", "exclusiveMinimum": 0, "description": "The numeric WordPress post ID." }, "slug": { "type": "string", "description": "The WordPress post slug." }, "status": { "type": "string", "description": "The WordPress post status." }, "title": { "type": "object", "properties": { "rendered": { "type": "string", "description": "The rendered HTML value returned by WordPress." } }, "additionalProperties": true, "description": "A WordPress rendered object." } }, "required": [ "id", "slug", "status", "title" ], "additionalProperties": true, "description": "A WordPress post object." }, "nullable": false, "handle": "post" } ], "name": "Update the same draft", "executor": { "kind": "connector", "action": "wordpress.update_post" } } }, "n_20ddafd65310b6f7": { "inputs": { "created": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_cc5c3d266c33f295", "output": "post" } ] }, "updated": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7e774ff2b3bbe5a9", "output": "post" } ] }, "postId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_a8715ac44d9f23b6", "output": "postId" } ] } }, "name": "Confirm the updated post", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "properties": { "id": { "type": "integer", "exclusiveMinimum": 0, "description": "The numeric WordPress post ID." }, "slug": { "type": "string", "description": "The WordPress post slug." }, "status": { "type": "string", "description": "The WordPress post status." }, "title": { "type": "object", "properties": { "rendered": { "type": "string", "description": "The rendered HTML value returned by WordPress." } }, "additionalProperties": true, "description": "A WordPress rendered object." } }, "required": [ "id", "slug", "status", "title" ], "additionalProperties": true, "description": "A WordPress post object." }, "nullable": false, "handle": "created" }, { "jsonSchema": { "type": "object", "properties": { "id": { "type": "integer", "exclusiveMinimum": 0, "description": "The numeric WordPress post ID." }, "slug": { "type": "string", "description": "The WordPress post slug." }, "status": { "type": "string", "description": "The WordPress post status." }, "title": { "type": "object", "properties": { "rendered": { "type": "string", "description": "The rendered HTML value returned by WordPress." } }, "additionalProperties": true, "description": "A WordPress rendered object." } }, "required": [ "id", "slug", "status", "title" ], "additionalProperties": true, "description": "A WordPress post object." }, "nullable": false, "handle": "updated" }, { "jsonSchema": { "type": "integer", "exclusiveMinimum": 0 }, "nullable": false, "handle": "postId" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "created" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "updated" } ], "name": "Confirm the updated post", "moduleId": "n_55daf7c39ffee282", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_6b8aaadc2d7912b6": { "name": "Created and updated post", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "created" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "updated" } ], "outputMappings": { "created": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_20ddafd65310b6f7", "output": "created" } ] }, "updated": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_20ddafd65310b6f7", "output": "updated" } ] } } } }, "edges": [ { "source": "n_9cad13df0dfa9884", "target": "n_cc5c3d266c33f295" }, { "source": "n_cc5c3d266c33f295", "target": "n_a8715ac44d9f23b6" }, { "source": "n_a8715ac44d9f23b6", "target": "n_7e774ff2b3bbe5a9" }, { "source": "n_7e774ff2b3bbe5a9", "target": "n_20ddafd65310b6f7" }, { "source": "n_20ddafd65310b6f7", "target": "n_6b8aaadc2d7912b6" } ] } }, "modules": { "n_fd6417d8abbb0c30": { "name": "Prepare the draft content", "imports": [], "source": "export default function wordpressPostPlan({ post, content }) {\n if (!post || !Number.isSafeInteger(post.id) || post.id <= 0) throw new Error('WordPress did not return a valid post ID; inspect the site before retrying');\n if (typeof content !== 'string') throw new Error('Invalid post content');\n return { postId: post.id, content };\n}\n" }, "n_55daf7c39ffee282": { "name": "Confirm the updated post", "imports": [], "source": "export default function wordpressPostConfirm({ created, updated, postId }) {\n if (!created || created.id !== postId || !updated || updated.id !== postId) throw new Error('WordPress did not confirm the same post ID; inspect the site before retrying');\n return { created, updated };\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }