Dynamic Global Variables for Multiple Sites in a Workflow

Hi everyone! I’m trying to track content changes across several sites in a Run Workflow step and ran into an issue with global variables.

I’m passing the following JSON as the input:

[
  {
    "site": "n8n",
    "url": "https://n8n.io/legal/cloud-enterprise-terms/"
  },
  {
    "site": "mindstudio",
    "url": "https://www.mindstudio.ai/legal/terms-of-use"
  },
  {
    "site": "make",
    "url": "https://www.make.com/en/privacy-notice"
  }
]

The workflow iterates through each item and checks the page for changes.

To track changes, I need to store a previous value (e.g., hash or content) for each site. Ideally, I’d like to store these in global variables, one per site.

What I was hoping to do is dynamically reference the variable name based on the current item, something like:

{{current_site.site}}

So the stored variables would effectively become:

  • n8n

  • mindstudio

  • make

However, it doesn’t seem possible to dynamically set the global variable name this way.

I also tried creating the globals manually, but I couldn’t find a clean way to initialize and reference them during the iteration.

Question:
Is there a recommended pattern in MindStudio for storing and retrieving per-item persistent values (like previous page content) when iterating over a list like this?

For example:

  • dynamically named global variables

  • a key/value store pattern

  • or another approach for persistent per-site state

Any suggestions would be appreciated!

Hi @bkermen,

Apologies for the delayed reply!

I’ve been thinking about this, and I don’t believe you can dynamically resolve and update global variable names that way. I could be wrong, though, so if anyone has ideas, feel free to jump in.

What could work well for this use case is the new database feature. You can use the Query App Database block to write SQL queries and store your per-site data there instead of relying on global variables. So the flow would look something like:

  1. The Scrape URL block pulls the latest content for each site
  2. A SQL query retrieves the previous scrape data for that specific site from your database
  3. You compare the two and flag any changes
  4. Then update the database with the new content for next time

Here’s a remix link to a sample agent:
https://app.mindstudio.ai/agents/website-change-monitor-f6634ab5/remix

Let me know what you think!

Thanks, @Alex_MindStudio.

Using a global variable isn’t a must. App databases are a relatively recent addition, and I think they’d be a great fit for this use case.

Thanks again for the sample.