How Can I Decrease the Memory Requirements of a Complex Automation Workflow to Prevent Running Out of Memory?

there is no such action as “Send to another workflow”

I apologize for the confusion earlier. You’re right, there isn’t a “Send to another workflow” action. Instead, you can use an HTTP action to send data from Workflow #1 to Workflow #2. Here’s how you can set it up: 1. In Workflow #1, add an HTTP action step. 2. Set the method to POST. 3. In Workflow #2, create an HTTP trigger, and copy its endpoint URL. 4. Paste the copied URL into the URL field of the HTTP action step in Workflow #1. 5. In the body of the HTTP action step in Workflow #1, pass the data you want to send to Workflow #2 as a JSON object. For example: on { "node": "{{steps.trigger.event.node}}", "chat": "{{steps.trigger.event.chat}}", "trigger": "{{steps.trigger.event.trigger}}" } Now, in Workflow #2, you can access the data from Workflow #1 using the same variable names: ```
{{steps.trigger.event.node}} {{steps.trigger.event.chat}} {{steps.trigger.event.trigger.newRow[0]}}

Here is what I did:

Workflow #1 ends with Custom_Request action, posting JSON:
• keys: node, chat, chat_18, trigger
• values: {{steps.node}}, {{steps.chat}}, {{steps.chat_18}}, {{steps.trigger.event.newRow[0]}}
Workflow #2 begins with HTTP request from the previous workflow.

However, my steps in Workflow #2 are not able to access the variables passed on because they are different names.

The original variable names are simply showing up as:

“undefined”

I apologize for the confusion earlier. To ensure that the variables in Workflow #2 have the same names as in Workflow #1, you can use the following approach: In Workflow #1, when sending the HTTP POST request, set the JSON body like this: on { "node": "{{steps.node}}", "chat": "{{steps.chat}}", "chat_18": "{{steps.chat_18}}", "trigger": "{{steps.trigger.event.newRow[0]}}" } In Workflow #2, you can access these variables directly from the HTTP trigger event: ```
const node = steps.trigger.event.node; const chat = steps.trigger.event.chat; const chat_18 = steps.trigger.event.chat_18; const trigger = steps.trigger.event.trigger;

Yes, I can access these variables, but they are different names from Workflow #1, so none of the steps in workflow #2 are referencing them.

{{steps.node}} has turned into {{steps.trigger.event.body.node}}

{{steps.chat}} has turned into {{steps.trigger.event.body.chat}}

etc.

As you can see, they are not the same variables, because the variable names are based on the steps they originated from.

Is there any way for me to make the variables exactly the same? Or do I have to manually change them in workflow #2?

And keep in mind, adding custom code to rename these variables won’t work either, because the variables taxonomy will simply start with the node step.

I understand your concern about the variable names being different in Workflow #2. Unfortunately, when passing data between workflows, the variable names will be based on the steps they originated from, as you mentioned. In this case, you’ll need to manually update the variable references in Workflow #2 to match the new names, such as {{steps.trigger.event.body.node}} and {{steps.trigger.event.body.chat}}. I apologize for the inconvenience, but this is the current behavior when passing data between workflows.

I’ve created a working workflow now, and everything is great. It generates markdown text in the cells I specify.

Now I’d like to build a final workflow that reads all of the completed cells, translates the markdown into HTML, and adds it to a Google Doc.

I have managed to pull all of the correct data from the correct cell range.

My last step is a Google Sheets “Get Values in Range” step that successfully pulls all of the content into a variable.

How do I now turn this content )which is formatted in markdown) into HTML?

To convert the markdown content from the Google Sheets cells into HTML, you can use a library like markdown-it. Here’s an example of how to use markdown-it in a Pipedream code step: 1. First, import the markdown-it package: import MarkdownIt from "markdown-it"; 2. Then, create an instance of the MarkdownIt class and use it to convert the markdown content to HTML: export default defineComponent({ async run({ steps }) { const markdownContent = steps.your_previous_step_name.result; // Replace with the actual step name const md = new MarkdownIt(); const htmlContent = md.render(markdownContent); // Now you can use the htmlContent variable to add the HTML to a Google Doc }, }); Replace your_previous_step_name with the actual name of the step that retrieves the content from Google Sheets. After converting the markdown to HTML, you can use the Google Docs API to insert the HTML content into a Google Doc. You can refer to the Google Docs API documentation for more information on how to insert the HTML content.

how do “import” the package? How do I “create an instance” of the class?

To import a package and create an instance of a class in a Pipedream code step, follow these steps: 1. Import the package using the ESM import syntax at the top of your code step: import PackageName from "package-name"; Replace PackageName with the actual package name you want to import. 2. Create an instance of the class within the run method of your Pipedream component: const instance = new PackageName(options); Replace PackageName with the actual package name, and options with any required options for the class constructor. Here’s an example of how to import the markdown-it package and create an instance of the MarkdownIt class: import MarkdownIt from "markdown-it"; export default defineComponent({ async run({ steps }) { const md = new MarkdownIt(); // Now you can use the md instance to convert markdown to HTML }, }); In this example, we import the markdown-it package and create an instance of the MarkdownIt class within the run method of the Pipedream component.

my step “Get Values From Range” brings in all of the markdown text as separate numbered variables (57 of them).

How can I combine all of the data from the cells into a single variable?

steps.get_values_in_range{1}
$return_value[1]
0[57]

To combine all the data from the cells into a single variable, you can use a code step in your Pipedream workflow. Assuming the step that gets the values from the range is named get_values_in_range, you can use the following code to concatenate all the cell values into a single variable: export default defineComponent({ async run({ steps }) { const cellValues = steps.get_values_in_range.values; const combinedContent = cellValues.flat().join("\n"); return combinedContent; }, }); This code takes the values from the get_values_in_range step, flattens the array (in case it’s a 2D array), and then joins the values using a newline character. The combined content will be available as the output of this code step, which you can use in subsequent steps.

getting this error:
TypeError
Cannot read properties of undefined (reading ‘flat’)
DETAILS

    at Object.run (file:///tmp/__pdg__/dist/code/d508d1c8e6dc03d92ceef139bcac59ee499ecf7626c03f7e335f6848ba122dd7/component.mjs:4:40)
    at null.executeComponent (/var/task/launch_worker.js:229:53)
    at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)

Some of the cells in the range are empty. Is this an issue?

I apologize for the confusion. It seems that the values property might be missing from the get_values_in_range step. Let’s modify the code to handle this case: export default defineComponent({ async run({ steps }) { const cellValues = steps.get_values_in_range.values || []; const combinedContent = cellValues.flat().join("\n"); return combinedContent; }, }); This code checks if values is present in the get_values_in_range step and assigns an empty array if it’s not. This should prevent the error you encountered. Empty cells in the range should not be an issue, as they will be treated as empty strings when joining the content.

return_value is empty:

steps.node_1{1}
$return_value:

I apologize for the confusion earlier. It seems that the code I provided might not be working as expected. To better assist you, could you please provide more information about the get_values_in_range step? Specifically, what is the structure of the output from that step? This will help me understand how to properly combine the values into a single variable.

here is the structure:

steps.get_values_in_range{1}
$return_value[1]
0[57]
0: My Content in cell A
1: My Content in cell B
2: My Content in cell C

56: My Content in cell BE

Thank you for providing the structure of the output. Based on the information you provided, you can use the following code to combine the cell values into a single variable: export default defineComponent({ async run({ steps }) { const cellValues = steps.get_values_in_range.$return_value; const combinedContent = cellValues.join("\n"); return combinedContent; }, }); This code takes the values from the get_values_in_range step and joins them using a newline character. The combined content will be available as the output of this code step, which you can use in subsequent steps.

now can you help me rewrite the code below to turn the value in variable steps.node_1.$return_value from markdown into HTML?

export default defineComponent({
  async run({ steps }) {
    const markdownContent = steps.your_previous_step_name.result; // Replace with the actual step name
    const md = new MarkdownIt();
    const htmlContent = md.render(markdownContent);

    // Now you can use the htmlContent variable to add the HTML to a Google Doc
  },
});

Sure, I can help you modify the code to convert the markdown content from steps.node_1.$return_value into HTML. First, you’ll need to import the MarkdownIt package. Here’s the updated code: import MarkdownIt from "markdown-it"; export default defineComponent({ async run({ steps }) { const markdownContent = steps.node_1.$return_value; const md = new MarkdownIt(); const htmlContent = md.render(markdownContent); // Now you can use the htmlContent variable to add the HTML to a Google Doc or use it in other steps return htmlContent; }, }); This code takes the markdown content from steps.node_1.$return_value, uses the MarkdownIt package to convert it into HTML, and then returns the HTML content. You can use the output of this code step in subsequent steps.