Analyze Seoul air pollution with MotherDuck and Ollama Qwen2.5
Go to WorkflowDescription
Quick overview
This workflow exposes a webhook that queries PM10 air pollution data from a MotherDuck database, sends the results to a local Ollama (qwen2.5:3b) model for analysis, and returns an HTML report showing the top polluted Seoul districts and the AI-generated findings.
How it works
Receives a request on a webhook endpoint.
Queries MotherDuck via its MCP API to calculate the top 10 Seoul monitoring districts by average PM10, including maximum PM10 values.
Sends the summarized PM10 results to a local Ollama /api/generate endpoint to produce a four-sentence air-quality analysis against the WHO PM10 guideline (50 μg/m³).
Extracts the model’s response text and injects it into a preformatted HTML page.
Returns the HTML report to the webhook caller as the HTTP response.
Setup
Create a MotherDuck API bearer token in n8n and ensure the air_pollution database and referenced tables/columns exist for the provided SQL query.
Run Ollama where n8n can reach http://ollama:11434 and pull the qwen2.5:3b model (or update the model name and URL in the request).
Copy the webhook URL from n8n and call the /air-quality endpoint from your browser or monitoring system to render the report.