← All articles

OpenClaw Tutorial: Complete Setup Guide for AI Automation (2026)

Master OpenClaw setup with this comprehensive tutorial. Learn installation, configuration, skills management, and advanced automation workflows to transform your productivity with AI agents.

OpenClaw is an open-source AI automation framework that lets you build powerful agent workflows without the complexity of traditional coding. This complete tutorial walks you through everything from basic setup to advanced automation patterns.

By the end of this guide, you'll have a fully configured OpenClaw instance running custom skills and automating real tasks in your workflow.


What is OpenClaw?

OpenClaw is an extensible AI agent framework that connects to various services (email, calendar, Slack, GitHub) and executes tasks through "skills" — reusable automation modules that can be triggered manually or through scheduling.

Think of it as the open-source foundation for building AI assistants that actually do work, not just chat.

Key capabilities:

  • Multi-service integration: Gmail, Google Calendar, Slack, Discord, GitHub, and 50+ other platforms
  • Custom skill development: Write Python functions that become AI-powered automation workflows
  • Memory persistence: Agents remember context across sessions and improve over time
  • Scheduling engine: Run skills on timers, webhooks, or custom triggers
  • Multi-agent orchestration: Coordinate multiple specialized agents for complex workflows

Prerequisites and Installation

Before diving into OpenClaw, ensure you have:

  • Python 3.9+ with pip installed
  • Git for cloning repositories
  • API keys for services you want to integrate (Gmail, Slack, etc.)
  • Basic command line familiarity

Step 1: Clone and Install OpenClaw

# Clone the repository
git clone https://github.com/openclaw/openclaw.git
cd openclaw

# Create virtual environment
python -m venv openclaw-env
source openclaw-env/bin/activate  # On Windows: openclaw-env\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Install OpenClaw in development mode
pip install -e .

Step 2: Initialize Configuration

# Generate default configuration
openclaw init

# This creates:
# ~/.openclaw/config.yaml
# ~/.openclaw/skills/
# ~/.openclaw/logs/
# ~/.openclaw/memory/

Your initial config.yaml will look like this:

# OpenClaw Configuration
core:
  debug: false
  log_level: INFO
  memory_path: ~/.openclaw/memory
  skills_path: ~/.openclaw/skills

agents:
  default:
    name: "DefaultAgent"
    model: "gpt-4"
    temperature: 0.1
    max_tokens: 2000

integrations: {}

Core Configuration

Step 3: Set Up API Keys

OpenClaw uses environment variables for sensitive data. Create a .env file in your project root:

# OpenAI (required for default agent)
OPENAI_API_KEY=your_openai_api_key_here

# Gmail Integration (optional)
GMAIL_CLIENT_ID=your_gmail_client_id
GMAIL_CLIENT_SECRET=your_gmail_client_secret

# Slack Integration (optional)
SLACK_BOT_TOKEN=xoxb-your-slack-bot-token
SLACK_APP_TOKEN=xapp-your-slack-app-token

# Discord Integration (optional)
DISCORD_BOT_TOKEN=your_discord_bot_token

Step 4: Configure Your First Integration

Let's set up Gmail integration as an example. Update your config.yaml:

integrations:
  gmail:
    enabled: true
    auth_method: oauth2
    scopes:
      - https://www.googleapis.com/auth/gmail.readonly
      - https://www.googleapis.com/auth/gmail.send
    credentials_file: ~/.openclaw/gmail_credentials.json

Step 5: Authenticate Services

# Authenticate Gmail (opens browser for OAuth)
openclaw auth gmail

# Verify connection
openclaw test gmail

Creating Your First Skill

Skills are Python functions that OpenClaw agents can execute. Let's create a simple email summarizer skill:

Step 6: Write a Custom Skill

Create ~/.openclaw/skills/email_summary.py:

from openclaw.core import Skill, Agent
from datetime import datetime, timedelta
import logging

class EmailSummarySkill(Skill):
    """Summarizes unread emails from the last 24 hours"""

    name = "email_summary"
    description = "Generate a summary of unread emails from the last 24 hours"

    def __init__(self, agent: Agent):
        super().__init__(agent)
        self.gmail = agent.get_integration('gmail')

    async def execute(self, **kwargs):
        """Main execution function"""
        try:
            # Get emails from last 24 hours
            since = datetime.now() - timedelta(days=1)
            query = f"is:unread after:{since.strftime('%Y/%m/%d')}"

            emails = await self.gmail.search_messages(query, max_results=20)

            if not emails:
                return {"status": "success", "summary": "No unread emails in the last 24 hours."}

            # Prepare email data for summarization
            email_data = []
            for email in emails:
                email_content = await self.gmail.get_message(email['id'])
                email_data.append({
                    'from': email_content['from'],
                    'subject': email_content['subject'],
                    'snippet': email_content['snippet'][:200]
                })

            # Generate AI summary
            prompt = f"""
            Summarize these {len(email_data)} unread emails. Group by importance and provide actionable insights:

            {self._format_emails_for_prompt(email_data)}

            Format as:
            ## High Priority (action needed)
            ## Medium Priority (review when convenient)
            ## Low Priority (FYI/newsletters)
            """

            summary = await self.agent.generate_response(prompt)

            return {
                "status": "success",
                "email_count": len(emails),
                "summary": summary,
                "timestamp": datetime.now().isoformat()
            }

        except Exception as e:
            logging.error(f"Email summary skill failed: {e}")
            return {"status": "error", "message": str(e)}

    def _format_emails_for_prompt(self, emails):
        """Format emails for AI processing"""
        formatted = []
        for email in emails:
            formatted.append(f"From: {email['from']}\nSubject: {email['subject']}\nSnippet: {email['snippet']}\n")
        return "\n---\n".join(formatted)

# Register the skill
def register_skill(agent):
    return EmailSummarySkill(agent)

Step 7: Test Your Skill

# Load and test the skill
openclaw skill load email_summary
openclaw skill run email_summary

# Check execution logs
openclaw logs --tail 50

Advanced Automation Patterns

Step 8: Set Up Scheduled Execution

Create a scheduler configuration in config.yaml:

scheduler:
  enabled: true
  jobs:
    - name: morning_email_summary
      skill: email_summary
      cron: "0 7 * * *"  # Every day at 7 AM
      output_channel: slack
      output_config:
        channel: "#daily-digest"

    - name: weekly_cleanup
      skill: inbox_cleanup
      cron: "0 18 * * 5"  # Every Friday at 6 PM

Step 9: Create Multi-Agent Workflows

OpenClaw supports agent orchestration for complex workflows:

# ~/.openclaw/skills/quarterly_review.py
class QuarterlyReviewSkill(Skill):
    """Coordinates multiple agents for quarterly business review"""

    async def execute(self, **kwargs):
        results = {}

        # Agent 1: Financial analysis
        finance_agent = await self.agent.spawn_child_agent("finance")
        results['financial'] = await finance_agent.run_skill("financial_summary",
                                                           period="quarter")

        # Agent 2: Team performance
        hr_agent = await self.agent.spawn_child_agent("hr")
        results['team'] = await hr_agent.run_skill("team_performance",
                                                  period="quarter")

        # Agent 3: Competitive analysis
        research_agent = await self.agent.spawn_child_agent("research")
        results['competitive'] = await research_agent.run_skill("market_analysis")

        # Synthesize final report
        report = await self._generate_executive_summary(results)

        return {"status": "success", "report": report}

Integration Examples

Slack Integration

# Connect OpenClaw to Slack for notifications
class SlackNotifierSkill(Skill):
    async def execute(self, message, channel="#general", **kwargs):
        slack = self.agent.get_integration('slack')
        await slack.send_message(channel, message)
        return {"status": "success", "channel": channel}

GitHub Integration

# Automate GitHub issue management
class GitHubTriageSkill(Skill):
    async def execute(self, repo, **kwargs):
        github = self.agent.get_integration('github')

        # Get new issues
        issues = await github.get_issues(repo, state='open', labels='triage')

        for issue in issues:
            # AI-powered triage
            priority = await self._analyze_issue_priority(issue)
            await github.add_labels(repo, issue['number'], [f"priority-{priority}"])

Production Deployment

Step 10: Deploy to Production

For production deployment, consider these options:

Docker Deployment:

FROM python:3.11-slim

WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .
RUN pip install -e .

CMD ["openclaw", "start", "--daemon"]

Docker Compose:

version: '3.8'
services:
  openclaw:
    build: .
    environment:
      - OPENAI_API_KEY=${OPENAI_API_KEY}
      - GMAIL_CLIENT_ID=${GMAIL_CLIENT_ID}
    volumes:
      - ./data:/root/.openclaw
    restart: unless-stopped

Systemd Service (Linux):

# /etc/systemd/system/openclaw.service
[Unit]
Description=OpenClaw AI Agent
After=network.target

[Service]
Type=forking
User=openclaw
WorkingDirectory=/opt/openclaw
ExecStart=/opt/openclaw/venv/bin/openclaw start --daemon
Restart=always

[Install]
WantedBy=multi-user.target

Next Steps and Advanced Features

Memory Management: OpenClaw agents build persistent memory over time. Configure memory retention and optimization:

memory:
  retention_days: 30
  optimization_schedule: "0 2 * * 0"  # Weekly at 2 AM
  compression_threshold: 1000  # messages

Custom Model Integration: While OpenClaw defaults to OpenAI, you can integrate any LLM:

from openclaw.models import BaseModel

class LocalLlamaModel(BaseModel):
    def __init__(self, model_path):
        self.model = load_local_model(model_path)

    async def generate_response(self, prompt, **kwargs):
        return await self.model.generate(prompt, **kwargs)

Webhook Triggers: Set up HTTP endpoints to trigger skills:

webhooks:
  enabled: true
  port: 8080
  endpoints:
    - path: "/trigger/email-summary"
      skill: "email_summary"
      auth_token: "your_secret_token"

Troubleshooting Common Issues

Authentication Failures:

# Reset OAuth tokens
openclaw auth reset gmail

# Verify API key permissions
openclaw auth test

Skill Loading Errors:

# Validate skill syntax
openclaw skill validate email_summary

# Check dependency issues
pip install --upgrade openclaw

Memory Issues:

# Clear agent memory
openclaw memory clear --agent default

# Optimize memory usage
openclaw memory optimize

Why OpenClaw vs. Commercial Alternatives

OpenClaw gives you what closed-source AI assistants can't: full control and customization. While platforms like MrDelegate offer plug-and-play AI Chief of Staff functionality for business users, OpenClaw is for developers who need:

  • Complete data ownership and privacy
  • Custom integration requirements
  • Specialized industry workflows
  • On-premise deployment capabilities

For non-technical users or teams wanting immediate productivity gains, consider MrDelegate's managed AI assistant service — it handles the complexity while delivering enterprise-grade AI delegation.

For developers building custom AI automation, OpenClaw provides the foundation to create exactly what you need.

Ready to build your AI automation empire? Start with OpenClaw's official documentation and join the community at GitHub.

Free 3-day trial

Your AI executive assistant is ready.

Morning brief at 7am. Inbox triaged overnight. Calendar protected. Dedicated VPS. No Docker. Live in 60 seconds.

Start free trial → $0 today · $47/mo after 3 days · Cancel anytime

Ready to delegate your inbox?

3-day free trial. No charge today. Live in 60 seconds.

Start your trial →