feat: enhance n8n workflows with dynamic credential management and email configuration

This commit is contained in:
Lago
2026-05-10 00:52:35 +02:00
parent 05de6cc9a4
commit bd906dbe15
6 changed files with 201 additions and 58 deletions
+22 -22
View File
@@ -30,36 +30,36 @@ This folder contains exportable n8n workflow definitions for the MC Cars qualifi
## Setup Instructions
### 1. Create Postgres credential in n8n
- **Name:** `MC Cars Postgres`
- **Host:** `db`
- **Port:** `5432`
- **Database:** `postgres`
- **User:** `postgres`
- **Password:** (value of `POSTGRES_PASSWORD` from `.env`)
### 1. Configure `.env`
The stack now bootstraps n8n credentials/workflow automatically on every `docker compose up`.
### 2. Create SMTP credential in n8n
- **Name:** `MC Cars SMTP`
- **Host:** `heracles.mxrouting.net`
- **Port:** `587` (STARTTLS) or `465` (SSL/TLS)
- **User:** `office@mc-cars.at`
- **Password:** use the mailbox password provided out-of-band (do not commit secrets to git)
- **From:** `office@mc-cars.at`
Required env variables:
- `POSTGRES_PASSWORD`
- `N8N_POSTGRES_CREDENTIAL_ID`
- `N8N_POSTGRES_CREDENTIAL_NAME`
- `N8N_SMTP_CREDENTIAL_ID`
- `N8N_SMTP_CREDENTIAL_NAME`
- `N8N_SMTP_HOST`
- `N8N_SMTP_USER`
- `N8N_SMTP_PASS`
- `N8N_PAYPAL_KAUTION_LINK`
- `N8N_PAYPAL_MIETE_LINK`
- `N8N_PAYMENT_WORKFLOW_ID`
### 3. Mailbox reference (for future incoming-email workflows)
### 2. Mailbox reference (for future incoming-email workflows)
- **IMAP host:** `heracles.mxrouting.net` (port `993`, SSL/TLS)
- **POP3 host:** `heracles.mxrouting.net` (port `995`, SSL/TLS)
- **Username:** `office@mc-cars.at`
- **Password:** same mailbox password as SMTP
### 4. Import workflows
1. Open n8n at http://localhost:55590
2. Go to **Workflows****Import from file**
3. Import `01-qualification-payment-email.json`
4. Import `02-mietvertrag-pdf-email.json`
5. Open each workflow → assign the credentials created above → **Activate**
### 3. Import behavior
On startup, n8n runs `/opt/mc-cars/bootstrap/bootstrap-n8n.sh` which:
1. Creates/updates Postgres and SMTP credentials from `.env`
2. Renders `01-qualification-payment-email.json` placeholders
3. Imports the workflow so nodes are always linked to the expected credential IDs
4. Activates the payment workflow automatically (`n8n update:workflow --active=true`)
### 5. Upload Mietvertrag template (optional)
### 4. Upload Mietvertrag template (optional)
1. Open Admin panel → **Einstellungen** tab
2. Upload a DOCX file in the "Mietvertrag-Vorlage" section
3. The template should contain these placeholders: