- name
- n8n-workflows
- description
- n8n otomasyon workflow'lari. Webhook, cron trigger, API entegrasyon, CI/CD otomasyon.
# n8n Workflows
## n8n MCP Server Kurulumu
### NPM Kurulum
```bash
npm install -g n8n
n8n start # http://localhost:5678
```
### Docker Kurulum
```bash
docker run -d \
--name n8n \
-p 5678:5678 \
-v n8n_data:/home/node/.n8n \
-e N8N_BASIC_AUTH_ACTIVE=true \
-e N8N_BASIC_AUTH_USER=admin \
-e N8N_BASIC_AUTH_PASSWORD=<strong-password> \
n8nio/n8n
```
### MCP Server Config
```json
{
"mcpServers": {
"n8n": {
"command": "npx",
"args": ["-y", "@anthropic/n8n-mcp-server"],
"env": {
"N8N_API_URL": "http://localhost:5678/api/v1",
"N8N_API_KEY": "<n8n-api-key>"
}
}
}
}
```
### API Key Olusturma
```
n8n UI > Settings > API > Create API Key
Scope: workflow:read, workflow:write, execution:read
```
## Workflow Olusturma
### Temel Yapi
```json
{
"name": "My Workflow",
"nodes": [
{
"name": "Trigger",
"type": "n8n-nodes-base.webhook",
"position": [250, 300],
"parameters": {
"path": "my-webhook",
"httpMethod": "POST"
}
},
{
"name": "Process",
"type": "n8n-nodes-base.function",
"position": [450, 300],
"parameters": {
"functionCode": "return items.map(item => ({ json: { processed: true, ...item.json } }));"
}
}
],
"connections": {
"Trigger": {
"main": [[{ "node": "Process", "type": "main", "index": 0 }]]
}
}
}
```
### MCP ile Workflow Olustur
```
n8n.create_workflow({
name: "Deploy Notification",
nodes: [...],
connections: {...},
active: true
})
```
### Workflow Listele
```
n8n.list_workflows({
active: true,
tags: ["production"]
})
```
### Workflow Calistir
```
n8n.execute_workflow({
workflow_id: "123",
data: {
environment: "production",
version: "v1.2.3"
}
})
```
## Trigger Tipleri
### Webhook Trigger
```json
{
"type": "n8n-nodes-base.webhook",
"parameters": {
"path": "deploy-hook",
"httpMethod": "POST",
"authentication": "headerAuth",
"options": {
"responseMode": "responseNode",
"responseCode": 200
}
}
}
```
### Cron Trigger
```json
{
"type": "n8n-nodes-base.cron",
"parameters": {
"triggerTimes": {
"item": [
{ "mode": "everyDay", "hour": 9, "minute": 0 },
{ "mode": "custom", "cronExpression": "0 */6 * * *" }
]
}
}
}
```
### Event Trigger'lar
| Trigger | Kaynak | Kullanim |
|---------|--------|----------|
| Webhook | Dis sistem | GitHub push, Stripe payment |
| Cron | Zamanlama | Gunluk rapor, cleanup |
| Email (IMAP) | Email | Support ticket olusturma |
| RSS | Feed | Icerik izleme |
| Telegram | Bot mesaj | Komut isleme |
| GitHub | Repo event | CI/CD tetikleme |
| Slack | Mesaj/mention | Team notification |
| Database | Row change | Data sync |
### Poll Trigger
```json
{
"type": "n8n-nodes-base.pollTrigger",
"parameters": {
"pollTimes": {
"item": [{ "mode": "everyMinute", "minute": 5 }]
},
"url": "https://api.example.com/status"
}
}
```
## Node Tipleri ve Kullanimi
### HTTP Request
```json
{
"type": "n8n-nodes-base.httpRequest",
"parameters": {
"url": "https://api.example.com/data",
"method": "POST",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "httpHeaderAuth",
"sendBody": true,
"bodyParameters": {
"parameters": [
{ "name": "key", "value": "={{ $json.value }}" }
]
},
"options": {
"timeout": 10000,
"retry": { "maxRetries": 3, "retryInterval": 1000 }
}
}
}
```
### Function Node (JavaScript)
```json
{
"type": "n8n-nodes-base.function",
"parameters": {
"functionCode": "const results = [];\nfor (const item of items) {\n const data = item.json;\n results.push({\n json: {\n name: data.name.toUpperCase(),\n processed_at: new Date().toISOString()\n }\n });\n}\nreturn results;"
}
}
```
### IF Node (Kosul)
```json
{
"type": "n8n-nodes-base.if",
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.status }}",
"operation": "equal",
"value2": "success"
}
]
}
}
}
```
### Switch Node
```json
{
"type": "n8n-nodes-base.switch",
"parameters": {
"dataType": "string",
"value1": "={{ $json.priority }}",
"rules": {
"rules": [
{ "value2": "critical", "output": 0 },
{ "value2": "high", "output": 1 },
{ "value2": "low", "output": 2 }
]
}
}
}
```
### Merge Node
```json
{
"type": "n8n-nodes-base.merge",
"parameters": {
"mode": "mergeByKey",
"propertyName1": "id",
"propertyName2": "userId"
}
}
```
### Yaygin Node'lar
| Node | Amac | Ornek |
|------|------|-------|
| HTTP Request | API cagir | REST endpoint |
| Function | Kod calistir | Data transform |
| IF/Switch | Dallanma | Kosula gore yonlendir |
| Set | Data ata | Field ekle/degistir |
| Merge | Birlestir | Iki kaynak birlestir |
| Split In Batches | Parcala | Rate limiting |
| Wait | Bekle | Delay/approval |
| Error Trigger | Hata yakala | Hata notification |
| Slack | Mesaj gonder | Team bildirim |
| Gmail | Email gonder | Notification |
| Postgres/MySQL | DB islem | CRUD |
| Redis | Cache | Key-value store |
## API Entegrasyonu
### Credential Yonetimi
```
n8n UI > Settings > Credentials > New Credential
Tipler: API Key, OAuth2, Basic Auth, Header Auth
// Workflow'da kullanim
"authentication": "predefinedCredentialType",
"nodeCredentialType": "slackApi"
```
### REST API Cagirma
```json
{
"type": "n8n-nodes-base.httpRequest",
"parameters": {
"url": "https://api.github.com/repos/{{ $json.owner }}/{{ $json.repo }}/pulls",
"method": "GET",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "githubApi",
"options": {
"response": { "response": { "fullResponse": true } }
}
}
}
```
### Pagination Handling
```javascript
// Function node: paginated API cagirma
const allResults = [];
let page = 1;
let hasMore = true;
while (hasMore) {
const response = await this.helpers.httpRequest({
url: `https://api.example.com/items?page=${page}&per_page=100`,
method: 'GET',
});
allResults.push(...response.data);
hasMore = response.data.length === 100;
page++;
}
return allResults.map(item => ({ json: item }));
```
## Error Handling
### Try/Catch Pattern
```json
{
"nodes": [
{
"name": "Try",
"type": "n8n-nodes-base.httpRequest",
"continueOnFail": true,
"parameters": { "url": "https://api.example.com/data" }
},
{
"name": "Check Error",
"type": "n8n-nodes-base.if",
"parameters": {
"conditions": {
"boolean": [
{ "value1": "={{ $json.error }}", "value2": true }
]
}
}
},
{
"name": "Error Handler",
"type": "n8n-nodes-base.slack",
"parameters": {
"channel": "#alerts",
"text": "Workflow error: {{ $json.error.message }}"
}
}
]
}
```
### Error Workflow
```
n8n UI > Workflow Settings > Error Workflow
Global error handler: her basarisiz workflow bu workflow'u tetikler
Error workflow node'lari:
1. Error Trigger → hata bilgisini al
2. Function → hatayi formatla
3. Slack/Email → bildirim gonder
4. HTTP Request → incident sisteme kaydet
```
### Retry Stratejisi
```json
{
"parameters": {
"options": {
"retry": {
"maxRetries": 3,
"retryInterval": 2000,
"retryOnTimeout": true
}
}
}
}
```
## Workflow Debugging
### Execution Log
```
n8n.list_executions({
workflow_id: "123",
status: "error",
limit: 10
})
```
### Execution Detayi
```
n8n.get_execution({
execution_id: "456",
include_data: true
View on GitHub