TaskFlow
DashboardFreewriteWhiteboardsProjectsCRMTasksNotificationsSettingsAgent TowerAPI Docs
OpenClaw Docs
?

User

Member

Caricamento in corso...

Home
Progetti
Task
Notifiche
CRM

    OpenClaw

    Documentation Mirror

    Documentation Overview

    Docs

    Auth credential semantics
    Scheduled tasks
    Hooks
    Automation & tasks
    Standing orders
    Task flow
    Background tasks
    BlueBubbles
    Broadcast groups
    Channel routing
    Discord
    Feishu
    Google Chat
    Group messages
    Groups
    iMessage
    Chat channels
    IRC
    LINE
    Channel location parsing
    Matrix
    Matrix migration
    Matrix push rules for quiet previews
    Mattermost
    Microsoft Teams
    Nextcloud Talk
    Nostr
    Pairing
    QA channel
    QQ bot
    Signal
    Slack
    Synology Chat
    Telegram
    Tlon
    Channel troubleshooting
    Twitch
    WeChat
    WhatsApp
    Yuanbao
    Zalo
    Zalo personal
    CI pipeline
    ACP
    Agent
    Agents
    Approvals
    Backup
    Browser
    Channels
    Clawbot
    `openclaw commitments`
    Completion
    Config
    Configure
    Cron
    Daemon
    Dashboard
    Devices
    Directory
    DNS
    Docs
    Doctor
    Flows (redirect)
    Gateway
    Health
    Hooks
    CLI reference
    Inference CLI
    Logs
    MCP
    Memory
    Message
    Migrate
    Models
    Node
    Nodes
    Onboard
    Pairing
    Plugins
    Proxy
    QR
    Reset
    Sandbox CLI
    Secrets
    Security
    Sessions
    Setup
    Skills
    Status
    System
    `openclaw tasks`
    TUI
    Uninstall
    Update
    Voicecall
    Webhooks
    Wiki
    Active memory
    Agent runtime
    Agent loop
    Agent runtimes
    Agent workspace
    Gateway architecture
    Channel docking
    Inferred commitments
    Compaction
    Context
    Context engine
    Delegate architecture
    Dreaming
    Experimental features
    Features
    Markdown formatting
    Memory overview
    Builtin memory engine
    Honcho memory
    QMD memory engine
    Memory search
    Messages
    Model failover
    Model providers
    Models CLI
    Multi-agent routing
    OAuth
    OpenClaw App SDK
    Presence
    QA overview
    Matrix QA
    Command queue
    Steering queue
    Retry policy
    Session management
    Session pruning
    Session tools
    SOUL.md personality guide
    Streaming and chunking
    System prompt
    Timezones
    TypeBox
    Typing indicators
    Usage tracking
    Date and time
    Node + tsx crash
    Diagnostics flags
    Authentication
    Background exec and process tool
    Bonjour discovery
    Bridge protocol
    CLI backends
    Configuration — agents
    Configuration — channels
    Configuration — tools and custom providers
    Configuration
    Configuration examples
    Configuration reference
    Diagnostics export
    Discovery and transports
    Doctor
    Gateway lock
    Health checks
    Heartbeat
    Gateway runbook
    Local models
    Gateway logging
    Multiple gateways
    Network model
    OpenAI chat completions
    OpenResponses API
    OpenShell
    OpenTelemetry export
    Gateway-owned pairing
    Prometheus metrics
    Gateway protocol
    Remote access
    Remote gateway setup
    Sandbox vs tool policy vs elevated
    Sandboxing
    Secrets management
    Secrets apply plan contract
    Security audit checks
    Security
    Tailscale
    Tools invoke API
    Troubleshooting
    Trusted proxy auth
    Debugging
    Environment variables
    FAQ
    FAQ: first-run setup
    FAQ: models and auth
    GPT-5.5 / Codex agentic parity
    GPT-5.5 / Codex parity maintainer notes
    Help
    Scripts
    Testing
    Testing: live suites
    General troubleshooting
    OpenClaw
    Ansible
    Azure
    Bun (experimental)
    ClawDock
    Release channels
    DigitalOcean
    Docker
    Docker VM runtime
    exe.dev
    Fly.io
    GCP
    Hetzner
    Hostinger
    Install
    Installer internals
    Kubernetes
    macOS VMs
    Migration guide
    Migrating from Claude
    Migrating from Hermes
    Nix
    Node.js
    Northflank
    Oracle Cloud
    Podman
    Railway
    Raspberry Pi
    Render
    Uninstall
    Updating
    Logging
    Network
    Audio and voice notes
    Camera capture
    Image and media support
    Nodes
    Location command
    Media understanding
    Talk mode
    Node troubleshooting
    Voice wake
    Pi integration architecture
    Pi development workflow
    Android app
    Platforms
    iOS app
    Linux app
    Gateway on macOS
    Canvas
    Gateway lifecycle
    macOS dev setup
    Health checks (macOS)
    Menu bar icon
    macOS logging
    Menu bar
    Peekaboo bridge
    macOS permissions
    Remote control
    macOS signing
    Skills (macOS)
    Voice overlay
    Voice wake (macOS)
    WebChat (macOS)
    macOS IPC
    macOS app
    Windows
    Plugin internals
    Plugin architecture internals
    Building plugins
    Plugin bundles
    Codex Computer Use
    Codex harness
    Community plugins
    Plugin compatibility
    Google Meet plugin
    Plugin hooks
    Plugin manifest
    Memory LanceDB
    Memory wiki
    Message presentation
    Agent harness plugins
    Building channel plugins
    Channel turn kernel
    Plugin entry points
    Plugin SDK migration
    Plugin SDK overview
    Building provider plugins
    Plugin runtime helpers
    Plugin setup and config
    Plugin SDK subpaths
    Plugin testing
    Skill workshop plugin
    Voice call plugin
    Webhooks plugin
    Zalo personal plugin
    OpenProse
    Alibaba Model Studio
    Anthropic
    Arcee AI
    Azure Speech
    Amazon Bedrock
    Amazon Bedrock Mantle
    Chutes
    Claude Max API proxy
    Cloudflare AI gateway
    ComfyUI
    Deepgram
    Deepinfra
    DeepSeek
    ElevenLabs
    Fal
    Fireworks
    GitHub Copilot
    GLM (Zhipu)
    Google (Gemini)
    Gradium
    Groq
    Hugging Face (inference)
    Provider directory
    Inferrs
    Inworld
    Kilocode
    LiteLLM
    LM Studio
    MiniMax
    Mistral
    Model provider quickstart
    Moonshot AI
    NVIDIA
    Ollama
    OpenAI
    OpenCode
    OpenCode Go
    OpenRouter
    Perplexity
    Qianfan
    Qwen
    Runway
    SGLang
    StepFun
    Synthetic
    Tencent Cloud (TokenHub)
    Together AI
    Venice AI
    Vercel AI gateway
    vLLM
    Volcengine (Doubao)
    Vydra
    xAI
    Xiaomi MiMo
    Z.AI
    Default AGENTS.md
    Release policy
    API usage and costs
    Credits
    Device model database
    Full release validation
    Memory configuration reference
    OpenClaw App SDK API design
    Prompt caching
    Rich output protocol
    RPC adapters
    SecretRef credential surface
    Session management deep dive
    AGENTS.md template
    BOOT.md template
    BOOTSTRAP.md template
    HEARTBEAT.md template
    IDENTITY template
    SOUL.md template
    TOOLS.md template
    USER template
    Tests
    Token use and costs
    Transcript hygiene
    Onboarding reference
    Contributing to the threat model
    Threat model (MITRE ATLAS)
    Formal verification (security models)
    Network proxy
    Agent bootstrapping
    Docs directory
    Getting started
    Docs hubs
    OpenClaw lore
    Onboarding (macOS app)
    Onboarding overview
    Personal assistant setup
    Setup
    Showcase
    Onboarding (CLI)
    CLI automation
    CLI setup reference
    ACP agents
    ACP agents — setup
    Agent send
    apply_patch tool
    Brave search
    Browser (OpenClaw-managed)
    Browser control API
    Browser troubleshooting
    Browser login
    WSL2 + Windows + remote Chrome CDP troubleshooting
    BTW side questions
    ClawHub
    Code execution
    Creating skills
    Diffs
    DuckDuckGo search
    Elevated mode
    Exa search
    Exec tool
    Exec approvals
    Exec approvals — advanced
    Firecrawl
    Gemini search
    Grok search
    Image generation
    Tools and plugins
    Kimi search
    LLM task
    Lobster
    Tool-loop detection
    Media overview
    MiniMax search
    Multi-agent sandbox and tools
    Music generation
    Ollama web search
    PDF tool
    Perplexity search
    Plugins
    Reactions
    SearXNG search
    Skills
    Skills config
    Slash commands
    Sub-agents
    Tavily
    Thinking levels
    Tokenjuice
    Trajectory bundles
    Text-to-speech
    Video generation
    Web search
    Web fetch
    Linux server
    Control UI
    Dashboard
    Web
    TUI
    WebChat

    OpenAPI Specs

    openapi
    TaskFlow
    docs/openclaw
    Original Docs

    Real-time Synchronized Documentation

    Last sync: 01/05/2026 07:04:25

    Note: This content is mirrored from docs.openclaw.ai and is subject to their terms and conditions.

    OpenClaw Docs

    v2.4.0 Production

    Last synced: Today, 22:00

    Technical reference for the OpenClaw framework. Real-time synchronization with the official documentation engine.

    Use this file to discover all available pages before exploring further.

    Hooks

    Hooks are small scripts that run when something happens inside the Gateway. They can be discovered from directories and inspected with

    text
    openclaw hooks
    . The Gateway loads internal hooks only after you enable hooks or configure at least one hook entry, hook pack, legacy handler, or extra hook directory.

    There are two kinds of hooks in OpenClaw:

    • Internal hooks (this page): run inside the Gateway when agent events fire, like
      text
      /new
      ,
      text
      /reset
      ,
      text
      /stop
      , or lifecycle events.
    • Webhooks: external HTTP endpoints that let other systems trigger work in OpenClaw. See Webhooks.

    Hooks can also be bundled inside plugins.

    text
    openclaw hooks list
    shows both standalone hooks and plugin-managed hooks.

    Quick start

    bash
    # List available hooks openclaw hooks list # Enable a hook openclaw hooks enable session-memory # Check hook status openclaw hooks check # Get detailed information openclaw hooks info session-memory

    Event types

    EventWhen it fires
    text
    command:new
    text
    /new
    command issued
    text
    command:reset
    text
    /reset
    command issued
    text
    command:stop
    text
    /stop
    command issued
    text
    command
    Any command event (general listener)
    text
    session:compact:before
    Before compaction summarizes history
    text
    session:compact:after
    After compaction completes
    text
    session:patch
    When session properties are modified
    text
    agent:bootstrap
    Before workspace bootstrap files are injected
    text
    gateway:startup
    After channels start and hooks are loaded
    text
    gateway:shutdown
    When gateway shutdown begins
    text
    gateway:pre-restart
    Before an expected gateway restart
    text
    message:received
    Inbound message from any channel
    text
    message:transcribed
    After audio transcription completes
    text
    message:preprocessed
    After media and link preprocessing completes or is skipped
    text
    message:sent
    Outbound message delivered

    Writing hooks

    Hook structure

    Each hook is a directory containing two files:

    text
    my-hook/ ├── HOOK.md # Metadata + documentation └── handler.ts # Handler implementation

    HOOK.md format

    markdown
    --- name: my-hook description: "Short description of what this hook does" metadata: { "openclaw": { "emoji": "🔗", "events": ["command:new"], "requires": { "bins": ["node"] } } } --- # My Hook Detailed documentation goes here.

    Metadata fields (

    text
    metadata.openclaw
    ):

    FieldDescription
    text
    emoji
    Display emoji for CLI
    text
    events
    Array of events to listen for
    text
    export
    Named export to use (defaults to
    text
    "default"
    )
    text
    os
    Required platforms (e.g.,
    text
    ["darwin", "linux"]
    )
    text
    requires
    Required
    text
    bins
    ,
    text
    anyBins
    ,
    text
    env
    , or
    text
    config
    paths
    text
    always
    Bypass eligibility checks (boolean)
    text
    install
    Installation methods

    Handler implementation

    typescript
    const handler = async (event) => { if (event.type !== "command" || event.action !== "new") { return; } console.log(`[my-hook] New command triggered`); // Your logic here // Optionally send message to user event.messages.push("Hook executed!"); }; export default handler;

    Each event includes:

    text
    type
    ,
    text
    action
    ,
    text
    sessionKey
    ,
    text
    timestamp
    ,
    text
    messages
    (push to send to user), and
    text
    context
    (event-specific data). Agent and tool plugin hook contexts can also include
    text
    trace
    , a read-only W3C-compatible diagnostic trace context that plugins may pass into structured logs for OTEL correlation.

    Event context highlights

    Command events (

    text
    command:new
    ,
    text
    command:reset
    ):
    text
    context.sessionEntry
    ,
    text
    context.previousSessionEntry
    ,
    text
    context.commandSource
    ,
    text
    context.workspaceDir
    ,
    text
    context.cfg
    .

    Message events (

    text
    message:received
    ):
    text
    context.from
    ,
    text
    context.content
    ,
    text
    context.channelId
    ,
    text
    context.metadata
    (provider-specific data including
    text
    senderId
    ,
    text
    senderName
    ,
    text
    guildId
    ).

    Message events (

    text
    message:sent
    ):
    text
    context.to
    ,
    text
    context.content
    ,
    text
    context.success
    ,
    text
    context.channelId
    .

    Message events (

    text
    message:transcribed
    ):
    text
    context.transcript
    ,
    text
    context.from
    ,
    text
    context.channelId
    ,
    text
    context.mediaPath
    .

    Message events (

    text
    message:preprocessed
    ):
    text
    context.bodyForAgent
    (final enriched body),
    text
    context.from
    ,
    text
    context.channelId
    .

    Bootstrap events (

    text
    agent:bootstrap
    ):
    text
    context.bootstrapFiles
    (mutable array),
    text
    context.agentId
    .

    Session patch events (

    text
    session:patch
    ):
    text
    context.sessionEntry
    ,
    text
    context.patch
    (only changed fields),
    text
    context.cfg
    . Only privileged clients can trigger patch events.

    Compaction events:

    text
    session:compact:before
    includes
    text
    messageCount
    ,
    text
    tokenCount
    .
    text
    session:compact:after
    adds
    text
    compactedCount
    ,
    text
    summaryLength
    ,
    text
    tokensBefore
    ,
    text
    tokensAfter
    .

    text
    command:stop
    observes the user issuing
    text
    /stop
    ; it is cancellation/command lifecycle, not an agent-finalization gate. Plugins that need to inspect a natural final answer and ask the agent for one more pass should use the typed plugin hook
    text
    before_agent_finalize
    instead. See Plugin hooks.

    Gateway lifecycle events:

    text
    gateway:shutdown
    includes
    text
    reason
    and
    text
    restartExpectedMs
    and fires when gateway shutdown begins.
    text
    gateway:pre-restart
    includes the same context but only fires when shutdown is part of an expected restart and a finite
    text
    restartExpectedMs
    value is supplied. During shutdown, each lifecycle hook wait is best-effort and bounded so shutdown continues if a handler stalls.

    Hook discovery

    Hooks are discovered from these directories, in order of increasing override precedence:

    1. Bundled hooks: shipped with OpenClaw
    2. Plugin hooks: hooks bundled inside installed plugins
    3. Managed hooks:
      text
      ~/.openclaw/hooks/
      (user-installed, shared across workspaces). Extra directories from
      text
      hooks.internal.load.extraDirs
      share this precedence.
    4. Workspace hooks:
      text
      <workspace>/hooks/
      (per-agent, disabled by default until explicitly enabled)

    Workspace hooks can add new hook names but cannot override bundled, managed, or plugin-provided hooks with the same name.

    The Gateway skips internal hook discovery on startup until internal hooks are configured. Enable a bundled or managed hook with

    text
    openclaw hooks enable <name>
    , install a hook pack, or set
    text
    hooks.internal.enabled=true
    to opt in. When you enable one named hook, the Gateway loads only that hook's handler;
    text
    hooks.internal.enabled=true
    , extra hook directories, and legacy handlers opt into broad discovery.

    Hook packs

    Hook packs are npm packages that export hooks via

    text
    openclaw.hooks
    in
    text
    package.json
    . Install with:

    bash
    openclaw plugins install <path-or-spec>

    Npm specs are registry-only (package name + optional exact version or dist-tag). Git/URL/file specs and semver ranges are rejected.

    Bundled hooks

    HookEventsWhat it does
    session-memory
    text
    command:new
    ,
    text
    command:reset
    Saves session context to
    text
    <workspace>/memory/
    bootstrap-extra-files
    text
    agent:bootstrap
    Injects additional bootstrap files from glob patterns
    command-logger
    text
    command
    Logs all commands to
    text
    ~/.openclaw/logs/commands.log
    boot-md
    text
    gateway:startup
    Runs
    text
    BOOT.md
    when the gateway starts

    Enable any bundled hook:

    bash
    openclaw hooks enable <hook-name>

    session-memory details

    Extracts the last 15 user/assistant messages, generates a descriptive filename slug via LLM, and saves to

    text
    <workspace>/memory/YYYY-MM-DD-slug.md
    using the host local date. Requires
    text
    workspace.dir
    to be configured.

    bootstrap-extra-files config

    json
    { "hooks": { "internal": { "entries": { "bootstrap-extra-files": { "enabled": true, "paths": ["packages/*/AGENTS.md", "packages/*/TOOLS.md"] } } } } }

    Paths resolve relative to workspace. Only recognized bootstrap basenames are loaded (

    text
    AGENTS.md
    ,
    text
    SOUL.md
    ,
    text
    TOOLS.md
    ,
    text
    IDENTITY.md
    ,
    text
    USER.md
    ,
    text
    HEARTBEAT.md
    ,
    text
    BOOTSTRAP.md
    ,
    text
    MEMORY.md
    ).

    command-logger details

    Logs every slash command to

    text
    ~/.openclaw/logs/commands.log
    .

    boot-md details

    Runs

    text
    BOOT.md
    from the active workspace when the gateway starts.

    Plugin hooks

    Plugins can register typed hooks through the Plugin SDK for deeper integration: intercepting tool calls, modifying prompts, controlling message flow, and more. Use plugin hooks when you need

    text
    before_tool_call
    ,
    text
    before_agent_reply
    ,
    text
    before_install
    , or other in-process lifecycle hooks.

    For the complete plugin hook reference, see Plugin hooks.

    Configuration

    json
    { "hooks": { "internal": { "enabled": true, "entries": { "session-memory": { "enabled": true }, "command-logger": { "enabled": false } } } } }

    Per-hook environment variables:

    json
    { "hooks": { "internal": { "entries": { "my-hook": { "enabled": true, "env": { "MY_CUSTOM_VAR": "value" } } } } } }

    Extra hook directories:

    json
    { "hooks": { "internal": { "load": { "extraDirs": ["/path/to/more/hooks"] } } } }

    note

    The legacy `hooks.internal.handlers` array config format is still supported for backwards compatibility, but new hooks should use the discovery-based system.

    CLI reference

    bash
    # List all hooks (add --eligible, --verbose, or --json) openclaw hooks list # Show detailed info about a hook openclaw hooks info <hook-name> # Show eligibility summary openclaw hooks check # Enable/disable openclaw hooks enable <hook-name> openclaw hooks disable <hook-name>

    Best practices

    • Keep handlers fast. Hooks run during command processing. Fire-and-forget heavy work with
      text
      void processInBackground(event)
      .
    • Handle errors gracefully. Wrap risky operations in try/catch; do not throw so other handlers can run.
    • Filter events early. Return immediately if the event type/action is not relevant.
    • Use specific event keys. Prefer
      text
      "events": ["command:new"]
      over
      text
      "events": ["command"]
      to reduce overhead.

    Troubleshooting

    Hook not discovered

    bash
    # Verify directory structure ls -la ~/.openclaw/hooks/my-hook/ # Should show: HOOK.md, handler.ts # List all discovered hooks openclaw hooks list

    Hook not eligible

    bash
    openclaw hooks info my-hook

    Check for missing binaries (PATH), environment variables, config values, or OS compatibility.

    Hook not executing

    1. Verify the hook is enabled:
      text
      openclaw hooks list
    2. Restart your gateway process so hooks reload.
    3. Check gateway logs:
      text
      ./scripts/clawlog.sh | grep hook

    Related

    • CLI Reference: hooks
    • Webhooks
    • Plugin hooks — in-process plugin lifecycle hooks
    • Configuration

    © 2024 TaskFlow Mirror

    Powered by TaskFlow Sync Engine