Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ The E2B node uses n8n's resource and operation layout:
- Snapshot: Create, Get Many, Delete
- Volume: Create, Get, Get Many, Delete

## Examples

Importable example workflows live in [`docs/examples/`](./docs/examples):

Ordered simplest → most advanced (Level 1–4):

- **Level 1** — [`1-run-command-ephemeral.json`](./docs/examples/1-run-command-ephemeral.json) — run a command in a one-shot ephemeral sandbox (the simplest flow).
- **Level 2** — [`2-web-app-with-preview.json`](./docs/examples/2-web-app-with-preview.json) — write and start a web server, return a preview URL.
- **Level 3** — [`3-clone-build-download.json`](./docs/examples/3-clone-build-download.json) — clone a repo, run a build, download the artifact back into n8n.
- **Level 4** — [`4-ai-agent-tool.json`](./docs/examples/4-ai-agent-tool.json) — an AI Agent that runs code in E2B as a tool.

In n8n: **Workflows → Import from File**, select a JSON, then set your **E2B API** credential. See [`docs/examples/README.md`](./docs/examples/README.md) for details.

## Development

```bash
Expand Down
98 changes: 98 additions & 0 deletions docs/examples/1-run-command-ephemeral.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"name": "E2B · Level 1 — Run a command (ephemeral sandbox)",
"nodes": [
{
"parameters": {
"content": "## E2B — Run one command, throwaway sandbox\n\nThe simplest E2B pattern: leave **Sandbox ID** empty and enable **Kill After Run** — a single node creates a sandbox, runs the command, and destroys it. No lifecycle to manage.\n\n### Setup\n1. Add an **E2B API** credential (key at e2b.dev/dashboard) to the E2B node.",
"height": 340,
"width": 460,
"color": "#CE2601"
},
"id": "aaaa0000-0000-0000-0000-0000000000a1",
"name": "About & setup",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-380,
120
]
},
{
"parameters": {
"content": "### How to run\nClick **Test workflow** — the node output shows the command's `stdout` (a hello from Python inside the sandbox).\n\nNothing to clean up: the sandbox is killed automatically after the run.",
"height": 200,
"width": 460,
"color": 7
},
"id": "cccc0000-0000-0000-0000-0000000000c1",
"name": "How to run",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-380,
480
]
},
{
"parameters": {},
"id": "11111111-1111-1111-1111-111111111111",
"name": "When clicking 'Test workflow'",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
240,
320
]
},
{
"parameters": {
"resource": "code",
"operation": "runCommand",
"sandboxId": "",
"command": "python3 -c \"import platform, sys; print(f'Python {sys.version_info.major}.{sys.version_info.minor} on {platform.system()}'); print('Hello from an E2B sandbox!')\"",
"allowInternetAccess": true,
"killAfterRun": true
},
"id": "22222222-2222-2222-2222-222222222222",
"name": "Run Command (Ephemeral)",
"type": "@e2b/n8n-nodes-e2b.e2b",
"typeVersion": 1,
"position": [
520,
320
],
"credentials": {
"e2bApi": {
"id": "REPLACE_WITH_YOUR_CREDENTIAL_ID",
"name": "E2B API account"
}
}
}
],
"connections": {
"When clicking 'Test workflow'": {
"main": [
[
{
"node": "Run Command (Ephemeral)",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"tags": [
{
"name": "e2b-example",
"id": "e2b-example"
}
],
"meta": {
"templateCredsSetupCompleted": false
}
}
197 changes: 197 additions & 0 deletions docs/examples/2-web-app-with-preview.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
{
"name": "E2B · Level 2 — Run a web app and return a preview URL",
"nodes": [
{
"parameters": {
"content": "## E2B — Web app with a public preview URL\n\nCreate a sandbox → **write** a tiny Python web server → start it on **port 3000** → return a public **preview URL**. Shows how to expose a running service from a sandbox to the internet.\n\n### Setup\n1. Add an **E2B API** credential (key at e2b.dev/dashboard) to every E2B node.",
"height": 360,
"width": 460,
"color": "#CE2601"
},
"id": "aaaa0000-0000-0000-0000-0000000000a2",
"name": "About & setup",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-380,
120
]
},
{
"parameters": {
"content": "### How to run\nClick **Test workflow**, then open the `url` from the **Get Preview URL** output in your browser — the page is served live from the sandbox.\n\nThe sandbox (and the server) stays up until its timeout expires, then it is cleaned up automatically.",
"height": 220,
"width": 460,
"color": 7
},
"id": "cccc0000-0000-0000-0000-0000000000c2",
"name": "How to run",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-380,
500
]
},
{
"parameters": {},
"id": "11111111-1111-1111-1111-111111111111",
"name": "When clicking 'Test workflow'",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
200,
320
]
},
{
"parameters": {
"resource": "sandbox",
"operation": "create",
"template": "",
"allowInternetAccess": true
},
"id": "22222222-2222-2222-2222-222222222222",
"name": "Create Sandbox",
"type": "@e2b/n8n-nodes-e2b.e2b",
"typeVersion": 1,
"position": [
440,
320
],
"credentials": {
"e2bApi": {
"id": "REPLACE_WITH_YOUR_CREDENTIAL_ID",
"name": "E2B API account"
}
}
},
{
"parameters": {
"resource": "file",
"operation": "write",
"sandboxId": "={{ $json.sandboxId }}",
"path": "/home/user/server.py",
"content": "from http.server import HTTPServer, BaseHTTPRequestHandler\n\nclass Handler(BaseHTTPRequestHandler):\n def do_GET(self):\n self.send_response(200)\n self.send_header('Content-Type', 'text/html')\n self.end_headers()\n self.wfile.write(b'<h1>Hello from an E2B sandbox!</h1>')\n\nHTTPServer(('0.0.0.0', 3000), Handler).serve_forever()\n"
},
"id": "33333333-3333-3333-3333-333333333333",
"name": "Write Server File",
"type": "@e2b/n8n-nodes-e2b.e2b",
"typeVersion": 1,
"position": [
680,
320
],
"credentials": {
"e2bApi": {
"id": "REPLACE_WITH_YOUR_CREDENTIAL_ID",
"name": "E2B API account"
}
}
},
{
"parameters": {
"resource": "code",
"operation": "runCommand",
"sandboxId": "={{ $('Create Sandbox').item.json.sandboxId }}",
"command": "nohup python3 /home/user/server.py > /tmp/server.log 2>&1 & sleep 1 && echo 'Server started on port 3000'",
"allowInternetAccess": true
},
"id": "44444444-4444-4444-4444-444444444444",
"name": "Start Web Server",
"type": "@e2b/n8n-nodes-e2b.e2b",
"typeVersion": 1,
"position": [
920,
320
],
"credentials": {
"e2bApi": {
"id": "REPLACE_WITH_YOUR_CREDENTIAL_ID",
"name": "E2B API account"
}
}
},
{
"parameters": {
"resource": "sandbox",
"operation": "getPreviewUrl",
"sandboxId": "={{ $('Create Sandbox').item.json.sandboxId }}",
"port": 3000
},
"id": "55555555-5555-5555-5555-555555555555",
"name": "Get Preview URL",
"type": "@e2b/n8n-nodes-e2b.e2b",
"typeVersion": 1,
"position": [
1160,
320
],
"credentials": {
"e2bApi": {
"id": "REPLACE_WITH_YOUR_CREDENTIAL_ID",
"name": "E2B API account"
}
}
}
],
"connections": {
"When clicking 'Test workflow'": {
"main": [
[
{
"node": "Create Sandbox",
"type": "main",
"index": 0
}
]
]
},
"Create Sandbox": {
"main": [
[
{
"node": "Write Server File",
"type": "main",
"index": 0
}
]
]
},
"Write Server File": {
"main": [
[
{
"node": "Start Web Server",
"type": "main",
"index": 0
}
]
]
},
"Start Web Server": {
"main": [
[
{
"node": "Get Preview URL",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"tags": [
{
"name": "e2b-example",
"id": "e2b-example"
}
],
"meta": {
"templateCredsSetupCompleted": false
}
}
Loading
Loading