Ep.03 n8n Workflow Examples, Export Options and Data Flow – Zero to Automation Pro Series

Building a truly efficient n8n workflow starts with visualizing the journey of a single piece of data. Whether you are pulling leads from a webhook or syncing rows to a database, understanding the underlying JSON structure is key to unlocking advanced automation. In Episode 03, we move beyond the basics to showcase versatile n8n workflow templates, demonstrating how to handle data transformations and use built-in export tools to migrate your projects seamlessly between environments.

Views: 86

Mastering the art of automation requires more than just connecting apps; it demands a deep understanding of how information moves from one node to another. In previous episode 02, we learned the n8n core concepts with a hello world workflow example. In this third episode of our “Zero to Automation Pro” series, we dive into the practical mechanics of the n8n workflow. We’ll explore real-world examples that solve common business bottlenecks, break down the various export options for sharing your builds, and demystify the logic of data flow to ensure your automations are both scalable and “bulletproof.”

https://youtu.be/_FU9NJ2qng0

Part 1: n8n Workflow Examples:

n8n Workflow Example 1: Date and Time Formatter

What it does: Takes current date and formats it multiple ways.

Steps:

  1. Create new workflow: “EP03-DateFormatter”
  2. Add Manual Trigger
  3. Add Code Node:
    • Add after Manual Trigger
    • Search for “Code”
    • Select “Code” node
    • In the node, you’ll see a JavaScript editor
  4. Write Your First JavaScript in n8n:
// Get the current date and time
const now = new Date();

// Format in different ways
const formatted = {
  iso: now.toISOString(),
  local: now.toLocaleString(),
  date_only: now.toLocaleDateString(),
  time_only: now.toLocaleTimeString(),
  timestamp: now.getTime(),
  day_name: now.toLocaleDateString('en-US', { weekday: 'long' }),
  month_name: now.toLocaleDateString('en-US', { month: 'long' }),
  year: now.getFullYear(),
  custom: `Today is ${now.toLocaleDateString('en-US', { weekday: 'long' })}, ${now.toLocaleDateString('en-US', { month: 'long' })} ${now.getDate()}, ${now.getFullYear()}`
};

// Return the data
return [{ json: formatted }];
  1. Execute and Examine:
    • Run the workflow
    • Click on Code node
    • See all the different date formats
    • Understand the data structure
  2. Save the workflow

Key Learning:

  • Code node runs JavaScript
  • return [{ json: {...} }] is the n8n data structure
  • You can use any JavaScript date/time manipulation

n8n Workflow Example 2: Simple API Call

What it does: Fetches data from a public API and processes it.

Steps:

  1. Create new workflow: “EP03-APICall”
  2. Add Manual Trigger
  3. Add HTTP Request Node:
    • Add after Manual Trigger
    • Search for “HTTP Request”
    • Configure:
      • Method: GET
      • URL: https://api.github.com/users/n8n-io
      • (Leave other options as default)
  4. Add Code Node to Process Response:
    • Add after HTTP Request
    • Name it “Process GitHub Data”
    • Code:
// Get the input data from previous node
const githubData = $input.all()[0].json;

// Extract interesting information
const processed = {
  username: githubData.login,
  name: githubData.name,
  bio: githubData.bio,
  public_repos: githubData.public_repos,
  followers: githubData.followers,
  following: githubData.following,
  profile_url: githubData.html_url,
  created_at: githubData.created_at,
  account_age_days: Math.floor((new Date() - new Date(githubData.created_at)) / (1000 * 60 * 60 * 24))
};

return [{ json: processed }];
  1. Add Another Code Node (for formatted output):
    • Add after Process GitHub Data
    • Name it “Create Summary”
    • Code:
const data = $input.all()[0].json;

const summary = {
  report: `GitHub User: ${data.name} (@${data.username})
  
Bio: ${data.bio}

Stats:
- Public Repositories: ${data.public_repos}
- Followers: ${data.followers}
- Following: ${data.following}
- Account Age: ${data.account_age_days} days

Profile: ${data.profile_url}`,
  raw_data: data
};

return [{ json: summary }];
  1. Execute and Explore:
    • Run the workflow
    • Click each node to see its output
    • Notice how data transforms through the workflow
  2. Save the workflow

Key Learning:

  • HTTP Request node fetches external data
  • $input.all() accesses data from previous nodes
  • Data flows and transforms through nodes
  • You can chain multiple processing steps

Part 2: How to Export Your n8n Workflow?

Save Workflows as JSON Files

For each workflow:

  1. Click the workflow name (top left)
  2. Select the three dots menu (…)
  3. Click “Download”
  4. Save to your n8n-learning/workflows/ folder
  5. Name them:
    • ep01-helloworld.json
    • ep01-dateformatter.json
    • ep01-apicall.json

Commit to Git

cd ~/n8n-learning
git add workflows/
git commit -m "Episode 3: n8n workflow examples completed with export options"

Part 3: Understanding n8n Data Flow

The Data Structure Deep Dive

Create a new workflow: “EP03-DataFlow-Understanding”

Add Manual Trigger → Code Node

In the Code node, paste this:

// Understanding n8n data structure
// Every node works with an array of items

// Single item structure
const singleItem = [
  {
    json: {
      name: "John",
      age: 30
    }
  }
];

// Multiple items structure
const multipleItems = [
  { json: { id: 1, name: "Alice" } },
  { json: { id: 2, name: "Bob" } },
  { json: { id: 3, name: "Charlie" } }
];

// Items can have binary data too
const itemWithBinary = [
  {
    json: { filename: "test.txt" },
    binary: {
      data: {
        data: "base64encodeddata",
        mimeType: "text/plain"
      }
    }
  }
];

// For this demo, let's return multiple items
return [
  { json: { type: "user", name: "Alice", score: 95 } },
  { json: { type: "user", name: "Bob", score: 87 } },
  { json: { type: "admin", name: "Charlie", score: 92 } }
];

Add another Code Node after it:

// Processing each item
// $input.all() gives you ALL items from previous node
const allItems = $input.all();

console.log(`Received ${allItems.length} items`);

// Process each item
const processed = allItems.map(item => {
  const data = item.json;
  
  return {
    json: {
      original_name: data.name,
      uppercase_name: data.name.toUpperCase(),
      score: data.score,
      grade: data.score >= 90 ? 'A' : data.score >= 80 ? 'B' : 'C',
      type: data.type
    }
  };
});

return processed;

Execute and observe:

  • First Code node: Creates 3 items
  • Second Code node: Processes all 3 items
  • Each item flows through independently
  • This is the foundation of n8n data handling

Part 4: What we have Achieved So Far?

Let’s summarize what we have achieved so far:

  • Episode 1 – Environment Setup
    • Installed Node.js v[your version]
    • Installed n8n globally
    • Set up VS Code with extensions
    • Created project structure
    • Committed code to GIT
    • n8n Editor Preview
  • Episode 2 – n8n Core Concepts with Hello World Workflow
    • Learned n8n core concepts
      • workflows
      • nodes
      • connections
      • data structure
      • executions
    • n8n Interface walkthrough
    • Hello World n8n Workflow
  • Episode 3 – n8n Workflow Examples, Export Options, n8n Data Flow
    • Data Formatter n8n Workflow
    • API Call n8n Workflow
    • n8n Data Flow Understanding

Next Episode:

In the next episode, we will explore the advanced data manipulation and workflow patterns!

## Episode 1,2,3 Completion Checklist

Check off everything you've accomplished:

- [ ] Node.js installed and verified
- [ ] VS Code installed with extensions
- [ ] Git installed and configured
- [ ] n8n installed and running on localhost:5678
- [ ] Project folder structure created
- [ ] Git repository initialized
- [ ] Created HelloWorld workflow
- [ ] Created DateFormatter workflow
- [ ] Created APICall workflow
- [ ] Created DataFlow-Understanding workflow
- [ ] Workflows exported as JSON files
- [ ] Changes committed to Git
- [ ] Can explain n8n data structure in own words

Leave a Reply