Convert PostgreSQL table to CSV
Convert PostgreSQL table to CSV
CSV is a super useful and universal way to transfer data between different tools. This workflow gives an example of how to take data from PostgreSQL and convert it easily into a CSV.
What you need
Before running the workflow, please make sure you have access to a remote PostgreSQL server and have table data:
book_title,book_author,read_date
Demons,Fyodor Dostoyevsky,2022-09-08
Ulysses,James Joyce,2022-05-06
Catch-22,Joseph Heller,2023-01-04
The Bell Jar,Sylvia Plath,2023-01-21
Frankenstein,Mary Shelley,2023-02-14
How it works
- Trigger the workflow on click
- Declare the name of the Excel file and sheet names
- Remotely connect to the PostgreSQL database and specify query execution
- Write the query data to CSV
The detailed process is explained further in the tutorial: https://blog.n8n.io/postgres-export-to-csv/
Convert PostgreSQL Table to CSV
This n8n workflow provides a simple, manual way to extract data from a PostgreSQL database and convert it into a spreadsheet file (like CSV). It's ideal for quick data exports or generating reports from your database without writing custom scripts.
What it does
This workflow performs the following steps:
- Manual Trigger: The workflow starts when you manually click 'Execute workflow' in the n8n editor.
- Query PostgreSQL: It connects to a configured PostgreSQL database and executes a query to retrieve data.
- Edit Fields: The retrieved data is then passed to an "Edit Fields (Set)" node, allowing for potential transformation or selection of specific fields before conversion.
- Convert to Spreadsheet File: Finally, the processed data is converted into a spreadsheet file format (e.g., CSV) which can then be downloaded or further processed.
Prerequisites/Requirements
- n8n Instance: A running instance of n8n.
- PostgreSQL Database: Access to a PostgreSQL database with the necessary connection details (host, port, database name, user, password).
- PostgreSQL Credentials: You will need to set up a PostgreSQL credential in your n8n instance.
Setup/Usage
- Import the Workflow:
- Copy the provided JSON code.
- In your n8n instance, go to "Workflows" and click "New".
- Click on the three dots menu (
...) and select "Import from JSON". - Paste the JSON code and click "Import".
- Configure PostgreSQL Node:
- Locate the "Postgres" node (ID: 30).
- Click on it to open its settings.
- Under "Credentials", select your existing PostgreSQL credential or create a new one by clicking "Create New".
- Configure the "Operation" (e.g.,
Read) and "Table" or "Query" to specify which data you want to retrieve. For example, you might use aSELECT * FROM your_table;query.
- Configure Edit Fields (Set) Node (Optional):
- Locate the "Edit Fields (Set)" node (ID: 38).
- This node is currently a placeholder. You can configure it to:
Keep Only: Specify which fields from the PostgreSQL output you want to retain.Remove: Specify fields to remove.Rename: Rename fields.Set: Add new fields or modify existing ones using expressions.
- If no transformations are needed, you can leave it as is or remove it.
- Configure Spreadsheet File Node:
- Locate the "Spreadsheet File" node (ID: 41).
- Ensure the "File Format" is set to your desired output (e.g.,
CSV). - You can also configure options like "Delimiter" for CSV files.
- Execute the Workflow:
- Click on the "When clicking βExecute workflowβ" (Manual Trigger) node.
- Click the "Execute Workflow" button in the top right corner of the n8n editor.
- After execution, the "Spreadsheet File" node will output the generated file data, which you can then download from the node's output.
Related Templates
Daily news digest & weekly trends with AI filtering, Slack & Google Sheets
Who is this for This template is perfect for: Market Researchers tracking industry trends. Tech Teams wanting to stay updated on specific technologies (e.g., "AI", "Cybersecurity"). Content Creators looking for curated news topics. Busy Professionals who need a high-signal, low-noise news digest. What it does Fetches News: Pulls daily articles via NewsAPI based on your chosen keyword (default: "technology"). AI Filtering: Uses an AI Agent (via OpenRouter) to filter out low-quality or irrelevant clickbait. Daily Digest (Slack): Summarizes the top 3 articles in English. Translates the summaries to Japanese using DeepL (optional). Posts both versions to a Slack channel. Data Archiving (Sheets): Extracts structured data (Title, Author, Summary, URL) and saves it to Google Sheets. Weekly Trend Report: Every Monday, it reads the past week's data from Google Sheets and uses AI to generate a high-level trend report and strategic insights. How to set up Configure Credentials: You will need API keys/auth for NewsAPI, OpenRouter (or OpenAI), DeepL, Google Sheets, and Slack. Setup Google Sheet: Create a sheet with the following headers in the first row: title, author, summary, url. Map the Sheet: In the "Append row in sheet" and "Read sheet (weekly)" nodes, select your file and map the columns. Define Keyword: Open the "Set Keyword" node and change chatInput to the topic you want to track (e.g., "Crypto", "SaaS", "Climate Change"). Slack Setup: Select your desired channel in the Slack nodes. Requirements n8n (Self-hosted or Cloud) NewsAPI Key (Free tier available) OpenRouter (or any LangChain compatible Chat Model like OpenAI) DeepL API Key (for translation) Google Sheets account Slack Workspace How to customize Change the Language: Remove the DeepL node if you only want English, or change the target language code. Adjust the Prompt: Modify the "AI Agent (Filter)" system message to change how strict the news filtering is. Change Schedule: Adjust the Cron nodes to run at your preferred time (currently set to Daily 8 AM and Weekly Monday 9 AM).
Generate verified job offer letters with OpenAI, Gmail and Slack
π AI-Powered Verified Job Offer Letter Generator Description Creating job offer letters manually is time-consuming, error-prone, and difficult to scale. This AI-powered workflow automates the entire job offer letter process β from validating candidate emails to generating and delivering professional PDF offer letters. This intelligent workflow eliminates repetitive drafting, reduces human errors, and ensures offer letters are sent only to verified email addresses, helping HR teams move faster while maintaining professionalism and accuracy. --- What This Workflow Does Transforms manual offer letter creation into a seamless, automated HR process: π Capture Candidate & Job Details β Receives candidate name, email, job role, salary, joining date, and company details via webhook or form. π§ Email Verification β Validates the candidateβs email address before sending any communication to prevent delivery errors. π§ AI-Powered Offer Letter Generation β Uses AI to generate a clear, professional, and structured job offer letter. π HTML Offer Letter Formatting β Converts the AI-generated content into a clean and readable HTML layout. π PDF Generation β Automatically converts the offer letter into a professional PDF document. π§ Offer Letter Delivery β Sends the PDF offer letter directly to the verified candidate email. ποΈ Document Storage β Saves a copy of the offer letter for internal records and future reference. π Confirmation Response β Returns a success response confirming completion. --- Key Features π€ AI Offer Letter Writing β Generates professional, ready-to-send offer letters automatically. π§ Email Verification Built-In β Ensures offer letters are only sent to valid email addresses. π PDF Generation β Creates clean, official-looking offer letters. βοΈ End-to-End Automation β No manual drafting, formatting, or sending required. π Centralized Record Keeping β Keeps copies of all generated offer letters. π Flexible Triggering β Can be triggered from HR systems, forms, or internal tools. --- Perfect For π’ HR & Recruitment Teams β Automate offer letter creation and delivery. π Startups & Growing Companies β Send professional offer letters without extra admin work. π« Staffing & Hiring Agencies β Generate offer letters quickly for multiple candidates. π» Remote & Distributed Teams β Ensure consistent communication across locations. π§ Operations Teams β Maintain accurate records and reduce manual errors. --- What Youβll Need Required Integrations π Webhook Trigger β Receives candidate and job details. π€ OpenAI β Generates offer letter content. π§ VerifyEmail β Validates candidate email addresses. π HTMLCSS to PDF β Converts HTML into PDF offer letters. π§ Gmail β Sends the offer letter email. βοΈ Google Drive (optional) β Stores generated offer letters. --- Optional Enhancements π¨ Brand Customization β Add company logo, colors, and formatting to offer letters. π§Ύ HR System Integration β Connect with ATS or HR tools for automatic triggering. π Multilingual Offer Letters β Generate offer letters in different languages. π Approval Step β Add internal approval before sending offer letters. π Audit Logging β Store offer letter data in Google Sheets or databases. π Additional Attachments β Include policies or onboarding documents with the offer letter. --- Quick Start 1οΈβ£ Import the workflow template into your n8n workspace 2οΈβ£ Connect credentials for OpenAI, VerifyEmail, Gmail, and HTMLCSS to PDF 3οΈβ£ Send test candidate data to the webhook 4οΈβ£ Review the generated PDF offer letter 5οΈβ£ Activate the workflow and start sending offer letters automatically --- Customization Options 1οΈβ£ Offer Letter Tone β Adjust AI prompt for formal or friendly tone. 2οΈβ£ Company Branding β Customize HTML layout and styling. 3οΈβ£ Email Content β Modify subject line and email message. 4οΈβ£ PDF Layout β Adjust spacing, fonts, and structure. 5οΈβ£ Storage Location β Change where offer letters are saved. 6οΈβ£ Validation Rules β Extend email or input checks. --- Expected Results β‘ Faster Hiring Process β Generate offer letters in minutes. π€ Consistent Quality β Every offer letter follows a professional format. π§ Error-Free Delivery β Verified emails reduce failed communication. ποΈ Organized Records β All offer letters stored automatically. π’ Professional Candidate Experience β Clean, official documents every time. --- Workflow Structure Visualization π Candidate & Job Details β π§ Email Verification β π§ AI Offer Letter Generation β π HTML Formatting β π PDF Conversion β π§ Email Delivery β π Confirmation Response --- π Ready to Automate Job Offer Letters? Import this template today and let AI handle offer letter creation, verification, and delivery β so your team can focus on hiring the right talent faster. β¨ ---
WhatsApp group chat with your vector database β no Facebook Business required
Enable smart, real-time answers in your WhatsApp groups using a custom webhook, Pinecone vector database, and no Facebook Business setup. > π‘ Note: This template uses a custom WhatsApp webhook. It does not use the official WhatsApp Business API. --- π₯ Who is this for? This workflow is designed for individuals and teams who want to enable smart WhatsApp group automation β without going through Metaβs official WhatsApp Business API. Ideal for small businesses, internal teams, communities, and personal power users. --- β What problem is this solving? Setting up WhatsApp bots with intelligent responses often requires approval from Meta and a verified business account. This workflow removes those barriers by using a self-hosted webhook to handle incoming messages and respond using a document-trained AI via Pinecone. --- βοΈ What this workflow does Connects a regular WhatsApp number to a custom webhook Adds the bot to any group chat (it stays silent unless mentioned) Indexes documents from Google Drive into Pinecone Responds with intelligent, context-aware answers from your custom knowledge base Auto-updates its knowledge every minute as the document changes --- π οΈ Setup Step 1: Connect Google Drive Set up your Google Drive credentials in n8n Step 2: Configure Pinecone Create an index in Pinecone Dimension: 1536 Select this index in both Pinecone nodes Click Test Workflow to ingest your document into Pinecone Step 3: Get Access to the WhatsApp Webhook Fill out this form to request access Youβll receive a WhatsApp confirmation for linking Step 4: Test WhatsApp Integration β One-on-one test: Send a message from another number π₯ Group test: Add the bot to a group; it will only respond when tagged --- π§© How to customize this workflow Modify the system prompt inside the AI agent node to control tone and behavior Update the connected Google Doc to match your specific domain (e.g. FAQs, SOPs, product manuals) Adjust the Pinecone sync frequency if you want updates more or less often --- π Use cases Customer Support: Instant, intelligent replies in WhatsApp without live agents Team Knowledge Bot: Tag the bot for quick access to SOPs and internal docs Community Groups: Automate common questions while keeping noise low Personal AI Assistant: A WhatsApp chatbot trained on your notes and files --- π Sticky Note Suggestion π¬ What this template does: > Enables an AI bot in your WhatsApp group that answers questions based on a Google Doc you provide. It uses a custom webhook, Google Drive, and Pinecone. π§ Requirements: > Google Drive account > Pinecone account with an index (dimension 1536) > Access to the custom WhatsApp webhook (see setup steps)