{ "kind": "open-flow-workflow", "version": 1, "name": "Create a Mattermost Channel and Welcome a Member", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_c6c7721c61aaa958": { "name": "Welcome a channel member", "kind": "start", "inputDefs": [] }, "n_120e2241c726e5cd": { "inputs": { "teamId": { "kind": "value", "value": "YOUR_MATTERMOST_TEAM_ID" }, "userId": { "kind": "value", "value": "YOUR_MATTERMOST_USER_ID" }, "channelName": { "kind": "value", "value": "docs" }, "displayName": { "kind": "value", "value": "Docs" }, "message": { "kind": "value", "value": "Hey! Welcome to the channel!" } }, "name": "Choose team, user and channel", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "teamId" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "userId" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "channelName" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "displayName" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "message" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "createBody" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "userId" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "message" } ], "name": "Choose team, user and channel", "moduleId": "n_3946fb80f1841793", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_ccaae56de4428500": { "inputs": { "endpoint": { "kind": "value", "value": "/channels" }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_120e2241c726e5cd", "output": "createBody" } ] } }, "name": "Create the public channel", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "endpoint" }, { "jsonSchema": {}, "nullable": true, "handle": "body" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" }, { "jsonSchema": { "const": "base64" }, "nullable": true, "handle": "bodyEncoding" } ], "name": "Create the public channel", "executor": { "providerId": "mattermost", "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "kind": "connector-proxy" } } }, "n_7ab1bc1f0d3fa095": { "inputs": { "statusCode": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ccaae56de4428500", "output": "statusCode" } ] }, "channel": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ccaae56de4428500", "output": "body" } ] }, "createBody": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_120e2241c726e5cd", "output": "createBody" } ] }, "userId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_120e2241c726e5cd", "output": "userId" } ] }, "message": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_120e2241c726e5cd", "output": "message" } ] } }, "name": "Confirm the new channel", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": {}, "nullable": true, "handle": "channel" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "createBody" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "userId" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "message" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "channel" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "channelId" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "memberEndpoint" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "memberBody" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "message" } ], "name": "Confirm the new channel", "moduleId": "n_fdab896882491641", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_0905ed0aa3958eb7": { "inputs": { "endpoint": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7ab1bc1f0d3fa095", "output": "memberEndpoint" } ] }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7ab1bc1f0d3fa095", "output": "memberBody" } ] } }, "name": "Add the chosen member", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "endpoint" }, { "jsonSchema": {}, "nullable": true, "handle": "body" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" }, { "jsonSchema": { "const": "base64" }, "nullable": true, "handle": "bodyEncoding" } ], "name": "Add the chosen member", "executor": { "providerId": "mattermost", "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "kind": "connector-proxy" } } }, "n_ec8648164893e69d": { "inputs": { "statusCode": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_0905ed0aa3958eb7", "output": "statusCode" } ] }, "membership": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_0905ed0aa3958eb7", "output": "body" } ] }, "channel": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7ab1bc1f0d3fa095", "output": "channel" } ] }, "userId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_120e2241c726e5cd", "output": "userId" } ] }, "message": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7ab1bc1f0d3fa095", "output": "message" } ] } }, "name": "Confirm channel membership", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": {}, "nullable": true, "handle": "membership" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "channel" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "userId" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "message" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "channel" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "membership" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "channelId" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "message" } ], "name": "Confirm channel membership", "moduleId": "n_060e701f59487807", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_068061c9b3a9f655": { "inputs": { "channelId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ec8648164893e69d", "output": "channelId" } ] }, "message": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ec8648164893e69d", "output": "message" } ] }, "props": { "kind": "value", "value": { "attachments": [] } } }, "name": "Post the welcome message", "kind": "task", "task": { "inputs": [ { "description": "A Mattermost object ID.", "jsonSchema": { "type": "string", "minLength": 1, "description": "A Mattermost object ID." }, "nullable": false, "handle": "channelId" }, { "description": "The Markdown message body to post.", "jsonSchema": { "type": "string", "minLength": 1, "description": "The Markdown message body to post." }, "nullable": false, "handle": "message" }, { "description": "Optional root post ID for replying in a thread.", "jsonSchema": { "type": "string", "minLength": 1, "description": "Optional root post ID for replying in a thread." }, "nullable": true, "handle": "rootId", "value": null }, { "description": "Optional Mattermost post props object.", "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "Optional Mattermost post props object." }, "nullable": true, "handle": "props", "value": null } ], "outputs": [ { "description": "A Mattermost post object.", "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "A Mattermost post object." }, "nullable": false, "handle": "post" }, { "description": "The raw Mattermost API JSON response.", "jsonSchema": { "description": "The raw Mattermost API JSON response." }, "nullable": false, "handle": "raw" } ], "name": "Post the welcome message", "executor": { "kind": "connector", "action": "mattermost.create_post" } } }, "n_9c91a42c195515c6": { "inputs": { "post": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_068061c9b3a9f655", "output": "post" } ] }, "rawPost": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_068061c9b3a9f655", "output": "raw" } ] }, "channel": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ec8648164893e69d", "output": "channel" } ] }, "membership": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ec8648164893e69d", "output": "membership" } ] }, "message": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ec8648164893e69d", "output": "message" } ] } }, "name": "Keep the complete API results", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "A Mattermost post object." }, "nullable": false, "handle": "post" }, { "jsonSchema": { "description": "The raw Mattermost API JSON response." }, "nullable": false, "handle": "rawPost" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "channel" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "membership" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "message" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "channel" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "membership" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "post" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": true, "handle": "rawPost" } ], "name": "Keep the complete API results", "moduleId": "n_4c635c4fc181023d", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_9aa2a246cd48c91b": { "name": "Channel, member and welcome post", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "channel" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "membership" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "post" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": true, "handle": "rawPost" } ], "outputMappings": { "channel": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9c91a42c195515c6", "output": "channel" } ] }, "membership": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9c91a42c195515c6", "output": "membership" } ] }, "post": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9c91a42c195515c6", "output": "post" } ] }, "rawPost": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9c91a42c195515c6", "output": "rawPost" } ] } } } }, "edges": [ { "source": "n_c6c7721c61aaa958", "target": "n_120e2241c726e5cd" }, { "source": "n_120e2241c726e5cd", "target": "n_ccaae56de4428500" }, { "source": "n_ccaae56de4428500", "target": "n_7ab1bc1f0d3fa095" }, { "source": "n_7ab1bc1f0d3fa095", "target": "n_0905ed0aa3958eb7" }, { "source": "n_0905ed0aa3958eb7", "target": "n_ec8648164893e69d" }, { "source": "n_ec8648164893e69d", "target": "n_068061c9b3a9f655" }, { "source": "n_068061c9b3a9f655", "target": "n_9c91a42c195515c6" }, { "source": "n_9c91a42c195515c6", "target": "n_9aa2a246cd48c91b" } ] } }, "modules": { "n_3946fb80f1841793": { "name": "Choose team, user and channel", "imports": [], "source": "export default function mattermostChannelPlan(input) {\n const text = (value, label) => { if (typeof value !== 'string' || !value.trim() || value.trim().startsWith('YOUR_')) throw new Error('Set ' + label); return value.trim(); };\n const id = (value, label) => { const result = text(value, label); if (!/^[a-z0-9]{26}$/.test(result)) throw new Error(label + ' must be a 26-character Mattermost ID'); return result; };\n const teamId = id(input.teamId, 'teamId'), userId = id(input.userId, 'userId'), channelName = text(input.channelName, 'channelName'), displayName = text(input.displayName, 'displayName'), message = text(input.message, 'message');\n return { createBody: { team_id: teamId, name: channelName, display_name: displayName, type: 'O' }, userId, message };\n}\n" }, "n_fdab896882491641": { "name": "Confirm the new channel", "imports": [], "source": "export default function mattermostChannelReceipt(input) {\n const succeeded = input.httpSucceeded === true || (Number.isInteger(input.statusCode) && input.statusCode >= 200 && input.statusCode < 300);\n if (!succeeded || !input.channel || typeof input.channel !== 'object' || Array.isArray(input.channel)) throw new Error('Channel creation was not confirmed. It may already have created a channel; inspect Mattermost before replaying.');\n const channel = input.channel, expected = input.createBody;\n if (typeof channel.id !== 'string' || !/^[a-z0-9]{26}$/.test(channel.id) || channel.team_id !== expected.team_id || channel.name !== expected.name || channel.display_name !== expected.display_name || channel.type !== 'O') throw new Error('Unexpected created channel. It may already exist; inspect Mattermost before replaying.');\n return { channel, channelId: channel.id, memberEndpoint: '/channels/' + encodeURIComponent(channel.id) + '/members', memberBody: { user_id: input.userId }, message: input.message };\n}\n" }, "n_060e701f59487807": { "name": "Confirm channel membership", "imports": [], "source": "export default function mattermostMemberReceipt(input) {\n const membership = input.membership;\n const succeeded = input.httpSucceeded === true || (Number.isInteger(input.statusCode) && input.statusCode >= 200 && input.statusCode < 300);\n if (!succeeded || !membership || typeof membership !== 'object' || Array.isArray(membership) || membership.channel_id !== input.channel.id || membership.user_id !== input.userId) throw new Error('Channel membership was not confirmed. The channel/member may already have changed; inspect Mattermost before replaying.');\n return { channel: input.channel, membership, channelId: input.channel.id, message: input.message };\n}\n" }, "n_4c635c4fc181023d": { "name": "Keep the complete API results", "imports": [], "source": "export default function mattermostOnboardingResult(input) {\n const post = input.post;\n if (!post || typeof post !== 'object' || Array.isArray(post) || typeof post.id !== 'string' || !/^[a-z0-9]{26}$/.test(post.id) || post.channel_id !== input.channel.id || post.message !== input.message) throw new Error('Welcome post was not confirmed. The channel, membership and post may already exist; inspect Mattermost before replaying.');\n return { channel: input.channel, membership: input.membership, post, rawPost: input.rawPost };\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }