{ "kind": "open-flow-workflow", "version": 1, "name": "Telegram Documents to Google Drive", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_b966cb593b6c07d6": { "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_963b0b32c5805ed0": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_b966cb593b6c07d6", "output": "body" } ] } }, "name": "Check for a document", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object" }, "nullable": false, "handle": "body" } ], "outputs": [ { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "hasDocument" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" } ], "name": "Check for a document", "moduleId": "n_1616fe5b2fb4b68d", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_cc78d0ebbfd6d838": { "inputs": {}, "name": "Message has no document", "kind": "condition", "matchMode": "first", "cases": [ { "output": "skip", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_963b0b32c5805ed0", "output": "hasDocument" } }, "operator": "==", "right": { "kind": "value", "value": false } } ] } ] } ] }, "n_2df69b83bd9531d8": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_963b0b32c5805ed0", "output": "body" } ] }, "folderId": { "kind": "value", "value": "YOUR_GOOGLE_DRIVE_FOLDER_ID" } }, "name": "Choose the destination folder", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "folderId" } ], "outputs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "fileId" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "fileRequest" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "fileName" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "mimeType" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "folderId" } ], "name": "Choose the destination folder", "moduleId": "n_7b458ae7927fbbf3", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_fea32dc9248085ca": { "inputs": {}, "name": "Identify the connected bot", "kind": "task", "task": { "inputs": [], "outputs": [ { "description": "The unique identifier of the user or bot.", "jsonSchema": { "type": "integer", "description": "The unique identifier of the user or bot." }, "nullable": false, "handle": "id" }, { "description": "Whether this account is a bot.", "jsonSchema": { "type": "boolean", "description": "Whether this account is a bot." }, "nullable": false, "handle": "isBot" }, { "description": "The first name of the user or bot.", "jsonSchema": { "type": "string", "description": "The first name of the user or bot." }, "nullable": false, "handle": "firstName" }, { "description": "The username of the user or bot.", "jsonSchema": { "type": "string", "description": "The username of the user or bot." }, "nullable": true, "handle": "username" }, { "description": "The IETF language tag of the user.", "jsonSchema": { "type": "string", "description": "The IETF language tag of the user." }, "nullable": true, "handle": "languageCode" }, { "description": "Whether the bot can be invited to groups.", "jsonSchema": { "type": "boolean", "description": "Whether the bot can be invited to groups." }, "nullable": true, "handle": "canJoinGroups" }, { "description": "Whether privacy mode is disabled for the bot.", "jsonSchema": { "type": "boolean", "description": "Whether privacy mode is disabled for the bot." }, "nullable": true, "handle": "canReadAllGroupMessages" }, { "description": "Whether the bot supports inline queries.", "jsonSchema": { "type": "boolean", "description": "Whether the bot supports inline queries." }, "nullable": true, "handle": "supportsInlineQueries" }, { "description": "Whether the bot can be connected to a Telegram Business account.", "jsonSchema": { "type": "boolean", "description": "Whether the bot can be connected to a Telegram Business account." }, "nullable": true, "handle": "canConnectToBusiness" }, { "description": "Whether the bot has a main Web App configured.", "jsonSchema": { "type": "boolean", "description": "Whether the bot has a main Web App configured." }, "nullable": true, "handle": "hasMainWebApp" } ], "name": "Identify the connected bot", "executor": { "kind": "connector", "action": "telegram.get_me" } } }, "n_6afcb65a6ead1231": { "inputs": { "botToken": { "kind": "unset" }, "providerBotId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_fea32dc9248085ca", "output": "id" } ] }, "providerIsBot": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_fea32dc9248085ca", "output": "isBot" } ] } }, "name": "Verify the download token", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "botToken" }, { "jsonSchema": { "type": "integer", "description": "The unique identifier of the user or bot." }, "nullable": false, "handle": "providerBotId" }, { "jsonSchema": { "type": "boolean", "description": "Whether this account is a bot." }, "nullable": false, "handle": "providerIsBot" } ], "outputs": [ { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "verified" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "botId" } ], "name": "Verify the download token", "moduleId": "n_89f74f8bca21daed", "capabilities": [ { "kind": "http", "hosts": [ "api.telegram.org" ] } ] } }, "n_18c8d3bfe779ce22": { "inputs": { "endpoint": { "kind": "value", "value": "/getFile" }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_2df69b83bd9531d8", "output": "fileRequest" } ] } }, "name": "Get the document path", "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": "Get the document path", "executor": { "providerId": "telegram", "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "kind": "connector-proxy" } } }, "n_efe38ad72eaece95": { "inputs": { "botToken": { "kind": "unset" }, "verified": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_6afcb65a6ead1231", "output": "verified" } ] }, "reply": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_18c8d3bfe779ce22", "output": "body" } ] }, "statusCode": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_18c8d3bfe779ce22", "output": "statusCode" } ] }, "fileId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_2df69b83bd9531d8", "output": "fileId" } ] }, "fileName": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_2df69b83bd9531d8", "output": "fileName" } ] }, "mimeType": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_2df69b83bd9531d8", "output": "mimeType" } ] }, "folderId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_2df69b83bd9531d8", "output": "folderId" } ] } }, "name": "Download the complete document", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "botToken" }, { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "verified" }, { "jsonSchema": {}, "nullable": true, "handle": "reply" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "fileId" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "fileName" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "mimeType" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "folderId" } ], "outputs": [ { "jsonSchema": { "type": "string", "minLength": 1, "description": "The name of the file." }, "nullable": true, "handle": "name" }, { "jsonSchema": { "type": "string", "minLength": 1, "description": "The MIME type of the file." }, "nullable": true, "handle": "mimeType" }, { "jsonSchema": { "type": "array", "items": { "type": "string", "minLength": 1, "description": "Schema for nonEmptyString." }, "minItems": 1, "description": "A list of parent folder IDs to place the file in." }, "nullable": true, "handle": "parents" }, { "jsonSchema": { "type": "string", "minLength": 1, "description": "Connector media upload content encoded as a Base64 string." }, "nullable": true, "handle": "contentBase64" }, { "jsonSchema": { "type": "integer", "minimum": 0 }, "nullable": false, "handle": "size" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "fileId" } ], "name": "Download the complete document", "moduleId": "n_eaf2d5f122c2b2e6", "capabilities": [ { "kind": "http", "hosts": [ "api.telegram.org" ] } ] } }, "n_c755c80ba2ac154e": { "inputs": { "name": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_efe38ad72eaece95", "output": "name" } ] }, "mimeType": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_efe38ad72eaece95", "output": "mimeType" } ] }, "parents": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_efe38ad72eaece95", "output": "parents" } ] }, "contentBase64": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_efe38ad72eaece95", "output": "contentBase64" } ] } }, "name": "Upload the document to Drive", "kind": "task", "task": { "inputs": [ { "description": "The name of the file.", "jsonSchema": { "type": "string", "minLength": 1, "description": "The name of the file." }, "nullable": true, "handle": "name", "value": null }, { "description": "The MIME type of the file.", "jsonSchema": { "type": "string", "minLength": 1, "description": "The MIME type of the file." }, "nullable": true, "handle": "mimeType", "value": null }, { "description": "A short description of the file.", "jsonSchema": { "type": "string", "minLength": 1, "description": "A short description of the file." }, "nullable": true, "handle": "description", "value": null }, { "description": "A list of parent folder IDs to place the file in.", "jsonSchema": { "type": "array", "items": { "type": "string", "minLength": 1, "description": "Schema for nonEmptyString." }, "minItems": 1, "description": "A list of parent folder IDs to place the file in." }, "nullable": true, "handle": "parents", "value": null }, { "description": "Whether the user has starred the file.", "jsonSchema": { "type": "boolean", "description": "Whether the user has starred the file." }, "nullable": true, "handle": "starred", "value": null }, { "description": "A collection of arbitrary key-value pairs which are private to the requesting app.", "jsonSchema": { "type": "object", "additionalProperties": { "type": "string", "description": "A record value." }, "description": "A collection of arbitrary key-value pairs which are private to the requesting app." }, "nullable": true, "handle": "appProperties", "value": null }, { "description": "A collection of arbitrary key-value pairs which are visible to all apps.", "jsonSchema": { "type": "object", "additionalProperties": { "type": "string", "description": "A record value." }, "description": "A collection of arbitrary key-value pairs which are visible to all apps." }, "nullable": true, "handle": "properties", "value": null }, { "description": "Connector media upload content encoded as a Base64 string.", "jsonSchema": { "type": "string", "minLength": 1, "description": "Connector media upload content encoded as a Base64 string." }, "nullable": true, "handle": "contentBase64", "value": null }, { "description": "Connector text media upload content.", "jsonSchema": { "type": "string", "description": "Connector text media upload content." }, "nullable": true, "handle": "text", "value": null } ], "outputs": [ { "description": "The unique identifier of the file.", "jsonSchema": { "type": "string", "description": "The unique identifier of the file." }, "nullable": false, "handle": "id" }, { "description": "The name of the file.", "jsonSchema": { "type": "string", "description": "The name of the file." }, "nullable": false, "handle": "name" }, { "description": "The MIME type of the file.", "jsonSchema": { "type": "string", "description": "The MIME type of the file." }, "nullable": false, "handle": "mimeType" }, { "description": "A link for opening the file in a relevant Google editor or viewer in a browser.", "jsonSchema": { "type": [ "string", "null" ], "description": "A link for opening the file in a relevant Google editor or viewer in a browser." }, "nullable": true, "handle": "webViewLink" }, { "description": "The time at which the file was created (RFC 3339 date-time).", "jsonSchema": { "type": [ "string", "null" ], "description": "The time at which the file was created (RFC 3339 date-time)." }, "nullable": true, "handle": "createdTime" }, { "description": "The last time the file was modified by anyone (RFC 3339 date-time).", "jsonSchema": { "type": [ "string", "null" ], "description": "The last time the file was modified by anyone (RFC 3339 date-time)." }, "nullable": true, "handle": "modifiedTime" }, { "description": "The size of the file's content in bytes.", "jsonSchema": { "type": [ "integer", "null" ], "description": "The size of the file's content in bytes." }, "nullable": true, "handle": "sizeBytes" }, { "description": "The ID of the shared drive the file belongs to.", "jsonSchema": { "type": [ "string", "null" ], "description": "The ID of the shared drive the file belongs to." }, "nullable": true, "handle": "driveId" }, { "description": "The IDs of the parent folders containing the file.", "jsonSchema": { "type": "array", "items": { "type": "string", "description": "An array item." }, "description": "The IDs of the parent folders containing the file." }, "nullable": true, "handle": "parents" }, { "description": "The owners of the file.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "displayName": { "type": [ "string", "null" ], "description": "The display name of the owner." }, "emailAddress": { "type": [ "string", "null" ], "description": "The email address of the owner." }, "permissionId": { "type": [ "string", "null" ], "description": "The permission ID of the owner." }, "photoLink": { "type": [ "string", "null" ], "description": "A link to the owner's profile photo." } }, "required": [ "displayName", "emailAddress", "permissionId", "photoLink" ], "additionalProperties": false, "description": "Schema for driveOwnerSchema." }, "description": "The owners of the file." }, "nullable": true, "handle": "owners" }, { "description": "Whether the file has been shared.", "jsonSchema": { "type": "boolean", "description": "Whether the file has been shared." }, "nullable": true, "handle": "shared" }, { "description": "Whether the user has starred the file.", "jsonSchema": { "type": "boolean", "description": "Whether the user has starred the file." }, "nullable": true, "handle": "starred" }, { "description": "Whether the file has been trashed.", "jsonSchema": { "type": "boolean", "description": "Whether the file has been trashed." }, "nullable": true, "handle": "trashed" }, { "description": "Whether the authenticated user owns the file.", "jsonSchema": { "type": "boolean", "description": "Whether the authenticated user owns the file." }, "nullable": true, "handle": "ownedByMe" }, { "description": "The projected Drive capabilities for the authenticated user.", "jsonSchema": { "type": "object", "properties": { "canShare": { "type": "boolean", "description": "Whether the authenticated user may modify sharing settings." } }, "required": [ "canShare" ], "additionalProperties": false, "description": "The projected Drive capabilities for the authenticated user." }, "nullable": true, "handle": "capabilities" } ], "name": "Upload the document to Drive", "executor": { "kind": "connector", "action": "googledrive.files.create" } } }, "n_22556233ac9c3c4f": { "inputs": { "id": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c755c80ba2ac154e", "output": "id" } ] }, "name": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c755c80ba2ac154e", "output": "name" } ] }, "mimeType": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c755c80ba2ac154e", "output": "mimeType" } ] }, "parents": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c755c80ba2ac154e", "output": "parents" } ] }, "sizeBytes": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c755c80ba2ac154e", "output": "sizeBytes" } ] }, "expectedName": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_efe38ad72eaece95", "output": "name" } ] }, "folderId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_2df69b83bd9531d8", "output": "folderId" } ] }, "fileId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_efe38ad72eaece95", "output": "fileId" } ] }, "bytes": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_efe38ad72eaece95", "output": "size" } ] } }, "name": "Confirm the uploaded file", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string", "description": "The unique identifier of the file." }, "nullable": false, "handle": "id" }, { "jsonSchema": { "type": "string", "description": "The name of the file." }, "nullable": false, "handle": "name" }, { "jsonSchema": { "type": "string", "description": "The MIME type of the file." }, "nullable": false, "handle": "mimeType" }, { "jsonSchema": { "type": "array", "items": { "type": "string", "description": "An array item." }, "description": "The IDs of the parent folders containing the file." }, "nullable": true, "handle": "parents" }, { "jsonSchema": { "type": [ "integer", "null" ], "description": "The size of the file's content in bytes." }, "nullable": true, "handle": "sizeBytes" }, { "jsonSchema": { "type": "string", "minLength": 1, "description": "The name of the file." }, "nullable": true, "handle": "expectedName" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "folderId" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "fileId" }, { "jsonSchema": { "type": "integer", "minimum": 0 }, "nullable": false, "handle": "bytes" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "result" } ], "name": "Confirm the uploaded file", "moduleId": "n_03fa6b11609d1528", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_9239d39dadb852ca": { "inputs": {}, "name": "Skip a message without a document", "kind": "task", "task": { "inputs": [], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "result" } ], "name": "Skip a message without a document", "moduleId": "n_e3c10407e07f4557", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_dcc7b32a89d591d0": { "name": "Document upload result", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "result" } ], "outputMappings": { "result": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_22556233ac9c3c4f", "output": "result" }, { "kind": "node", "nodeId": "n_9239d39dadb852ca", "output": "result" } ] } } } }, "edges": [ { "source": "n_b966cb593b6c07d6", "target": "n_963b0b32c5805ed0" }, { "source": "n_963b0b32c5805ed0", "target": "n_cc78d0ebbfd6d838" }, { "source": "n_cc78d0ebbfd6d838", "target": "n_2df69b83bd9531d8", "sourceHandle": "otherwise" }, { "source": "n_2df69b83bd9531d8", "target": "n_fea32dc9248085ca" }, { "source": "n_fea32dc9248085ca", "target": "n_6afcb65a6ead1231" }, { "source": "n_6afcb65a6ead1231", "target": "n_18c8d3bfe779ce22" }, { "source": "n_18c8d3bfe779ce22", "target": "n_efe38ad72eaece95" }, { "source": "n_efe38ad72eaece95", "target": "n_c755c80ba2ac154e" }, { "source": "n_c755c80ba2ac154e", "target": "n_22556233ac9c3c4f" }, { "source": "n_22556233ac9c3c4f", "target": "n_dcc7b32a89d591d0" }, { "source": "n_cc78d0ebbfd6d838", "target": "n_9239d39dadb852ca", "sourceHandle": "skip" }, { "source": "n_9239d39dadb852ca", "target": "n_dcc7b32a89d591d0" } ] } }, "modules": { "n_1616fe5b2fb4b68d": { "name": "Check for a document", "imports": [], "source": "export default function selectTelegramDocument({body}) {\n if(!body||typeof body!=='object'||Array.isArray(body)||!body.message||typeof body.message!=='object')throw new Error('A Telegram message event is required.');\n const document=body.message.document;\n return {hasDocument:!!document&&typeof document==='object'&&!Array.isArray(document),body};\n}\n" }, "n_7b458ae7927fbbf3": { "name": "Choose the destination folder", "imports": [], "source": "export default function prepareTelegramDocument({body,folderId}) {\n const doc=body.message.document;\n if(!doc||typeof doc.file_id!=='string'||!doc.file_id)throw new Error('A Telegram document file ID is required.');\n if(typeof folderId!=='string'||!folderId.trim()||folderId.startsWith('YOUR_'))throw new Error('Set the Google Drive folder ID.');\n return {fileId:doc.file_id,fileRequest:{file_id:doc.file_id},fileName:typeof doc.file_name==='string'?doc.file_name:'',mimeType:typeof doc.mime_type==='string'&&doc.mime_type?doc.mime_type:'application/octet-stream',folderId};\n}\n" }, "n_89f74f8bca21daed": { "name": "Verify the download token", "imports": [], "source": "export default async function verifyTelegramAudioBot({botToken,providerBotId,providerIsBot},context) {\n if(typeof botToken!=='string'||!/^\\d+:[A-Za-z0-9_-]+$/.test(botToken))throw new Error('Select the Telegram audio Bot Token Variable.');\n if(!Number.isSafeInteger(providerBotId)||providerIsBot!==true)throw new Error('The Telegram connection did not identify a bot.');\n try {\n const response=await context.fetch('https://api.telegram.org/bot'+botToken+'/getMe',{method:'GET'});\n if(!response.ok)throw new Error('Unconfirmed identity.');\n const reply=await response.json();\n if(reply?.ok!==true||reply.result?.is_bot!==true||reply.result.id!==providerBotId)throw new Error('Unmatched bot.');\n return {verified:true,botId:providerBotId};\n } catch {throw new Error('The audio Bot Token must identify the same bot as the selected Telegram connection.');}\n}\n" }, "n_eaf2d5f122c2b2e6": { "name": "Download the complete document", "imports": [], "source": "import {Buffer} from 'node:buffer';\nexport default async function downloadTelegramDocument({botToken,verified,reply,statusCode,fileId,fileName,mimeType,folderId},context) {\n if(verified!==true||typeof botToken!=='string'||!/^\\d+:[A-Za-z0-9_-]+$/.test(botToken))throw new Error('Verify the Telegram bot token before downloading.');\n const file=reply?.result,path=file?.file_path;\n if(statusCode!==200||reply?.ok!==true||file?.file_id!==fileId||typeof path!=='string'||!path||path.startsWith('/')||path.split('/').some(x=>!x||x==='.'||x==='..')||/[?#\\\\\\x00-\\x20]/.test(path))throw new Error('Telegram did not confirm a valid downloadable document.');\n const name=fileName||path.split('/').at(-1);if(!name)throw new Error('Telegram did not provide a document name.');\n try{const response=await context.fetch('https://api.telegram.org/file/bot'+botToken+'/'+path.split('/').map(encodeURIComponent).join('/'),{method:'GET'});if(!response.ok)throw new Error('Download failed.');const bytes=new Uint8Array(await response.arrayBuffer());if(typeof file.file_size==='number'&&(!Number.isSafeInteger(file.file_size)||file.file_size<0||file.file_size!==bytes.length))throw new Error('Document size mismatch.');return {name,mimeType,parents:[folderId],contentBase64:bytes.length?Buffer.from(bytes).toString('base64'):null,size:bytes.length,fileId};}catch{throw new Error('Telegram document download failed; no partial content was uploaded.');}\n}\n" }, "n_03fa6b11609d1528": { "name": "Confirm the uploaded file", "imports": [], "source": "export default function confirmTelegramDriveFile({id,name,mimeType,parents,sizeBytes,expectedName,folderId,fileId,bytes}) {\n if(typeof id!=='string'||!id||name!==expectedName||!Array.isArray(parents)||!parents.includes(folderId))throw new Error('Drive did not confirm the created file; it may already exist, inspect Drive before replaying.');\n if(sizeBytes!==null&&sizeBytes!==bytes)throw new Error('Drive returned an unexpected file size; inspect Drive before replaying.');\n return {result:{status:\"uploaded\",file:{id,name,mimeType,parents,sizeBytes},sourceFileId:fileId,bytes}};\n}\n" }, "n_e3c10407e07f4557": { "name": "Skip a message without a document", "imports": [], "source": "export default function(){return {result:{status:\"skipped\"}};}" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }