{ "kind": "open-flow-workflow", "version": 1, "name": "Random Cocktail to Mattermost", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_7d0a6271152f8619": { "name": "Receive the channel request", "kind": "webhook", "bodyFields": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "channel_id" } ], "method": "POST", "options": {} }, "n_551c8ec9e98b2d25": { "inputs": { "url": { "kind": "value", "value": "https://www.thecocktaildb.com/api/json/v1/1/random.php" } }, "name": "Fetch a random cocktail", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Fetch a random cocktail", "executor": { "method": "GET", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "none", "authentication": { "type": "none" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_5fd26be53b3f0763": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_551c8ec9e98b2d25", "output": "body" } ] }, "request": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7d0a6271152f8619", "output": "body" } ] } }, "name": "Prepare cocktail message", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "request" } ], "outputs": [ { "jsonSchema": { "type": "string", "minLength": 1, "description": "A Mattermost object ID." }, "nullable": false, "handle": "channelId" }, { "jsonSchema": { "type": "string", "minLength": 1, "description": "The Markdown message body to post." }, "nullable": false, "handle": "message" }, { "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "Optional Mattermost post props object." }, "nullable": true, "handle": "props" } ], "name": "Prepare cocktail message", "moduleId": "n_7304d1e05926d882", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_401513244ac31b5e": { "inputs": { "channelId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_5fd26be53b3f0763", "output": "channelId" } ] }, "message": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_5fd26be53b3f0763", "output": "message" } ] }, "props": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_5fd26be53b3f0763", "output": "props" } ] } }, "name": "Post the cocktail", "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 cocktail", "executor": { "kind": "connector", "action": "mattermost.create_post" } } } }, "edges": [ { "source": "n_7d0a6271152f8619", "target": "n_551c8ec9e98b2d25" }, { "source": "n_551c8ec9e98b2d25", "target": "n_5fd26be53b3f0763" }, { "source": "n_5fd26be53b3f0763", "target": "n_401513244ac31b5e" } ] } }, "modules": { "n_7304d1e05926d882": { "name": "Prepare cocktail message", "imports": [], "source": "export default function cocktailNotice({body,request}){\n const d=body?.drinks?.[0],id=request?.channel_id;\n if(typeof id!=='string'||!id.trim())throw Error('Webhook needs channel_id');\n if(!d||[d.strDrink,d.strInstructions,d.strGlass,d.strDrinkThumb].some(x=>typeof x!=='string'||!x))throw Error('Cocktail response lacks required fields');\n return{channelId:id,message:`Why not try ${d.strDrink}?\\n${d.strInstructions} Serve in ${d.strGlass}.`,props:{attachments:[{image_url:d.strDrinkThumb}]}};\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }