{"secureTokens":{"secrets":[],"connections":[{"connectionId":"4648049012375552","id":"g2652dtbbmpqtyn5l","type":"action","actionTypeId":"redeemoauthtoken-v1","path":"settings.accessToken","fullPath":"settings.accessToken[0]","displayName":"Redeem OAuth Token"}],"aiModels":[]},"isPublished":true,"isTriggerTypeChanged":false,"id":"4946211816079360","name":"Extract Text from Google Doc","description":"","rootContainer":{"id":"eu8j1uk2xmjyn2fxx","type":"container","steps":[{"actionTypeId":"redeemoauthtoken-v1","errorHandling":{"retries":[],"errorAction":0},"id":"g2652dtbbmpqtyn5l","name":"Redeem OAuth Token","displayName":"Prepare Authentication","settings":{"accessToken":[{"type":"ref","value":{"referenceType":"connection","dataType":"string","displayName":null,"error":false,"connectionId":"4648049012375552"}}]},"type":"action"},{"actionTypeId":"googledrivefileget-v1","errorHandling":{"retries":[],"errorAction":0},"id":"e18qqio0empraqq6x","name":"Find File/Folder","displayName":"Locate Google Doc File","settings":{"accessToken":[{"type":"ref","value":{"referenceType":"connection","dataType":"string","displayName":null,"error":false,"connectionId":"4820678757842944"}}]},"type":"action"},{"actionTypeId":"utilityhttprequest-v1","errorHandling":{"retries":[],"errorAction":0},"id":"3dkaaesytmpqtx089","name":"Make HTTP Request","displayName":"Fetch Document JSON Content","settings":{"requestMethod":"get","bodyType":"none","authorizationType":"bearerToken","url":[{"type":"text","value":"https://docs.googleapis.com/v1/documents/"},{"type":"ref","value":{"referenceType":"stepParam","displayName":"Locate Google Doc File.Id","flowStepId":"e18qqio0empraqq6x","dataType":"string","outputName":"id","isProjected":false,"path":".id","possibleNull":false,"iconSrc":"assets/img/designer/actions/googledrivefileget-v1.svg","error":false}}],"bearerToken":[{"type":"ref","value":{"referenceType":"stepParam","displayName":"Prepare Authentication.Token","flowStepId":"g2652dtbbmpqtyn5l","dataType":"string","outputName":"token","isProjected":false,"path":".token","possibleNull":false,"iconSrc":"assets/img/designer/actions/redeemoauthtoken-v1.svg","error":false}}],"headers":[{"type":"text","value":""}],"fileContentType":null,"fileName":null},"type":"action"},{"actionTypeId":"parsejson-v1","errorHandling":{"retries":[],"errorAction":0},"id":"hlull953impquvl0r","name":"Convert JSON to Object","displayName":"Parse API Response","settings":{"input":[{"type":"ref","value":{"referenceType":"stepParam","displayName":"Fetch Document JSON Content.Body Text","flowStepId":"3dkaaesytmpqtx089","dataType":"string","outputName":"body","isProjected":false,"path":".body","possibleNull":false,"iconSrc":"https://api-zone1.zenphi.io/343097f7a2b64a98836236fd44c4ff39/providers/utility/u/e6c27138-f861-4d56-8975-7bb6cfb100f0/v/0/ui/assets/icons/utilityhttprequest-v1.svg","error":false}}]},"type":"action"},{"actionTypeId":"script-v1","errorHandling":{"retries":[],"errorAction":0},"id":"7947wg6sqmpquokds","name":"Execute Script","displayName":"Extract Text from JSON","settings":{"parameters":[{"name":"rawDocsJson","dataType":"string","value":{"stringValue":[{"type":"ref","value":{"referenceType":"stepParam","displayName":"Fetch Document JSON Content.Body Text","flowStepId":"3dkaaesytmpqtx089","dataType":"string","outputName":"body","isProjected":false,"path":".body","possibleNull":false,"iconSrc":"https://api-zone1.zenphi.io/343097f7a2b64a98836236fd44c4ff39/providers/utility/u/e6c27138-f861-4d56-8975-7bb6cfb100f0/v/0/ui/assets/icons/utilityhttprequest-v1.svg","error":false}}]}}],"script":"// Description: Extracts plain text from a Google Docs JSON structure by iterating through body content elements.\nexport default function run() {\n    const inputData = parameters.rawDocsJson;\n    \n    if (!inputData) {\n        return { cleanText: \"\" };\n    }\n\n    try {\n        // Parse string to object since platform parameters are received as strings\n        const docJson = typeof inputData === 'string' ? JSON.parse(inputData) : inputData;\n        let plainText = \"\";\n\n        // Safety check: Make sure the JSON has the expected body and content structure\n        if (!docJson || !docJson.body || !docJson.body.content) {\n            return { cleanText: \"Error: Invalid Document JSON structure.\" };\n        }\n\n        const contentArray = docJson.body.content;\n\n        // Loop through every structural element in the document\n        for (let i = 0; i < contentArray.length; i++) {\n            const structuralElement = contentArray[i];\n\n            // We only care about paragraphs\n            if (structuralElement.paragraph && structuralElement.paragraph.elements) {\n                const paraElements = structuralElement.paragraph.elements;\n\n                // Loop through the elements inside the paragraph\n                for (let j = 0; j < paraElements.length; j++) {\n                    const element = paraElements[j];\n\n                    // If it's a text run, grab the string and add it to our result\n                    if (element.textRun && element.textRun.content) {\n                        plainText += element.textRun.content;\n                    }\n                }\n            }\n        }\n\n        // Return the final clean string\n        return { cleanText: plainText.trim() };\n        \n    } catch (error) {\n        const errorMessage = error instanceof Error ? error.message : \"Unknown error\";\n        return { cleanText: \"Error parsing JSON: \" + errorMessage };\n    }\n}","exportSchema":"{\n    \"$schema\": \"http://json-schema.org/draft-04/schema\",\n    \"type\": \"object\",\n    \"properties\": {\n        \"default\": {\n            \"type\": \"object\",\n            \"properties\": {\n                \"cleanText\": {\n                    \"type\": \"string\",\n                    \"title\": \"Clean Text\"\n                }\n            },\n            \"title\": \"Default\"\n        }\n    }\n}","scriptError":false},"type":"action"},{"actionTypeId":"logtohistory-v1","errorHandling":{"retries":[],"errorAction":0},"id":"kyrrcaejbmpqvh4u7","name":"Log to History","displayName":"Log Extracted Text","settings":{"message":[{"type":"ref","value":{"referenceType":"stepParam","displayName":"Extract Text from JSON.Exports.Default.Clean Text","flowStepId":"7947wg6sqmpquokds","dataType":"string","outputName":"exports.default.cleanText","isProjected":false,"path":".exports.default.cleanText","possibleNull":false,"iconSrc":"assets/img/designer/actions/script-v1.svg","error":false}}]},"type":"action"}],"label":null,"showLabel":false},"variables":[],"triggers":[{"id":"9824a39e8a72429fa83384195799c740","name":"On Demand Flow","triggerType":"manualv1","triggerTypeName":"On Demand Flow","connectionId":null,"parameters":[],"configuration":null,"hasFilter":false,"filter":null}],"startParameters":[],"parameterMapping":[],"version":"2.4","isDraft":true,"isPrivate":true,"tags":[],"metadata":[],"publishedMetadata":[],"flowMetadata":{},"notes":[]}