{ "kind": "open-flow-workflow", "version": 1, "name": "Telegram Command to GitHub Release", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_ccbf6f18ca1946b0": { "name": "Receive a Telegram message", "kind": "integration", "config": { "updates": { "kind": "value", "value": [ "message" ] }, "chatIds": { "kind": "value", "value": [] }, "userIds": { "kind": "value", "value": [] }, "dropPendingUpdates": { "kind": "value", "value": false } }, "definition": { "configInputs": [ { "description": "Only accept updates from these numeric Telegram chat IDs. Empty means every chat.", "jsonSchema": { "type": "array", "items": { "type": "string", "pattern": "^-?[0-9]{1,20}$" }, "maxItems": 100, "uniqueItems": true }, "nullable": false, "handle": "chatIds", "value": [] }, { "description": "Discard updates queued before the webhook is created or resumed.", "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "dropPendingUpdates", "value": true }, { "description": "Telegram update types that trigger a Run. Use * for the Telegram default set.", "jsonSchema": { "type": "array", "items": { "enum": [ "*", "message", "edited_message", "channel_post", "edited_channel_post", "business_connection", "business_message", "edited_business_message", "deleted_business_messages", "guest_message", "message_reaction", "message_reaction_count", "inline_query", "chosen_inline_result", "callback_query", "shipping_query", "pre_checkout_query", "purchased_paid_media", "poll", "poll_answer", "my_chat_member", "chat_member", "chat_join_request", "chat_boost", "removed_chat_boost", "managed_bot", "subscription" ] }, "minItems": 1, "uniqueItems": true }, "nullable": false, "handle": "updates" }, { "description": "Only accept updates from these numeric Telegram user IDs. Empty means every user.", "jsonSchema": { "type": "array", "items": { "type": "string", "pattern": "^[0-9]{1,20}$" }, "maxItems": 100, "uniqueItems": true }, "nullable": false, "handle": "userIds", "value": [] } ], "definitionVersion": 2, "description": "Triggers when the connected Telegram bot receives a selected update.", "displayName": "Bot Update", "key": "telegram.on_update", "name": "on_update", "outputs": [ { "jsonSchema": { "type": "object" }, "nullable": false, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "deliveryId" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "event" } ], "provider": "telegram", "type": "integration", "endpoint": { "body": { "allowArray": false, "allowEmpty": false, "formats": [ "json" ] }, "methods": [ "POST" ], "successStatus": 200 } } }, "n_2043c1c9388bf0de": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ccbf6f18ca1946b0", "output": "body" } ] }, "allowedChatId": { "kind": "value", "value": "YOUR_TELEGRAM_CHAT_ID" }, "allowedUserId": { "kind": "value", "value": "YOUR_TELEGRAM_USER_ID" } }, "name": "Check the authorized command", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object" }, "nullable": false, "handle": "body" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "allowedChatId" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "allowedUserId" } ], "outputs": [ { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "run" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "tag" } ], "name": "Check the authorized command", "moduleId": "n_47ac76692947d936", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_eef7c5d6d1409451": { "inputs": {}, "name": "Create a release", "kind": "condition", "matchMode": "first", "cases": [ { "output": "publish", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_2043c1c9388bf0de", "output": "run" } }, "operator": "==", "right": { "kind": "value", "value": true } } ] } ] } ] }, "n_cdecb4dd04f53db1": { "inputs": { "owner": { "kind": "value", "value": "YOUR_GITHUB_OWNER" }, "repo": { "kind": "value", "value": "YOUR_GITHUB_REPOSITORY" }, "tagName": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_2043c1c9388bf0de", "output": "tag" } ] } }, "name": "Publish the GitHub release", "kind": "task", "task": { "inputs": [ { "description": "The repository owner.", "jsonSchema": { "type": "string", "minLength": 1, "description": "The repository owner." }, "nullable": false, "handle": "owner" }, { "description": "The repository name.", "jsonSchema": { "type": "string", "minLength": 1, "description": "The repository name." }, "nullable": false, "handle": "repo" }, { "description": "The tag name for the release.", "jsonSchema": { "type": "string", "minLength": 1, "description": "The tag name for the release." }, "nullable": false, "handle": "tagName" }, { "description": "The branch or commit SHA to tag.", "jsonSchema": { "type": "string", "description": "The branch or commit SHA to tag." }, "nullable": true, "handle": "targetCommitish", "value": null }, { "description": "The release title.", "jsonSchema": { "type": "string", "description": "The release title." }, "nullable": true, "handle": "name", "value": null }, { "description": "The release body.", "jsonSchema": { "type": "string", "description": "The release body." }, "nullable": true, "handle": "body", "value": null }, { "description": "Whether to create a draft release.", "jsonSchema": { "type": "boolean", "description": "Whether to create a draft release." }, "nullable": true, "handle": "draft", "value": null }, { "description": "Whether to mark the release as prerelease.", "jsonSchema": { "type": "boolean", "description": "Whether to mark the release as prerelease." }, "nullable": true, "handle": "prerelease", "value": null }, { "description": "Whether GitHub should generate release notes.", "jsonSchema": { "type": "boolean", "description": "Whether GitHub should generate release notes." }, "nullable": true, "handle": "generateReleaseNotes", "value": null }, { "description": "Whether this release should be marked latest.", "jsonSchema": { "type": "string", "enum": [ "true", "false", "legacy" ], "description": "Whether this release should be marked latest." }, "nullable": true, "handle": "makeLatest", "value": null } ], "outputs": [ { "description": "The created GitHub release response.", "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "The created GitHub release response." }, "nullable": false, "handle": "output" } ], "name": "Publish the GitHub release", "executor": { "kind": "connector", "action": "github.create_release", "outputMode": "value" } } }, "n_f04d129c53d2df4b": { "inputs": {}, "name": "Skip other messages", "kind": "task", "task": { "inputs": [], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "result" } ], "name": "Skip other messages", "moduleId": "n_05ce40d1b3323048", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_90d2737427dfeb9f": { "inputs": { "release": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_cdecb4dd04f53db1", "output": "output" } ] }, "tag": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_2043c1c9388bf0de", "output": "tag" } ] } }, "name": "Confirm the published release", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "The created GitHub release response." }, "nullable": false, "handle": "release" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "tag" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "result" } ], "name": "Confirm the published release", "moduleId": "n_83d6d2bad1507034", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_82204dc99eaac451": { "name": "Release result", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "result" } ], "outputMappings": { "result": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_f04d129c53d2df4b", "output": "result" }, { "kind": "node", "nodeId": "n_90d2737427dfeb9f", "output": "result" } ] } } } }, "edges": [ { "source": "n_ccbf6f18ca1946b0", "target": "n_2043c1c9388bf0de" }, { "source": "n_2043c1c9388bf0de", "target": "n_eef7c5d6d1409451" }, { "source": "n_eef7c5d6d1409451", "target": "n_f04d129c53d2df4b", "sourceHandle": "otherwise" }, { "source": "n_eef7c5d6d1409451", "target": "n_cdecb4dd04f53db1", "sourceHandle": "publish" }, { "source": "n_cdecb4dd04f53db1", "target": "n_90d2737427dfeb9f" }, { "source": "n_90d2737427dfeb9f", "target": "n_82204dc99eaac451" }, { "source": "n_f04d129c53d2df4b", "target": "n_82204dc99eaac451" } ] } }, "modules": { "n_47ac76692947d936": { "name": "Check the authorized command", "imports": [], "source": "export default function telegramReleaseCommand({body,allowedChatId,allowedUserId}) {\n const message=body?.message,text=message?.text;if(typeof text!=='string'||!text.includes('/deploy'))return {run:false,tag:'skipped'};\n for(const [name,value] of Object.entries({allowedChatId,allowedUserId}))if(typeof value!=='string'||!/^\\-?\\d{1,20}$/.test(value))throw new Error('Configure '+name+' as a numeric Telegram ID.');\n if(!Number.isSafeInteger(message?.chat?.id)||!Number.isSafeInteger(message?.from?.id))throw new Error('The command needs its Telegram chat and sender IDs.');\n if(String(message.chat.id)!==allowedChatId||String(message.from.id)!==allowedUserId)return {run:false,tag:'skipped'};\n const tag=text.split(' ')[1];if(typeof tag!=='string'||!tag.trim())throw new Error('The deploy message needs a nonempty second space-separated field.');return {run:true,tag};\n}\n" }, "n_05ce40d1b3323048": { "name": "Skip other messages", "imports": [], "source": "export default function(){return {result:{status:\"skipped\"}};}" }, "n_83d6d2bad1507034": { "name": "Confirm the published release", "imports": [], "source": "export default function confirmTelegramRelease({release,tag}) {\n if(!release||typeof release!=='object'||!Number.isSafeInteger(release.id)||release.id<=0||release.tag_name!==tag||release.draft!==false)throw new Error('GitHub did not confirm the published release; inspect GitHub before replaying.');\n return {result:{status:'published',release}};\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }