{ "kind": "open-flow-workflow", "version": 1, "name": "Suggest Inclusive Language in Mattermost", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_bfb99cc2df68be36": { "name": "Receive a Mattermost message", "kind": "webhook", "bodyFields": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "token" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "channel_id" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "text" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "team_id" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "team_domain" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "channel_name" }, { "jsonSchema": { "type": "integer" }, "nullable": true, "handle": "timestamp" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "user_id" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "user_name" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "post_id" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "trigger_word" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "file_ids" } ], "method": "POST", "options": { "responseData": "{}", "responseHeaders": { "Content-Type": "application/json" }, "responseStatusCode": 200 } }, "n_bbab813499727fef": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_bfb99cc2df68be36", "output": "body" } ] }, "token": { "kind": "unset" } }, "name": "Check the message", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "token" } ], "outputs": [ { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "match" }, { "jsonSchema": { "type": "string", "minLength": 1, "description": "A Mattermost object ID." }, "nullable": false, "handle": "channelId" } ], "name": "Check the message", "moduleId": "n_76de0dca7665abc2", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_a21b9dd41b5fd881": { "inputs": {}, "name": "A selected term is present", "kind": "condition", "matchMode": "first", "cases": [ { "output": "yes", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_bbab813499727fef", "output": "match" } }, "operator": "==", "right": { "kind": "value", "value": true } } ] } ] } ] }, "n_b662aa377eea5eb0": { "inputs": { "channelId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_bbab813499727fef", "output": "channelId" } ] }, "message": { "kind": "value", "value": "May I suggest \"folks\" or โ€œy'allโ€? We use gender inclusive language here. ๐Ÿ˜„" } }, "name": "Post the suggestion", "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 suggestion", "executor": { "kind": "connector", "action": "mattermost.create_post" } } } }, "edges": [ { "source": "n_bfb99cc2df68be36", "target": "n_bbab813499727fef" }, { "source": "n_bbab813499727fef", "target": "n_a21b9dd41b5fd881" }, { "source": "n_a21b9dd41b5fd881", "target": "n_b662aa377eea5eb0", "sourceHandle": "yes" } ] } }, "modules": { "n_76de0dca7665abc2": { "name": "Check the message", "imports": [], "source": "export default function plan({body,token}) {\n if(typeof token!=='string'||!token||body?.token!==token)throw Error('Invalid Mattermost webhook token');\n if(typeof body?.channel_id!=='string'||!body.channel_id||typeof body?.text!=='string')throw Error('Invalid Mattermost event');\n const match=['guys','Guys','bros','Bros','dudes','Dudes','gals','Gals'].some(word=>body.text.includes(word));\n return {match,channelId:body.channel_id};\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }