Quick Overview
This workflow runs daily at 10am, reads a marketplaces configuration file, fetches KPI statistics from marketplace APIs via HTTP requests, compiles the results into an Excel file, then posts a Slack notification and emails the file using Microsoft Outlook while also saving it to disk.
How it works
- Runs every day at 10am on a scheduled trigger.
- Reads
/home/node/.n8n-files/config/marketplaces.json from disk and parses it as JSON to get the list of marketplaces to process.
- Iterates through each marketplace entry and calls the marketplace stats endpoint with an HTTP GET request using environment-variable-based URL parts and an Authorization header.
- Extracts KPI fields from each API response (offers, orders, evaluations, grades, and various rates) and builds a consolidated metrics dataset with the current date.
- Converts the consolidated dataset into an
.xlsx file and attaches it to a Microsoft Outlook email.
- Sends a Slack message to confirm the KPI file was sent, and writes the same Excel file to
/home/node/.n8n-files/share_files/.
Setup
- Create the
marketplaces.json file at /home/node/.n8n-files/config/marketplaces.json with a data array containing each marketplace’s marketplace name plus the baseUrlEnv, endpointstatsEnv, and apiKeyEnv environment-variable keys used to build the request.
- Define the required environment variables in your n8n environment for each marketplace (base URL, stats endpoint path, and API key/token used in the
Authorization header).
- Add Microsoft Outlook OAuth2 credentials, set the recipient email address and message body in the Outlook node, and ensure attachments are allowed for your tenant.
- Add Slack OAuth2 credentials and select the target channel for the confirmation message.
- Ensure the n8n instance has read access to the config path and write access to
/home/node/.n8n-files/share_files/ if you want to save the generated Excel file.