AutomationFlowsEmail & Gmail › Monthly Energy Report: Postgres to PDF Email

Monthly Energy Report: Postgres to PDF Email

Original n8n title: Monthly Energy Generation Report (postgres → PDF → Email)

Monthly Energy Generation Report (Postgres → PDF → Email). Uses httpRequest, gmail, postgres. Scheduled trigger; 7 nodes.

Cron / scheduled trigger★★★★☆ complexity7 nodesHTTP RequestGmailPostgres
Email & Gmail Trigger: Cron / scheduled Nodes: 7 Complexity: ★★★★☆ Added:

This workflow follows the Gmail → HTTP Request recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "lFJOVIgGwLDmQa4o",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Monthly Energy Generation Report (Postgres \u2192 PDF \u2192 Email)",
  "tags": [],
  "nodes": [
    {
      "id": "8a74f8aa-d3bf-4a08-9950-e51077071a5e",
      "name": "Transform data",
      "type": "n8n-nodes-base.code",
      "position": [
        360,
        0
      ],
      "parameters": {
        "jsCode": "return {\n  json: {\n    json_string: JSON.stringify({\n      date_range: \"2025-07-01 to 2025-07-03\",\n      records: $input.all().map(record => ({\n        id: record.json.id,\n        site_name: record.json.site_name,\n        generation_date: record.json.generation_date,\n        energy_generated_kwh: record.json.energy_generated_kwh,\n        peak_power_kw: record.json.peak_power_kw,\n        remarks: record.json.remarks\n      })),\n      note: \"TEST\"\n    })\n  }\n};\n"
      },
      "typeVersion": 2
    },
    {
      "id": "7e78ea66-5a79-4904-a514-f5916602b571",
      "name": "Convert data to pdf",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        580,
        0
      ],
      "parameters": {
        "url": "https://api.pdf.co/v1/pdf/convert/from/html",
        "options": {},
        "sendBody": true,
        "sendQuery": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {}
          ]
        },
        "queryParameters": {
          "parameters": [
            {}
          ]
        },
        "headerParameters": {
          "parameters": [
            {}
          ]
        }
      },
      "executeOnce": true,
      "typeVersion": 4.2
    },
    {
      "id": "3f834d5f-2239-4842-a14e-9a1c15dbb771",
      "name": "Send Report",
      "type": "n8n-nodes-base.gmail",
      "position": [
        800,
        0
      ],
      "parameters": {
        "sendTo": "",
        "message": "=Your monthly energy report is as follows  {{ $json.url }}",
        "options": {
          "appendAttribution": true
        },
        "subject": "Energy Report",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "e8dd1777-6e62-4d14-89dc-e3217b9f7318",
      "name": "Get energy data",
      "type": "n8n-nodes-base.postgres",
      "position": [
        140,
        0
      ],
      "parameters": {
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "energy_data",
          "cachedResultName": "energy_data"
        },
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public",
          "cachedResultName": "public"
        },
        "options": {},
        "operation": "select"
      },
      "typeVersion": 2.6
    },
    {
      "id": "18bb8b25-1532-4b31-9b53-6599c6ee5624",
      "name": "Monthly Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -80,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "months",
              "triggerAtMinute": 1
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "72b04ac2-68f3-4e90-9b02-e250f83aeb42",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -140,
        -160
      ],
      "parameters": {
        "color": 4,
        "width": 1140,
        "height": 340,
        "content": "## Monthly Energy Generation Report (Postgres \u2192 PDF \u2192 Email)"
      },
      "typeVersion": 1
    },
    {
      "id": "04a42081-91d1-4a4b-b21c-57e26c7343da",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -140,
        220
      ],
      "parameters": {
        "color": 2,
        "width": 1140,
        "height": 400,
        "content": "##  **Purpose**\nAutomatically generate and send a monthly energy generation report. It collects energy data from a PostgreSQL database, formats it into a PDF, and emails it to a recipient.\n\n##  **Core Logic**\n1. **Trigger**: The workflow is scheduled to run monthly via a `Schedule Trigger` node.\n2. **Data Collection**: Connects to a PostgreSQL database and fetches energy data from the `energy_data` table.\n3. **Transformation**: Uses a `Code` node to transform raw database rows into a structured JSON object with metadata like `date_range`, `note`, and `records`.\n4. **PDF Generation**: Sends the transformed JSON to the PDF.co API (`Convert data to pdf` node), which returns a downloadable report URL.\n5. **Email Delivery**: Uses the `Gmail` node to send the report link via email to a configured recipient.\n\n##  **Outcome**\n* An energy performance PDF report is automatically generated and emailed monthly.\n* Enables proactive reporting for energy production across multiple plants (solar, wind, hydro).\n* Removes manual intervention in creating recurring performance summaries."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a6822d15-47ba-4c21-8f81-355f80d534a9",
  "connections": {
    "Send Report": {
      "main": [
        []
      ]
    },
    "Transform data": {
      "main": [
        [
          {
            "node": "Convert data to pdf",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get energy data": {
      "main": [
        [
          {
            "node": "Transform data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Monthly Trigger": {
      "main": [
        [
          {
            "node": "Get energy data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert data to pdf": {
      "main": [
        [
          {
            "node": "Send Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Monthly Energy Generation Report (Postgres → PDF → Email). Uses httpRequest, gmail, postgres. Scheduled trigger; 7 nodes.

Source: https://github.com/weblineindia/n8n-Automated-monthly-energy-reports-with-PostgreSQL-PDF-email-delivery/blob/main/main.json — original creator credit. Request a take-down →

More Email & Gmail workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Email & Gmail

This workflow automates the complete end-to-end processing of daily revenue transactions for finance and accounting teams. It systematically retrieves, validates, and standardizes transaction data fro

HTTP Request, Gmail, Google Drive +2
Email & Gmail

YOUR_ID 4. Uses gmail, googleDrive, googleSheets, httpRequest. Scheduled trigger; 53 nodes.

Gmail, Google Drive, Google Sheets +1
Email & Gmail

Suspicious_login_detection. Uses postgres, httpRequest, noOp, html. Webhook trigger; 43 nodes.

Postgres, HTTP Request, Gmail +1
Email & Gmail

This n8n workflow is designed for security monitoring and incident response when suspicious login events are detected. It can be initiated either manually from within the n8n UI for testing or automat

Postgres, HTTP Request, Gmail +1
Email & Gmail

Instead of providing a routine check, it focuses on significant movements by: Sending a Slack alert only if a query crosses a defined movement threshold. Emailing a structured report with the Top 25 i

HTTP Request, Slack, Gmail