Skip to content

Commit 490791c

Browse files
authored
Merge pull request #3000 from port-labs/PORT-n8n-vulnerability
Set up Port's n8n custom node
2 parents e2ac500 + faeb3ce commit 490791c

14 files changed

+722
-0
lines changed

docs/ai-interfaces/context-lake.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ Define your organizational semantics once—service definitions, environment typ
101101
</TabItem>
102102
</Tabs>
103103

104+
## External agents and AI workflows
105+
106+
External AI agents and automation workflows can leverage Port's Context Lake to make intelligent, context-aware decisions without needing direct access to your entire toolchain. Instead of building custom integrations for each tool, external systems can query Port's unified knowledge layer to understand your organization's structure, relationships, and standards.
107+
108+
### n8n integration
109+
110+
Port provides a custom n8n node that simplifies integration with Port's AI agents and Context Lake. To get started:
111+
112+
1. **[Set up Port's n8n custom node](/guides/all/setup-port-n8n-node)** — Install and configure the Port node in your n8n instance
113+
2. **[Build automation workflows](/guides/all/remediate-vulnerability-with-n8n-and-port)** — See an example of using Port as a context lake for vulnerability management workflows
114+
104115
## Getting started
105116

106117
Building your Context Lake is a natural part of setting up Port:

docs/guides/all/remediate-vulnerability-with-n8n-and-port.md

Lines changed: 468 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
---
2+
displayed_sidebar: null
3+
description: Install and configure Port's custom n8n node to integrate Port AI agents and workflows with n8n automation
4+
---
5+
6+
# Set up Port's n8n custom node
7+
8+
Port provides a custom n8n node (`n8n-nodes-portio`) that simplifies integration with Port's AI agents and API. Instead of making manual HTTP requests for authentication, invocation, and response retrieval, the Port node handles all of this automatically, making it easy to build powerful automation workflows that leverage Port's Context Lake.
9+
10+
This guide walks you through installing and configuring Port's custom n8n node in your n8n instance.
11+
12+
<img src='/img/guides/n8n-port-node/5-n8n-connect-port-node.png' border="1px" width="80%" />
13+
14+
## Prerequisites
15+
16+
Before you begin, ensure you have:
17+
18+
- **npm installed** — Required for installing the Port n8n node package. npm comes with Node.js, [install Node.js](https://nodejs.org/) if you don't have it.
19+
- **A working n8n instance** — Either n8n Cloud or a self-hosted instance. If you don't have one, follow n8n's [guide on using Docker](https://docs.n8n.io/hosting/installation/installation/docker/).
20+
- **Port API credentials** — Your Port `Client ID` and `Client Secret`. [Learn how to get them](/build-your-software-catalog/custom-integration/api/#find-your-port-credentials).
21+
- **A Port account with AI features enabled** — Required for using Port AI agents in your workflows.
22+
- We recommend [creating a dedicated service account](https://docs.port.io/sso-rbac/users-and-teams/manage-users-teams/#service-accounts) in Port for each workflow or agent integration. This improves security and makes it easier to manage credentials.
23+
24+
## Set up n8n instance
25+
26+
If you don't have an n8n instance running, you can set one up using Docker. The location where you mount the n8n data directory is important; this is where you will install the Port n8n node package.
27+
28+
### Using Docker (bind mount)
29+
30+
Using a bind mount allows the container to read/write directly to your local filesystem, making it easier to install and manage the Port n8n node package.
31+
32+
1. **Create a directory for n8n data** (we will call this `$n8n_HOME`):
33+
34+
```bash
35+
mkdir -p ~/n8n-data
36+
```
37+
38+
2. **Run n8n with a bind mount**:
39+
40+
```bash showLineNumbers
41+
docker volume create n8n_data
42+
43+
docker run -it --rm \
44+
--name n8n \
45+
-p 5678:5678 \
46+
-e GENERIC_TIMEZONE="Africa/Accra" \
47+
-e TZ="Africa/Accra" \
48+
-e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true \
49+
-e N8N_RUNNERS_ENABLED=true \
50+
-e N8N_COMMUNITY_PACKAGES_ENABLED=true \
51+
-v ~/n8n-data:/home/node/.n8n \
52+
docker.n8n.io/n8nio/n8n
53+
```
54+
55+
:::tip Configuration notes
56+
- The `N8N_COMMUNITY_PACKAGES_ENABLED=true` environment variable is required for n8n to load community-installed nodes like the Port n8n node.
57+
- Replace `"Africa/Accra"` with your preferred timezone. The `GENERIC_TIMEZONE` and `TZ` environment variables should match.
58+
- Replace `~/n8n-data` with the actual local path you want to use such as `/Users/janedoe/n8n-data`. Anything n8n writes to `/home/node/.n8n` (inside the container) will persist directly to your local directory.
59+
:::
60+
61+
3. **Access n8n** — Open your browser and navigate to `http://localhost:5678`.
62+
63+
### Using Docker Compose
64+
65+
If you prefer using Docker Compose, create a `docker-compose.yml` file:
66+
67+
```yaml showLineNumbers
68+
version: '3'
69+
services:
70+
n8n:
71+
image: docker.n8n.io/n8nio/n8n
72+
ports:
73+
- "5678:5678"
74+
environment:
75+
- GENERIC_TIMEZONE=Europe/Madrid
76+
- TZ=Europe/Madrid
77+
- N8N_COMMUNITY_PACKAGES_ENABLED=true
78+
volumes:
79+
- ./n8n-data:/home/node/.n8n
80+
```
81+
82+
The `N8N_COMMUNITY_PACKAGES_ENABLED=true` environment variable is required for n8n to load community-installed nodes like the Port n8n node.
83+
84+
Then run:
85+
86+
```bash showLineNumbers
87+
# Navigate to the directory containing your docker compose file
88+
cd /path/to/your/compose/file/directory
89+
90+
# Pull latest version
91+
docker compose pull
92+
93+
# Start the container
94+
docker compose up -d
95+
```
96+
97+
## Install Port's n8n node
98+
99+
Now that you have n8n running, let's install Port's custom node using npm.
100+
101+
### Install the npm package
102+
103+
1. **Navigate to your n8n data directory** (the `$n8n_HOME` directory you created earlier):
104+
105+
```bash
106+
cd ~/n8n-data
107+
```
108+
109+
2. **Install the Port n8n node package**:
110+
111+
```bash showLineNumbers
112+
mkdir -p custom
113+
cd custom
114+
npm i @port-labs/n8n-nodes-portio-experimental
115+
```
116+
117+
The package is installed in the `custom` folder in your n8n data directory (`$n8n_HOME`).
118+
119+
3. **Restart your n8n instance**:
120+
121+
- **If using Docker**: Stop the container (`Ctrl+C` or `docker stop n8n`) and start it again with the same command.
122+
- **If using Docker Compose**: Run `docker compose restart`.
123+
124+
:::caution Restart required
125+
n8n needs to be restarted after installing community packages so it can discover and load them. Make sure `N8N_COMMUNITY_PACKAGES_ENABLED=true` is set in your Docker configuration.
126+
:::
127+
128+
The Port n8n node package is available on npm at [@port-labs/n8n-nodes-portio-experimental](https://www.npmjs.com/package/@port-labs/n8n-nodes-portio-experimental). The package is currently in experimental status.
129+
130+
## Quick start
131+
132+
Now that the Port node is installed, let us verify it works by creating a simple workflow.
133+
134+
### Add a Port node to your workflow
135+
136+
1. **Create a new workflow** in your n8n instance.
137+
138+
<img src='/img/guides/n8n-port-node/1-n8n-create-workflow-button.png' border="1px" width="100%" />
139+
140+
2. **Add a trigger** — For testing, add a **Manual Trigger** node so you can trigger the workflow manually by clicking the **Execute Workflow** button.
141+
142+
<img src='/img/guides/n8n-port-node/2-n8n-manual-trigger-workflow.png' border="1px" width="60%" />
143+
144+
3. **Add the Port node**:
145+
- Click the **+** button on the left side of the screen to add a new node
146+
- Search for `port` in the node search
147+
148+
<img src='/img/guides/n8n-port-node/3-n8n-search-port-node.png' border="1px" width="50%" />
149+
150+
4. **Select a Port node** — Click the "Port.io" search result and select "General Purpose AI Interaction" (this is the easiest one to test with).
151+
152+
<img src='/img/guides/n8n-port-node/4-n8n-general-node.png' border="1px" width="50%" />
153+
154+
5. **Connect the nodes** — Drag from the **+** icon on the trigger node to the left side of the Port AI node to connect them.
155+
156+
<img src='/img/guides/n8n-port-node/5-n8n-connect-port-node.png' border="1px" width="70%" />
157+
158+
:::tip Success!
159+
You have successfully deployed your first Port n8n node! The node is now available in your n8n instance.
160+
:::
161+
162+
### Configure Port credentials
163+
164+
Before you can use the Port node, you need to add your Port API credentials.
165+
166+
1. **Open the Port node** — Double-click the Port AI node you just added.
167+
168+
2. **Create a new credential**:
169+
- At the top of the node configuration, you will see a dropdown named `Credential to connect with`
170+
- Click this dropdown and select `Create new credential`
171+
172+
3. **Enter your Port credentials**:
173+
- **Client ID** — Your Port Client ID
174+
- **Client Secret** — Your Port Client Secret
175+
176+
<img src='/img/guides/n8n-port-node/6-n8n-port-credentials.png' border="1px" width="50%" />
177+
178+
If you're not sure how to get your Port credentials, see the [Port API documentation](/build-your-software-catalog/custom-integration/api/#find-your-port-credentials).
179+
180+
4. **Save the credential** — Click "Save" to store the credential.
181+
182+
You can store multiple Port account credentials in n8n and select which one to use for each node. This is useful if you work with multiple Port organizations.
183+
184+
## Verify the installation
185+
186+
To verify everything is working:
187+
188+
1. **Configure the Port node** — In the **General Purpose AI Interaction** node:
189+
- Select your Port credential from the dropdown
190+
- Enter a simple prompt like "List all ec2 instances in the eu-west region"
191+
- Save the node
192+
<img src='/img/guides/n8n-port-node/7-n8n-example-question.png' border="1px" width="50%" />
193+
194+
2. **Execute the workflow** — Click **Execute Workflow** to test the connection.
195+
196+
3. **Check the output** — If successful, you should see the AI response in the node output.
197+
198+
## What's next?
199+
200+
Now that you have Port's n8n node installed and configured, you can:
201+
202+
- **Build automation workflows** — Use Port's Context Lake to enrich your n8n workflows with organizational context
203+
- **Integrate with AI agents** — Invoke Port AI agents from n8n workflows
204+
- **Query the catalog** — Access service metadata, ownership, dependencies, and more
205+
206+
## Related guides
207+
208+
- [Remediate security vulnerability with n8n and Port AI](/guides/all/remediate-vulnerability-with-n8n-and-port) — Example workflow using Port as a context lake for vulnerability management
209+
- [Port n8n nodes repository](https://github.com/port-labs/port-n8n-nodes) — Source code and detailed documentation for the Port n8n nodes
210+
211+
## Troubleshooting
212+
213+
### Node not appearing in n8n
214+
215+
- **Check package installation** — Verify that `npm i @port-labs/n8n-nodes-portio-experimental` completed successfully. Check for a `node_modules` directory in your `$n8n_HOME` directory.
216+
- **Verify environment variable** — Ensure `N8N_COMMUNITY_PACKAGES_ENABLED=true` is set in your Docker configuration
217+
- **Check installation location** — Make sure the package is installed in the same directory that's mounted to `/home/node/.n8n` in the Docker container
218+
- **Restart n8n** — Community packages are only loaded when n8n starts, so a restart is required after installation
219+
220+
### Credential errors
221+
222+
- **Verify credentials** — Double-check that your Client ID and Client Secret are correct
223+
- **Check AI features** — Ensure your Port account has AI features enabled
224+
- **Test API access** — Try making a direct API call to verify your credentials work
225+

src/components/guides-section/consts.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const tagsCategoryMap = {
1313
"BitBucket",
1414
"AzureDevops",
1515
"Claude Code",
16+
"n8n",
1617
"Azure",
1718
"Webhook",
1819
"Kafka",
@@ -1535,6 +1536,20 @@ export const availableGuides = [
15351536
tags: ["Self Healing Incidents", "AI", "Jira", "PagerDuty", "Slack"],
15361537
logos: ["Jira", "PagerDuty", "Slack"],
15371538
link: "/guides/all/orchestrate-incident-response-with-ai",
1539+
},
1540+
{
1541+
title: "Remediate security vulnerability with n8n and Port AI",
1542+
description: "Remediate security vulnerabilities with n8n and Port AI using Port's AI agents and automations",
1543+
tags: ["Security", "n8n", "Slack", "AI"],
1544+
logos: ["n8n", "Slack", "AI"],
1545+
link: "/guides/all/remediate-vulnerability-with-n8n-and-port",
1546+
},
1547+
{
1548+
title: "Setup Port's n8n custom node",
1549+
description: "Setup Port's n8n custom node to integrate Port's AI agents and Context Lake with n8n workflows",
1550+
tags: ["n8n", "AI"],
1551+
logos: ["n8n", "AI"],
1552+
link: "/guides/all/setup-port-n8n-node",
15381553
}
15391554
]
15401555

static/img/guides/icons/n8n.svg

Lines changed: 3 additions & 0 deletions
Loading
135 KB
Loading
54.9 KB
Loading
56 KB
Loading
50.3 KB
Loading
52.6 KB
Loading

0 commit comments

Comments
 (0)