How to Use These Tutorials

Each tutorial provides complete, copy-paste-ready code that you can run immediately after the installation and configuration steps. Tutorials are grouped by difficulty level:

  • Beginner — no prior agent experience needed; assumes only basic Python knowledge. Average completion time: 15–30 minutes.
  • Intermediate — requires familiarity with the basics from the beginner set; introduces multi-tool agents and external API integrations. Average time: 45–90 minutes.
  • Advanced — assumes proficiency with intermediate concepts; covers multi-agent orchestration and production patterns. Average time: 2–4 hours.

New to OpenClaw? Start with Your First Agent — it walks you through every step from provider setup to running your first task in under 15 minutes.

Beginner

Intermediate

Advanced

This example from the Research Agent tutorial shows how to build a fully functional agent that searches the web and writes a structured report — in under 30 lines of Python:

import openclaw

# Create a research agent with web search capability
agent = openclaw.Agent(
    provider="openai",
    model="gpt-4o-mini",
    tools=["web_search", "fetch_url"],
    max_iterations=15,
    system_prompt="""
        You are a research assistant. When given a topic:
        1. Search for the 3 most recent and relevant sources.
        2. Read each source using fetch_url.
        3. Write a 500-word summary with key findings.
        4. List all sources with URLs.
        Format: Markdown with H2 sections.
    """
)

# Run the agent
result = agent.run("What are the latest developments in AI regulation in the EU?")
print(result.output)

# Save the report
with open("eu-ai-regulation-report.md", "w") as f:
    f.write(result.output)

print(f"Done in {result.elapsed_seconds:.1f}s using {result.tokens_used['total']} tokens")

Featured Code: GitHub PR Code Review Bot

From the Code Review Bot tutorial — trigger an OpenClaw agent from a GitHub Actions webhook to automatically review every pull request:

from flask import Flask, request
import openclaw, hmac, hashlib, os

app = Flask(__name__)
client = openclaw.Client()

@app.post("/webhook/github")
def github_pr_webhook():
    # Verify GitHub HMAC signature
    sig = request.headers.get("X-Hub-Signature-256", "")
    secret = os.environ["GITHUB_WEBHOOK_SECRET"].encode()
    expected = "sha256=" + hmac.new(secret, request.data, hashlib.sha256).hexdigest()
    if not hmac.compare_digest(expected, sig):
        return "Forbidden", 403

    event = request.json
    if event.get("action") not in ("opened", "synchronize"):
        return "OK", 200

    pr = event["pull_request"]
    diff_url = pr["diff_url"]
    pr_number = pr["number"]

    # Trigger OpenClaw code review agent
    run = client.agents.run(
        "agnt_code_reviewer",
        input=f"Review the pull request diff at {diff_url}. "
              f"List bugs, security issues, and style improvements.",
    )
    result = run.wait()

    # Post review comment back to GitHub
    post_pr_comment(pr["html_url"], pr_number, result.output)
    return "OK", 200

Suggested Learning Path

  1. 🚀 Start: Getting Started — install OpenClaw and verify setup
  2. 🎯 First win: Your First Agent — run an agent in minutes
  3. 📚 Learn fundamentals: Agent Loops and Prompt Engineering
  4. 🔧 Add tools: File Organizer and Web Scraper
  5. 🧠 Add memory: Memory Systems guide
  6. 🤝 Scale up: Multi-Step Workflow and Multi-Agent
  7. 🚀 Deploy: Deployment Guide