{ "kind": "open-flow-workflow", "version": 1, "name": "Telegram Journal Replies to Google Sheets", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_ea118fb656f3f71b": { "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_a3c6c930a2705a9d": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ea118fb656f3f71b", "output": "body" } ] }, "botUsername": { "kind": "value", "value": "YOUR_BOT_USERNAME" }, "userUsername": { "kind": "value", "value": "YOUR_USERNAME" } }, "name": "Check the dated journal reply", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "botUsername" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "userUsername" } ], "outputs": [ { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "accepted" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "entry" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "date" }, { "jsonSchema": { "type": "array", "items": { "type": "array", "items": { "anyOf": [ { "type": "string", "description": "A union variant." }, { "type": "number", "description": "A union variant." }, { "type": "boolean", "description": "A union variant." }, { "const": null, "description": "A union variant." } ], "description": "The cell value schema." }, "description": "An array item." }, "description": "The data to append." }, "nullable": false, "handle": "values" } ], "name": "Check the dated journal reply", "moduleId": "n_d3077b860751b942", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_56965c98daf7ba01": { "inputs": {}, "name": "Is it the configured reply", "kind": "condition", "matchMode": "first", "cases": [ { "output": "accept", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_a3c6c930a2705a9d", "output": "accepted" } }, "operator": "==", "right": { "kind": "value", "value": true } } ] } ] } ] }, "n_8eeaae851239147c": { "inputs": { "spreadsheetId": { "kind": "value", "value": "YOUR_SPREADSHEET_ID" }, "range": { "kind": "value", "value": "Sheet1!A:B" }, "values": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_a3c6c930a2705a9d", "output": "values" } ] }, "majorDimension": { "kind": "value", "value": "ROWS" }, "valueInputOption": { "kind": "value", "value": "RAW" } }, "name": "Append the journal entry", "kind": "task", "task": { "inputs": [ { "description": "The spreadsheet ID.", "jsonSchema": { "type": "string", "minLength": 1, "description": "The spreadsheet ID." }, "nullable": true, "handle": "spreadsheetId", "value": null }, { "description": "The A1 notation of the range to append values after.", "jsonSchema": { "type": "string", "minLength": 1, "description": "The A1 notation of the range to append values after." }, "nullable": false, "handle": "range" }, { "description": "The data to append.", "jsonSchema": { "type": "array", "items": { "type": "array", "items": { "anyOf": [ { "type": "string", "description": "A union variant." }, { "type": "number", "description": "A union variant." }, { "type": "boolean", "description": "A union variant." }, { "const": null, "description": "A union variant." } ], "description": "The cell value schema." }, "description": "An array item." }, "description": "The data to append." }, "nullable": false, "handle": "values" }, { "description": "The major dimension of the values array.", "jsonSchema": { "type": "string", "enum": [ "ROWS", "COLUMNS" ], "description": "The major dimension of the values array." }, "nullable": true, "handle": "majorDimension", "value": null }, { "description": "How the data should be inserted.", "jsonSchema": { "type": "string", "enum": [ "OVERWRITE", "INSERT_ROWS" ], "description": "How the data should be inserted." }, "nullable": true, "handle": "insertDataOption", "value": null }, { "description": "How the input data should be interpreted.", "jsonSchema": { "type": "string", "enum": [ "RAW", "USER_ENTERED" ], "description": "How the input data should be interpreted." }, "nullable": true, "handle": "valueInputOption", "value": null }, { "description": "Whether to include the appended values in the response.", "jsonSchema": { "type": "boolean", "description": "Whether to include the appended values in the response." }, "nullable": true, "handle": "includeValuesInResponse", "value": null }, { "description": "How values in the response should be rendered.", "jsonSchema": { "type": "string", "enum": [ "FORMATTED_VALUE", "UNFORMATTED_VALUE", "FORMULA" ], "description": "How values in the response should be rendered." }, "nullable": true, "handle": "responseValueRenderOption", "value": null }, { "description": "How dates in the response should be rendered.", "jsonSchema": { "type": "string", "enum": [ "SERIAL_NUMBER", "FORMATTED_STRING" ], "description": "How dates in the response should be rendered." }, "nullable": true, "handle": "responseDateTimeRenderOption", "value": null } ], "outputs": [ { "description": "The unique ID of the spreadsheet.", "jsonSchema": { "type": "string", "description": "The unique ID of the spreadsheet." }, "nullable": false, "handle": "spreadsheetId" }, { "description": "The A1 notation of the range that was updated.", "jsonSchema": { "type": "string", "description": "The A1 notation of the range that was updated." }, "nullable": false, "handle": "updatedRange" }, { "description": "The number of rows that were updated.", "jsonSchema": { "type": "integer", "description": "The number of rows that were updated." }, "nullable": false, "handle": "updatedRows" }, { "description": "The number of columns that were updated.", "jsonSchema": { "type": "integer", "description": "The number of columns that were updated." }, "nullable": false, "handle": "updatedColumns" }, { "description": "The number of cells that were updated.", "jsonSchema": { "type": "integer", "description": "The number of cells that were updated." }, "nullable": false, "handle": "updatedCells" }, { "description": "The values of the cells after the update.", "jsonSchema": { "type": "object", "properties": { "range": { "type": "string", "description": "The A1 notation of the range." }, "majorDimension": { "type": "string", "description": "The major dimension of the values (ROWS or COLUMNS)." }, "values": { "type": "array", "items": { "type": "array", "items": { "anyOf": [ { "type": "string", "description": "A union variant." }, { "type": "number", "description": "A union variant." }, { "type": "boolean", "description": "A union variant." }, { "const": null, "description": "A union variant." } ], "description": "The cell value schema." }, "description": "An array item." }, "description": "The data values in the range." } }, "required": [ "range", "majorDimension", "values" ], "additionalProperties": false, "description": "The values of the cells after the update." }, "nullable": true, "handle": "updatedData" }, { "description": "The A1 notation of the table range that data was appended to.", "jsonSchema": { "type": "string", "description": "The A1 notation of the table range that data was appended to." }, "nullable": false, "handle": "tableRange" } ], "name": "Append the journal entry", "executor": { "kind": "connector", "action": "googlesheets.spreadsheets_values_append" } } }, "n_c711a10f8bda71ae": { "inputs": { "entry": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_a3c6c930a2705a9d", "output": "entry" } ] }, "date": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_a3c6c930a2705a9d", "output": "date" } ] }, "updatedRows": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_8eeaae851239147c", "output": "updatedRows" } ] } }, "name": "Confirm the journal entry", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "entry" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "date" }, { "jsonSchema": { "type": "integer", "description": "The number of rows that were updated." }, "nullable": false, "handle": "updatedRows" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "entry" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "date" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "updatedRows" } ], "name": "Confirm the journal entry", "moduleId": "n_aa6f1913b5cb7a62", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_a93448fbf2dcf362": { "name": "Saved journal entry", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "entry" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "date" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "updatedRows" } ], "outputMappings": { "entry": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c711a10f8bda71ae", "output": "entry" } ] }, "date": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c711a10f8bda71ae", "output": "date" } ] }, "updatedRows": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c711a10f8bda71ae", "output": "updatedRows" } ] } } } }, "edges": [ { "source": "n_ea118fb656f3f71b", "target": "n_a3c6c930a2705a9d" }, { "source": "n_a3c6c930a2705a9d", "target": "n_56965c98daf7ba01" }, { "source": "n_56965c98daf7ba01", "target": "n_8eeaae851239147c", "sourceHandle": "accept" }, { "source": "n_8eeaae851239147c", "target": "n_c711a10f8bda71ae" }, { "source": "n_c711a10f8bda71ae", "target": "n_a93448fbf2dcf362" } ] } }, "modules": { "n_d3077b860751b942": { "name": "Check the dated journal reply", "imports": [], "source": "export default function telegramJournalReply({ body, botUsername, userUsername }) {\n if (typeof botUsername !== 'string' || !botUsername.trim() || botUsername === 'YOUR_BOT_USERNAME' || typeof userUsername !== 'string' || !userUsername.trim() || userUsername === 'YOUR_USERNAME') throw new Error('Set the bot and user usernames without @');\n const message = body?.message;\n const reply = message?.reply_to_message;\n if (!message || !reply || message.from?.username !== userUsername || reply.from?.username !== botUsername || typeof message.text !== 'string') return { accepted: false, entry: '', date: '', values: [] };\n if (typeof reply.text !== 'string' || !reply.text.includes(':')) throw new Error('The bot prompt must contain a colon followed by the journal date');\n const date = reply.text.split(':')[1].replace(/\\s/g, '');\n const entry = message.text;\n return { accepted: true, entry, date, values: [[entry, date]] };\n}\n" }, "n_aa6f1913b5cb7a62": { "name": "Confirm the journal entry", "imports": [], "source": "export default function telegramJournalConfirm({ entry, date, updatedRows }) {\n if (updatedRows !== 1) throw new Error('The sheet did not confirm one row; inspect it before replaying');\n return { entry, date, updatedRows };\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }