# Export AI chat logs from PostgreSQL to Google Sheets by session
This workflow automates the export of user conversation logs from a PostgreSQL database (e.g., n8n_chat_histories) into Google Sheets, organizing data by session. Each session gets its own sheet, enabling efficient analysis and archiving. Designed for teams building AI agents on n8n.
## Who it´s for
- Teams developing AI agents on n8n
- Product managers needing access to chat logs
- Technical specialists managing chat storage in PostgreSQL
- Analysts and support teams reviewing user interactions
## What the automation does
- Runs on schedule (cron) or manually triggered
- Retrieves chat logs from a PostgreSQL table using session_id
- Creates a dedicated sheet in Google Sheets for each session_id
- Clears old data, duplicates a template sheet, and populates messages
- Includes speaker, message content, and timestamp for each entry
- Enables regular, hands-free updates without manual input
## What´s included
- Ready-to-use n8n workflow
- Trigger logic (scheduled and manual)
- Integrations with PostgreSQL, Google Sheets API, and HTTP API
- Basic setup and adaptation guide
## Requirements for setup
- Access to an n8n instance
- PostgreSQL account with read permissions to chat history table
- Google account with Google Sheets access
- Pre-created Google Spreadsheet containing a template sheet
## Benefits and outcomes
- Centralized, structured storage of all chat sessions
- Easy access for product and analytics teams
- Enables manual review of user interaction patterns
- Automated archiving with no data loss
- Supports repeatable reporting and dialogue audits
- Saves time otherwise spent on manual exports and formatting
## Important: template only
Important: you are purchasing a ready-made automation workflow template only. Rollout into your infrastructure, connecting specific accounts and services, 1:1 setup help, custom adjustments for non-standard stacks and any consulting support are provided as a separate paid service at an individual rate. To discuss custom work or 1:1 help, contact via chat
No feedback yet