{ "kind": "open-flow-workflow", "version": 1, "name": "Publish a Reddit Post and Comment", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_ff540f7f2bf1257c": { "name": "Enter post details", "kind": "start", "inputDefs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "subreddit" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "title" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "text" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "comment" } ] }, "n_5855331b247ea435": { "inputs": { "subreddit": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ff540f7f2bf1257c", "output": "subreddit" } ] }, "title": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ff540f7f2bf1257c", "output": "title" } ] }, "text": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ff540f7f2bf1257c", "output": "text" } ] }, "comment": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ff540f7f2bf1257c", "output": "comment" } ] } }, "name": "Validate post details", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "subreddit" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "title" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "text" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "comment" } ], "outputs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "subreddit" }, { "jsonSchema": { "type": "string", "minLength": 1, "maxLength": 300 }, "nullable": false, "handle": "title" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "text" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "comment" } ], "name": "Validate post details", "moduleId": "n_73236f8a01a7cd68", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_4b0ac1e38ad8381d": { "inputs": { "subreddit": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_5855331b247ea435", "output": "subreddit" } ] }, "title": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_5855331b247ea435", "output": "title" } ] }, "kind": { "kind": "value", "value": "self" }, "text": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_5855331b247ea435", "output": "text" } ] } }, "name": "Publish text post", "kind": "task", "task": { "inputs": [ { "description": "The subreddit name without the r/ prefix.", "jsonSchema": { "type": "string", "minLength": 1, "description": "The subreddit name without the r/ prefix." }, "nullable": false, "handle": "subreddit" }, { "description": "The title of the Reddit post.", "jsonSchema": { "type": "string", "maxLength": 300, "minLength": 1, "description": "The title of the Reddit post." }, "nullable": false, "handle": "title" }, { "description": "Whether to create a text post or link post.", "jsonSchema": { "type": "string", "enum": [ "self", "link" ], "description": "Whether to create a text post or link post." }, "nullable": false, "handle": "kind" }, { "description": "The Markdown body for a text post.", "jsonSchema": { "type": "string", "description": "The Markdown body for a text post." }, "nullable": true, "handle": "text", "value": null }, { "description": "The destination URL for a link post.", "jsonSchema": { "type": "string", "format": "uri", "description": "The destination URL for a link post." }, "nullable": true, "handle": "url", "value": null }, { "description": "The subreddit link flair template ID to apply.", "jsonSchema": { "type": "string", "maxLength": 36, "description": "The subreddit link flair template ID to apply." }, "nullable": true, "handle": "flairId", "value": null }, { "description": "The custom link flair text to apply when supported.", "jsonSchema": { "type": "string", "maxLength": 64, "description": "The custom link flair text to apply when supported." }, "nullable": true, "handle": "flairText", "value": null }, { "description": "Whether Reddit should send inbox replies for the post.", "jsonSchema": { "type": "boolean", "description": "Whether Reddit should send inbox replies for the post." }, "nullable": true, "handle": "sendReplies", "value": null }, { "description": "Whether the post should be marked not safe for work.", "jsonSchema": { "type": "boolean", "description": "Whether the post should be marked not safe for work." }, "nullable": true, "handle": "nsfw", "value": null }, { "description": "Whether the post should be marked as a spoiler.", "jsonSchema": { "type": "boolean", "description": "Whether the post should be marked as a spoiler." }, "nullable": true, "handle": "spoiler", "value": null } ], "outputs": [ { "description": "The raw object returned by the Reddit Data API.", "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "The raw object returned by the Reddit Data API." }, "nullable": false, "handle": "post" }, { "description": "The resulting Reddit post URL, or null.", "jsonSchema": { "type": [ "string", "null" ], "description": "The resulting Reddit post URL, or null." }, "nullable": true, "handle": "url" } ], "name": "Publish text post", "executor": { "kind": "connector", "action": "reddit.create_post" } } }, "n_ea4d303e4be4b2ea": { "inputs": { "post": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_4b0ac1e38ad8381d", "output": "post" } ] } }, "name": "Confirm post creation", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "The raw object returned by the Reddit Data API." }, "nullable": false, "handle": "post" } ], "outputs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "id" } ], "name": "Confirm post creation", "moduleId": "n_2d084df28e48bd33", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_c953a7af02958eaf": { "inputs": { "subreddit": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_5855331b247ea435", "output": "subreddit" } ] }, "postId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ea4d303e4be4b2ea", "output": "id" } ] }, "limit": { "kind": "value", "value": 1 } }, "name": "Read the post", "kind": "task", "task": { "inputs": [ { "description": "The base-36 Reddit post ID without the t3_ prefix.", "jsonSchema": { "type": "string", "minLength": 1, "description": "The base-36 Reddit post ID without the t3_ prefix." }, "nullable": false, "handle": "postId" }, { "description": "The subreddit name without the r/ prefix.", "jsonSchema": { "type": "string", "description": "The subreddit name without the r/ prefix." }, "nullable": true, "handle": "subreddit", "value": null }, { "description": "The comment sort order.", "jsonSchema": { "type": "string", "enum": [ "confidence", "top", "new", "controversial", "old", "random", "qa", "live" ], "description": "The comment sort order." }, "nullable": true, "handle": "sort", "value": null }, { "description": "The maximum number of comments to return.", "jsonSchema": { "type": "integer", "minimum": 1, "description": "The maximum number of comments to return." }, "nullable": true, "handle": "limit", "value": null }, { "description": "The maximum depth of comment subtrees to return.", "jsonSchema": { "type": "integer", "minimum": 1, "description": "The maximum depth of comment subtrees to return." }, "nullable": true, "handle": "depth", "value": null } ], "outputs": [ { "description": "The raw object returned by the Reddit Data API.", "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "The raw object returned by the Reddit Data API." }, "nullable": false, "handle": "post" }, { "description": "The top-level comment things, including nested replies.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": {}, "additionalProperties": true, "description": "The raw object returned by the Reddit Data API." }, "description": "The top-level comment things, including nested replies." }, "nullable": false, "handle": "comments" } ], "name": "Read the post", "executor": { "kind": "connector", "action": "reddit.get_post_comments" } } }, "n_0714ff9ed92bae6b": { "inputs": { "subreddit": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_5855331b247ea435", "output": "subreddit" } ] }, "id": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ea4d303e4be4b2ea", "output": "id" } ] }, "post": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c953a7af02958eaf", "output": "post" } ] } }, "name": "Verify the post", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "subreddit" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "id" }, { "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "The raw object returned by the Reddit Data API." }, "nullable": false, "handle": "post" } ], "outputs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "fullname" } ], "name": "Verify the post", "moduleId": "n_bb4fd8373312826e", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_baaaa7e5c2e299dc": { "inputs": { "parentFullname": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_0714ff9ed92bae6b", "output": "fullname" } ] }, "text": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_5855331b247ea435", "output": "comment" } ] } }, "name": "Add comment", "kind": "task", "task": { "inputs": [ { "description": "A Reddit fullname such as t3_postid for a post or t1_commentid for a comment.", "jsonSchema": { "type": "string", "minLength": 1, "description": "A Reddit fullname such as t3_postid for a post or t1_commentid for a comment." }, "nullable": false, "handle": "parentFullname" }, { "description": "The Markdown body of the comment.", "jsonSchema": { "type": "string", "minLength": 1, "description": "The Markdown body of the comment." }, "nullable": false, "handle": "text" } ], "outputs": [ { "description": "The raw object returned by the Reddit Data API.", "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "The raw object returned by the Reddit Data API." }, "nullable": false, "handle": "comment" } ], "name": "Add comment", "executor": { "kind": "connector", "action": "reddit.create_comment" } } }, "n_8fb08a3d51b52de4": { "inputs": { "fullname": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_0714ff9ed92bae6b", "output": "fullname" } ] }, "comment": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_baaaa7e5c2e299dc", "output": "comment" } ] } }, "name": "Confirm comment", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "fullname" }, { "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "The raw object returned by the Reddit Data API." }, "nullable": false, "handle": "comment" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "comment" } ], "name": "Confirm comment", "moduleId": "n_704aa8a7516dd05c", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_452a5af22368e0e8": { "name": "Published comment", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "comment" } ], "outputMappings": { "comment": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_8fb08a3d51b52de4", "output": "comment" } ] } } } }, "edges": [ { "source": "n_ff540f7f2bf1257c", "target": "n_5855331b247ea435" }, { "source": "n_5855331b247ea435", "target": "n_4b0ac1e38ad8381d" }, { "source": "n_4b0ac1e38ad8381d", "target": "n_ea4d303e4be4b2ea" }, { "source": "n_ea4d303e4be4b2ea", "target": "n_c953a7af02958eaf" }, { "source": "n_c953a7af02958eaf", "target": "n_0714ff9ed92bae6b" }, { "source": "n_0714ff9ed92bae6b", "target": "n_baaaa7e5c2e299dc" }, { "source": "n_baaaa7e5c2e299dc", "target": "n_8fb08a3d51b52de4" }, { "source": "n_8fb08a3d51b52de4", "target": "n_452a5af22368e0e8" } ] } }, "modules": { "n_73236f8a01a7cd68": { "name": "Validate post details", "imports": [], "source": "export default function input({subreddit,title,text,comment}){if(typeof subreddit!=='string'||!/^[A-Za-z0-9_]+$/.test(subreddit)||typeof title!=='string'||!title.trim()||[...title].length>300||typeof text!=='string'||!text.trim()||typeof comment!=='string'||!comment.trim())throw Error('Enter a subreddit without r/, a title, post text and comment');return {subreddit,title,text,comment}}\n" }, "n_2d084df28e48bd33": { "name": "Confirm post creation", "imports": [], "source": "export default function({post}){const id=post?.id;if(typeof id!=='string'||!/^[a-z0-9]+$/.test(id))throw Error('Post creation was not confirmed');return {id}}\n" }, "n_bb4fd8373312826e": { "name": "Verify the post", "imports": [], "source": "export default function({subreddit,id,post}){if(post?.id!==id||typeof post.subreddit!=='string'||post.subreddit.toLowerCase()!==subreddit.toLowerCase())throw Error('The created post could not be confirmed');return {fullname:'t3_'+id}}\n" }, "n_704aa8a7516dd05c": { "name": "Confirm comment", "imports": [], "source": "export default function({fullname,comment}){if(typeof comment?.name!=='string'||!/^t1_[a-z0-9]+$/.test(comment.name)||comment.parent_id!==fullname)throw Error('Comment creation was not confirmed');return {comment}}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }