Cara Integrasi OpenClaw
dengan Tool Server (Shell, Script, dan API)

Connect everything: dari shell commands, custom scripts, sampai external APIs.

± 40 menit baca SufaNet
OpenClaw Server Integration

Pendahuluan

OpenClaw powerful karena dia ga kerja sendiri. Dia bisa integrate dengan hampir semua tool dan service yang ada di server kamu: dari shell commands basic, custom scripts Python/Node.js, REST APIs, database, message queues, sampai cloud services kayak AWS dan Google Cloud.

Artikel ini akan bahas cara mengintegrasikan OpenClaw dengan berbagai tool server secara praktis dan production-ready. Setiap integration dijelaskan dengan contoh konkret yang bisa langsung kamu pakai.

💡 Note: Integration yang fleksibel adalah kunci automation yang powerfull. Dengan OpenClaw sebagai orchestrator, kamu bisa connect tool-tool yang tadinya isolated jadi satu workflow unified.

Shell Command Integration

Integration paling dasar dan powerful: execute shell commands langsung dari OpenClaw.

1. Basic Shell Execution

{
  "name": "system-info",
  "actions": [
    {
      "type": "shell",
      "command": "uname -a",
      "output": "os_info"
    },
    {
      "type": "shell",
      "command": "df -h | grep /dev/",
      "output": "disk_info"
    },
    {
      "type": "notification",
      "message": "OS: {{os_info}}\nDisk: {{disk_info}}"
    }
  ]
}

2. Piping dan Advanced Commands

{
  "name": "find-large-files",
  "actions": [
    {
      "type": "shell",
      "command": "find /var/www -type f -size +100M | sort -rh | head -10",
      "output": "large_files"
    },
    {
      "type": "ai-analyze",
      "prompt": "Analyze these large files and suggest which can be deleted or compressed",
      "input": "{{large_files}}"
    }
  ]
}

3. Environment Variables

{
  "name": "backup-with-env",
  "actions": [
    {
      "type": "shell",
      "command": "mysqldump -u $DB_USER -p$DB_PASS $DB_NAME > /backup/db.sql",
      "env": {
        "DB_USER": "${DATABASE_USER}",
        "DB_PASS": "${DATABASE_PASSWORD}",
        "DB_NAME": "production"
      },
      "timeout": 300000
    }
  ]
}

4. Error Handling

{
  "name": "safe-shell-exec",
  "actions": [
    {
      "type": "shell",
      "command": "systemctl restart nginx",
      "onError": {
        "retry": 3,
        "retryDelay": 5000,
        "fallback": [
          {
            "type": "shell",
            "command": "journalctl -u nginx -n 50",
            "output": "nginx_logs"
          },
          {
            "type": "notification",
            "message": "Nginx restart failed:\n{{nginx_logs}}"
          }
        ]
      }
    }
  ]
}

Python Script Integration

Execute Python scripts dengan input/output handling yang rapi.

1. Execute Python Script

Buat script Python:

nano ~/scripts/data-processor.py
#!/usr/bin/env python3
import sys
import json

def process_data(input_data):
    # Process your data here
    result = {
        "processed": True,
        "count": len(input_data.split('\n')),
        "summary": "Data processed successfully"
    }
    return result

if __name__ == "__main__":
    input_data = sys.stdin.read() if not sys.stdin.isatty() else ""
    result = process_data(input_data)
    print(json.dumps(result))

OpenClaw task:

{
  "name": "run-python-processor",
  "actions": [
    {
      "type": "shell",
      "command": "cat /data/input.txt",
      "output": "input_data"
    },
    {
      "type": "python",
      "script": "/home/user/scripts/data-processor.py",
      "input": "{{input_data}}",
      "output": "result"
    },
    {
      "type": "notification",
      "message": "Processing result: {{result.summary}}"
    }
  ]
}

2. Python dengan Arguments

{
  "name": "python-with-args",
  "actions": [
    {
      "type": "python",
      "script": "/home/user/scripts/analyzer.py",
      "args": ["--mode", "full", "--output", "/tmp/report.json"],
      "timeout": 60000
    }
  ]
}

3. Virtual Environment Support

{
  "name": "python-with-venv",
  "actions": [
    {
      "type": "shell",
      "command": "source /home/user/venv/bin/activate && python /home/user/scripts/ml-model.py",
      "timeout": 300000
    }
  ]
}

Node.js Script Integration

1. Execute Node.js Script

Buat Node.js script:

nano ~/scripts/api-caller.js
#!/usr/bin/env node
const axios = require('axios');

async function main() {
  const apiUrl = process.argv[2];
  const response = await axios.get(apiUrl);
  
  console.log(JSON.stringify({
    status: response.status,
    data: response.data,
    timestamp: new Date().toISOString()
  }));
}

main().catch(err => {
  console.error(JSON.stringify({ error: err.message }));
  process.exit(1);
});

OpenClaw task:

{
  "name": "call-api-via-nodejs",
  "actions": [
    {
      "type": "nodejs",
      "script": "/home/user/scripts/api-caller.js",
      "args": ["https://api.example.com/data"],
      "output": "api_response"
    },
    {
      "type": "ai-process",
      "prompt": "Summarize this API response",
      "input": "{{api_response.data}}"
    }
  ]
}

REST API Integration

1. GET Request

{
  "name": "fetch-api-data",
  "actions": [
    {
      "type": "http",
      "method": "GET",
      "url": "https://api.github.com/repos/openai/gpt-4",
      "headers": {
        "Authorization": "token ${GITHUB_TOKEN}",
        "Accept": "application/vnd.github.v3+json"
      },
      "output": "repo_data"
    },
    {
      "type": "notification",
      "message": "Stars: {{repo_data.stargazers_count}}"
    }
  ]
}

2. POST Request dengan JSON Body

{
  "name": "create-issue",
  "actions": [
    {
      "type": "http",
      "method": "POST",
      "url": "https://api.github.com/repos/owner/repo/issues",
      "headers": {
        "Authorization": "token ${GITHUB_TOKEN}",
        "Content-Type": "application/json"
      },
      "body": {
        "title": "Automated issue from OpenClaw",
        "body": "This issue was created automatically",
        "labels": ["automation", "openclaw"]
      },
      "output": "issue"
    }
  ]
}

3. Webhook Trigger External API

{
  "name": "trigger-deployment",
  "trigger": "webhook",
  "actions": [
    {
      "type": "http",
      "method": "POST",
      "url": "https://api.vercel.com/v1/integrations/deploy",
      "headers": {
        "Authorization": "Bearer ${VERCEL_TOKEN}"
      },
      "body": {
        "name": "my-project",
        "gitSource": {
          "type": "github",
          "ref": "main"
        }
      }
    }
  ]
}

4. GraphQL Query

{
  "name": "graphql-query",
  "actions": [
    {
      "type": "http",
      "method": "POST",
      "url": "https://api.github.com/graphql",
      "headers": {
        "Authorization": "bearer ${GITHUB_TOKEN}",
        "Content-Type": "application/json"
      },
      "body": {
        "query": "query { viewer { login repositories(first: 10) { nodes { name stargazers { totalCount } } } } }"
      },
      "output": "graphql_response"
    }
  ]
}

Database Integration

1. MySQL/MariaDB

{
  "name": "database-query",
  "actions": [
    {
      "type": "database",
      "driver": "mysql",
      "connection": {
        "host": "localhost",
        "user": "${DB_USER}",
        "password": "${DB_PASS}",
        "database": "myapp"
      },
      "query": "SELECT * FROM users WHERE created_at > DATE_SUB(NOW(), INTERVAL 24 HOUR)",
      "output": "new_users"
    },
    {
      "type": "ai-analyze",
      "prompt": "Analyze these new user signups and identify trends",
      "input": "{{new_users}}"
    }
  ]
}

2. PostgreSQL

{
  "name": "postgres-query",
  "actions": [
    {
      "type": "database",
      "driver": "postgresql",
      "connection": {
        "host": "localhost",
        "port": 5432,
        "user": "${PG_USER}",
        "password": "${PG_PASS}",
        "database": "analytics"
      },
      "query": "SELECT date_trunc('day', created_at) as date, COUNT(*) as count FROM events WHERE created_at > NOW() - INTERVAL '7 days' GROUP BY date",
      "output": "event_stats"
    }
  ]
}

3. MongoDB

{
  "name": "mongodb-query",
  "actions": [
    {
      "type": "database",
      "driver": "mongodb",
      "connection": {
        "url": "${MONGODB_URL}",
        "database": "myapp"
      },
      "collection": "logs",
      "operation": "find",
      "filter": {
        "level": "error",
        "timestamp": {
          "$gte": "{{yesterday}}"
        }
      },
      "output": "error_logs"
    }
  ]
}

4. Redis

{
  "name": "redis-cache",
  "actions": [
    {
      "type": "redis",
      "connection": {
        "host": "localhost",
        "port": 6379,
        "password": "${REDIS_PASS}"
      },
      "command": "GET",
      "key": "api:response:{{endpoint}}",
      "output": "cached_data"
    },
    {
      "type": "condition",
      "if": "cached_data == null",
      "then": [
        {
          "type": "http",
          "method": "GET",
          "url": "{{api_url}}",
          "output": "fresh_data"
        },
        {
          "type": "redis",
          "command": "SETEX",
          "key": "api:response:{{endpoint}}",
          "value": "{{fresh_data}}",
          "ttl": 3600
        }
      ]
    }
  ]
}

Message Queue Integration

1. RabbitMQ

{
  "name": "rabbitmq-publisher",
  "actions": [
    {
      "type": "rabbitmq",
      "connection": {
        "host": "localhost",
        "port": 5672,
        "username": "${RABBITMQ_USER}",
        "password": "${RABBITMQ_PASS}"
      },
      "exchange": "events",
      "routingKey": "task.completed",
      "message": {
        "taskId": "{{task_id}}",
        "status": "completed",
        "timestamp": "{{now}}"
      }
    }
  ]
}

2. Redis Pub/Sub

{
  "name": "redis-pubsub",
  "trigger": "schedule",
  "schedule": "*/5 * * * *",
  "actions": [
    {
      "type": "shell",
      "command": "df -h / | tail -1 | awk '{print $5}'",
      "output": "disk_usage"
    },
    {
      "type": "redis",
      "command": "PUBLISH",
      "channel": "metrics:disk",
      "message": {
        "usage": "{{disk_usage}}",
        "timestamp": "{{now}}"
      }
    }
  ]
}

Cloud Services Integration

1. AWS S3

{
  "name": "upload-to-s3",
  "actions": [
    {
      "type": "aws-s3",
      "action": "upload",
      "credentials": {
        "accessKeyId": "${AWS_ACCESS_KEY}",
        "secretAccessKey": "${AWS_SECRET_KEY}",
        "region": "ap-southeast-1"
      },
      "bucket": "my-backups",
      "key": "backup-{{date}}.tar.gz",
      "file": "/backup/latest.tar.gz"
    }
  ]
}

2. Google Cloud Storage

{
  "name": "gcs-upload",
  "actions": [
    {
      "type": "gcs",
      "action": "upload",
      "credentials": "${GCS_CREDENTIALS_FILE}",
      "bucket": "my-bucket",
      "destination": "logs/{{date}}/app.log",
      "source": "/var/log/app/current.log"
    }
  ]
}

3. DigitalOcean Spaces

{
  "name": "do-spaces-upload",
  "actions": [
    {
      "type": "s3-compatible",
      "endpoint": "sgp1.digitaloceanspaces.com",
      "credentials": {
        "accessKeyId": "${DO_SPACES_KEY}",
        "secretAccessKey": "${DO_SPACES_SECRET}"
      },
      "bucket": "my-space",
      "key": "backup.tar.gz",
      "file": "/backup/latest.tar.gz"
    }
  ]
}

Custom Plugins Development

Kalau integration yang kamu butuhkan belum ada, kamu bisa buat custom plugin.

1. Plugin Structure

mkdir ~/openclaw/plugins/my-custom-plugin
cd ~/openclaw/plugins/my-custom-plugin
npm init -y
// index.js
module.exports = {
  name: 'my-custom-plugin',
  version: '1.0.0',
  
  async execute(context, config) {
    // Your custom logic here
    const result = await doSomething(config);
    
    return {
      success: true,
      data: result
    };
  },
  
  validate(config) {
    // Validate config
    if (!config.requiredParam) {
      throw new Error('requiredParam is required');
    }
  }
};

2. Use Custom Plugin

{
  "name": "use-custom-plugin",
  "actions": [
    {
      "type": "plugin",
      "plugin": "my-custom-plugin",
      "config": {
        "requiredParam": "value",
        "optionalParam": "another value"
      },
      "output": "plugin_result"
    }
  ]
}

VPS untuk Integration Workload

Kalau OpenClaw kamu integrate dengan banyak service, pastikan VPS punya resource yang cukup:

🚀 VPS Indonesia Murah SufaNet

Perfect untuk OpenClaw dengan multiple integrations:

  • Network stabil untuk API calls
  • Latency rendah untuk database queries
  • Resource dedicated untuk concurrent tasks
  • NVMe SSD cepat untuk script execution

Spek recommended: 4GB RAM, 2 CPU Core, 50GB SSD Sudah cukup untuk handle 20+ concurrent integrations.

Lihat Paket VPS Indonesia

FAQ

Apakah shell command aman dieksekusi?

Aman kalau sudah di-setup dengan benar: validation input, permission control, dan audit logging. Jangan pernah execute shell command dari input user tanpa sanitization.

Berapa timeout yang wajar untuk integration?

Tergantung jenis integration: shell command 30 detik, Python/Node script 60 detik, API calls 30 detik, database query 10 detik. Adjust sesuai kebutuhan.

Bagaimana handle credential dengan aman?

Selalu pakai environment variables atau secret manager. Jangan hardcode di task definition. OpenClaw support integration dengan HashiCorp Vault untuk secret management.

Apakah bisa retry kalau integration failed?

Ya, OpenClaw punya built-in retry mechanism dengan configurable retry count, delay, dan exponential backoff.

Kesimpulan

Integration adalah jantung dari automation yang powerfull. Dengan OpenClaw sebagai orchestrator, kamu bisa connect berbagai tool dan service jadi satu workflow unified yang intelligent.

Key points:

  • Shell commands — flexible tapi butuh validation ketat
  • Scripts (Python/Node) — untuk logic kompleks
  • REST APIs — connect dengan external services
  • Database — direct access untuk query dan analysis
  • Message queues — async processing dan event-driven
  • Cloud services — leverage managed services
  • Custom plugins — extend functionality sesuai kebutuhan

👉 Langkah Selanjutnya

Integration yang stabil butuh server yang reliable.