{ "kind": "open-flow-workflow", "version": 1, "name": "Publish a Post to a Medium Publication", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_eb34f40395c6edbe": { "name": "Run manually", "kind": "start", "inputDefs": [] }, "n_cdb569172ea9ece0": { "inputs": { "publicationId": { "kind": "value", "value": "YOUR_PUBLICATION_ID" }, "title": { "kind": "value", "value": "" }, "content": { "kind": "value", "value": "" }, "contentFormat": { "kind": "value", "value": "markdown" } }, "name": "Prepare the article", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "publicationId" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "title" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "content" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "contentFormat" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" } ], "name": "Prepare the article", "moduleId": "n_c3d9a72af51472ea", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_715b081898c1591f": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_cdb569172ea9ece0", "output": "url" } ] }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_cdb569172ea9ece0", "output": "body" } ] }, "auth.token": { "kind": "unset" } }, "name": "Publish the article", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.token" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Publish the article", "executor": { "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "authentication": { "type": "bearer" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_804881eb641a171d": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_715b081898c1591f", "output": "body" } ] }, "statusCode": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_715b081898c1591f", "output": "statusCode" } ] } }, "name": "Confirm the post", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "post" } ], "name": "Confirm the post", "moduleId": "n_56b8acd2d2e83de7", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_efe037259a619427": { "name": "Published post", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "post" } ], "outputMappings": { "post": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_804881eb641a171d", "output": "post" } ] } } } }, "edges": [ { "source": "n_eb34f40395c6edbe", "target": "n_cdb569172ea9ece0" }, { "source": "n_cdb569172ea9ece0", "target": "n_715b081898c1591f" }, { "source": "n_715b081898c1591f", "target": "n_804881eb641a171d" }, { "source": "n_804881eb641a171d", "target": "n_efe037259a619427" } ] } }, "modules": { "n_c3d9a72af51472ea": { "name": "Prepare the article", "imports": [], "source": "export default function prepare({publicationId,title,content,contentFormat}) {\n if(!publicationId||publicationId.startsWith('YOUR_')||!title||!content||!['markdown','html'].includes(contentFormat)) throw Error('Set a publication ID, title, content and valid format.');\n return {url:'https://api.medium.com/v1/publications/'+encodeURIComponent(publicationId)+'/posts',body:{title,content,contentFormat,tags:[]}};\n}\n" }, "n_56b8acd2d2e83de7": { "name": "Confirm the post", "imports": [], "source": "export default function check({body,statusCode}) {\n if(statusCode<200||statusCode>=300||!body||!body.data||typeof body.data.id!=='string'||!body.data.id)throw Error('Medium did not confirm a post ID.');\n return {post:body};\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }