{ "kind": "open-flow-workflow", "version": 1, "name": "Mattermost Webhook Call Invite", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_469b6dc7f3a9e382": { "name": "Receive the call request", "kind": "webhook", "bodyFields": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "channel_id" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "user_name" } ], "method": "POST", "options": {} }, "n_1b091e31f313b8ef": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_469b6dc7f3a9e382", "output": "body" } ] }, "configuredUserName": { "kind": "value", "value": "YOUR_USER_NAME" }, "roomSlug": { "kind": "value", "value": "YOUR_WHEREBY_ROOM" } }, "name": "Select the configured room", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "properties": { "channel_id": { "type": "string", "minLength": 1 }, "user_name": { "type": "string", "minLength": 1 } }, "required": [ "channel_id", "user_name" ], "additionalProperties": true }, "nullable": false, "handle": "body" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "configuredUserName" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "roomSlug" } ], "outputs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "channelId" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "props" } ], "name": "Select the configured room", "moduleId": "n_e77637846a8a88be", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_2466a4e45365fa5a": { "inputs": { "channelId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_1b091e31f313b8ef", "output": "channelId" } ] }, "message": { "kind": "value", "value": "Join me in a video call:" }, "props": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_1b091e31f313b8ef", "output": "props" } ] } }, "name": "Post the call invite", "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 call invite", "executor": { "kind": "connector", "action": "mattermost.create_post" } } } }, "edges": [ { "source": "n_469b6dc7f3a9e382", "target": "n_1b091e31f313b8ef" }, { "source": "n_1b091e31f313b8ef", "target": "n_2466a4e45365fa5a" } ] } }, "modules": { "n_e77637846a8a88be": { "name": "Select the configured room", "imports": [], "source": "export default function mattermostWebhookLink({ body, configuredUserName, roomSlug }) {\n const userName = body?.user_name;\n if (typeof userName !== 'string' || userName.length === 0) throw new Error('Webhook body.user_name is required');\n if (typeof configuredUserName !== 'string' || configuredUserName.length === 0) throw new Error('Set the configured user name');\n if (typeof roomSlug !== 'string' || !/^[A-Za-z0-9_-]+$/.test(roomSlug)) throw new Error('Set a valid Whereby room slug');\n if (userName !== configuredUserName) throw new Error('Webhook user_name does not match the configured invite');\n const url = 'https://whereby.com/' + roomSlug;\n return { url, channelId: body.channel_id, props: { attachments: [{ title: 'Join the video call', title_link: url }] } };\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }