Automate Data Flow from Random User API to Sheets & Email with n8n

This n8n workflow automates fetching random user data, appending it to Google Sheets, converting to CSV and JSON files, and emailing the JSON file. It eliminates manual data entry, accelerates processing, and ensures seamless data sharing.
httpRequest
googleSheets
spreadsheetFile
+4
Workflow Identifier: 2407
NODES in Use: httpRequest, set, googleSheets, spreadsheetFile, moveBinaryData, writeBinaryFile, gmail
Automate data flow with n8n and GoogleSheets

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

What This Automation Does

This workflow gets random user info from the https://randomuser.me/api/ API.

It picks out only the user names and countries for easy reading.

It adds this data as new rows in a Google Sheets file to keep a record growing.

Then it turns the spreadsheet data into a CSV file format for backup or sharing.

From the CSV data, it creates a JSON file ready for flexible use.

Next, it sends this JSON file by email using Gmail so the data reaches others fast.

Finally, it reads that emailed JSON file and adds its data into another Google Sheets to keep all info updated.

This automation saves time spent copying data, stops manual mistakes, and keeps data safe in two formats.


Step-by-Step Guide

Step 1: Configure HTTP Request Node to Fetch Random User Data

Open the HTTP Request node.

Set URL to https://randomuser.me/api/. Leave other options as default.

When you run this, it gets random user data including names and countries.

Common mistake with Step 1

  1. Wrong URL or HTTP method causes no data return.

Step 2: Extract User Data Using Set Node

Open the Set node.

Add two string fields: name and country.

Use these expressions for values:

{{$json["results"][0]["name"]["first"]}} {{$json["results"][0]["name"]["last"]}}

{{$json["results"][0]["location"]["country"]}}

This cleans raw data to just the columns you want.

Common mistake with Step 2

  1. Wrong expression syntax or not choosing “Keep Only Set” adds cluttered data.

Step 3: Add Data to Google Sheets

Use the Google Sheets node.

Set operation to Append.

Select your spreadsheet by sheet ID, like “qwertz”.

Set range to “A:C” and enable “Use Path For Key Row”.

New user info will add to the sheet bottom.

Common mistake with Step 3

  1. Missing or bad OAuth2 credentials block sheet editing.

Step 4: Turn Spreadsheet Data into CSV File

Use the Spreadsheet File node.

Set Operation to toFile and File Format to CSV.

Name the file like “users_spreadsheet.csv”.

This saves spreadsheet rows as a CSV file for backups.

Common mistake with Step 4

  1. Wrong file name or unsupported format breaks node run.

Step 5: Change CSV to JSON Binary Data

Connect this CSV file output to another Spreadsheet File node to parse CSV back to JSON.

Then use the Move Binary Data node set to “jsonToBinary” mode to get JSON as a binary file.

Common mistake with Step 5

  1. Skipping proper data changes leads to bad file output.

Step 6: Save JSON as a File

Use the Write Binary File node.

Save binary JSON data in a file called “randomusers.json” on your system.

Common mistake with Step 6

  1. Wrong file path or no write permissions cause failure.

Step 7: Email the JSON File Using Gmail

Use the Gmail node with OAuth credentials set.

Write message like “Hello, attached is the random user JSON file.”.

Set the subject.

Add the JSON file as a binary attachment using property “data” under attachmentsBinary.

Common mistake with Step 7

  1. Wrong attachment data reference causes email to miss file.

Step 8: Read JSON Attachment and Add Back to Google Sheets

After sending, extract the email attachment binary using the Move Binary Data node with sourceKey “attachment_0”.

Append this data to another Google Sheets node spreadsheet.

Common mistake with Step 8

  1. Wrong sourceKey leads to empty or wrong sheet data.

Beginner Step-by-Step: Using the Workflow in n8n

Step 1: Download and Import

  1. Download the workflow file here on this page using the Download button.
  2. Open your n8n editor.
  3. Click the menu and select “Import from File”.
  4. Choose the downloaded workflow file to import.

Step 2: Configure Credentials and IDs

  1. Add your Google Sheets OAuth2 credentials in the Google Sheets nodes.
  2. Add your Gmail OAuth2 credentials in the Gmail node.
  3. Update sheet IDs in Google Sheets nodes if your spreadsheets are different.
  4. Update recipient emails in the Gmail node as needed.

Step 3: Test and Activate

  1. Run the workflow manually in n8n once to confirm data flows correctly.
  2. Check Google Sheets and your inbox for new data and email.
  3. If all works, turn the workflow ON using the toggle.
  4. Optionally, add a Cron node or other triggers for automatic runs.

This lets users quickly use the workflow in production without coding.

For self hosting n8n, visit this page for help.


Prerequisites ⚙️

  • n8n account: Cloud or self-hosted (self-host n8n)
  • Google Sheets account: OAuth credentials configured in n8n
  • Gmail account: OAuth credentials configured in n8n
  • Internet access: To call Random User API via HTTP Request node

Customizations ✏️

  • Change Data Range in Google Sheets: Adjust range in Google Sheets nodes to add more columns, e.g. “A:D”.
  • Email More People: Add multiple addresses separated by commas in the Gmail node.
  • Get Many Users: Add query parameters like “?results=5” to HTTP Request URL to fetch many users at once.
  • Save JSON to Cloud Storage: Replace Write Binary File node with cloud storage nodes such as S3 or Google Drive.

Troubleshooting 🔧

Problem: Invalid OAuth2 Credentials in Google Sheets

Cause: Missed re-authentication or expired token.

Fix: Update OAuth2 credentials in n8n credentials manager and check permissions.

Problem: Gmail Node Sends Email Without Attachment

Cause: Attachment binary property not linked properly.

Fix: Check Gmail node’s attachmentsBinary field uses property “data” from previous node.

Problem: Data Not Added to Google Sheets

Cause: Wrong sheet ID or exceeded API quota.

Fix: Confirm sheet ID is correct and check quotas on Google Cloud Console.


Pre-Production Checklist ✅

  • Check HTTP Request node retrieves user data.
  • Confirm Google Sheets OAuth2 credentials and sheet IDs are correct.
  • Run a test to verify data enters Google Sheets.
  • Verify Write Binary File node creates JSON file.
  • Send a test email with Gmail node and check mailbox for attachment.
  • Check appended data in final Google Sheets node.
  • Backup sheets before full runs for safety.

Deployment Guide

Turn the workflow ON in n8n using the toggle.

Run the first test manually.

Add triggers like Cron node to automate runs at intervals.

Watch executions list in n8n for errors.

Set failure email alerts if possible.


Conclusion

✓ Automates getting user info from Random User API to Google Sheets.

✓ Saves hours of cutting, pasting, and fixing data mistakes.

✓ Keeps data in spreadsheets and JSON format for backups and sharing.

✓ Sends JSON files by email so data is shared fast.

✓ Imports emailed data back into Google Sheets to keep all info updated.

→ You get accurate, fast user data logs with less manual work.

→ Use extra time on analysis or other key tasks.


Automate data flow with n8n and GoogleSheets

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

Yes. Any API returning JSON with user name and country can work if the Set node expressions are updated accordingly.
Yes. Each append to sheets or email sent counts against Google API quotas. Monitor quota usage in Google Cloud Console.
OAuth2 credentials secure data access without exposing passwords. Keep the n8n instance secure to protect data.
Yes. Adjust the HTTP Request URL with parameters like ?results=5 and loop or batch processes in n8n for bulk data.

Promoted by BULDRR AI

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.
manualTrigger
twist
twist
Free

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.
googleSheets
httpRequest
chainLlm
+8
Free

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.
RespondToWebhook
If
Slack
+5
Free

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.
agent
lmChatOpenAi
toolWorkflow
+3
Free

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.
gumroadTrigger
googleSheets
httpRequest
+3
Free

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
httpRequest
informationExtractor
wordpress
+9
Free
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.