Back to Templates

Poll Multiple Gmail Accounts with Unified Data Table Storage & Discord Notifications

Created by

Created by: Jatin Khatri || jatinkhatri

Jatin Khatri

Last update

Last update 2 days ago

Share


Screenshot 20251216 001014.png

This template lets you poll multiple Gmail accounts from a single workflow using n8n’s credential-aware execution. Instead of creating separate workflows for every inbox, this setup loops through all accounts stored in your data table and runs Gmail operations dynamically using the correct OAuth2 credential.

It’s built for cases like cold-email systems, multi-client mail monitoring, or anything that needs centralized polling and logging.

### What It Does

  1. Pulls all email account records from the cold_email_accounts table.

  2. For every account, the workflow:

  3. Runs the Gmail “Get Many Messages” node for that account using "Run Node With Credentials X" community node.

  4. Messages are reformatted into a clean JSON object (from, subject, preview text, body, labels, attachments, etc.).

  5. Saved into the All Emails table using an upsert (avoids duplicates).

  6. Sends a Discord notification like “15 new emails arrived”.

### How to Set It Up

  1. Create Gmail OAuth2 credentials in n8n, one for each email account you want to poll.

  2. Add those credentials into a Data Table named cold_email_accounts with columns:
    cred_id
    credentials_name
    email
    last_polled (datetime)

  3. Import this workflow template into n8n.

  4. Update:
    DataTable references (if your names/IDs differ)
    Discord channel/server IDs
    Any domain filters inside the Gmail search query

  5. Activate the workflow and it will automatically:
    Poll each Gmail inbox every hour
    Save all new emails
    Notify you on Discord
    Keep everything synced via last_polled.