Skip to main content

Overview

The gateway command starts the PicoClaw gateway server, which enables the agent to interact with users through various messaging platforms and channels. The gateway manages incoming messages, scheduled tasks (cron jobs), heartbeat monitoring, device events, and health checks.

Usage

Alias: picoclaw g

Flags

boolean
default:"false"
Enable debug logging to see detailed information about gateway operations, including:
  • Channel connection details
  • Message routing
  • Agent tool usage
  • Service lifecycle events

What the Gateway Does

When started, the gateway:
  1. Initializes the Agent: Loads tools and skills
  2. Starts Services:
    • Cron service for scheduled tasks
    • Heartbeat service for periodic checks
    • Device monitoring service (if enabled)
    • Media cleanup service (if enabled)
  3. Connects Channels: Establishes connections to configured messaging platforms
  4. Starts HTTP Server: Provides health endpoints and webhook handlers
  5. Processes Messages: Routes incoming messages to the agent and sends responses

Startup Output

Expected Output:

Supported Channels

The gateway supports multiple messaging platforms:
  • Telegram: Bot API integration
  • Discord: Bot integration
  • Slack: App integration
  • WhatsApp: Business API and native
  • Feishu/Lark: Bot integration
  • DingTalk: Bot integration
  • WeCom: Enterprise WeChat
  • QQ: Bot integration
  • LINE: Messaging API
  • OneBot: Standard protocol
  • MaixCAM: Custom device integration
  • Pico: Custom protocol
Channels are configured in your config.yaml file.

Health Endpoints

The gateway exposes HTTP endpoints for monitoring:

/health

Returns gateway health status
Response:

/ready

Returns readiness status for load balancers
Response:

Services

Cron Service

Executes scheduled tasks defined via picoclaw cron commands. Tasks run in the background and can optionally deliver results to specified channels.

Heartbeat Service

Periodically checks system health and can trigger agent actions based on configured prompts.

Device Service

Monitors USB device events and can trigger workflows when devices are connected/disconnected (e.g., MaixCAM devices).

Media Cleanup

Automatically removes old media files based on TTL configuration to prevent disk space issues.

Examples

Start Gateway (Standard)

Start Gateway with Debug Logging

Output:

Using the Alias

Configuration

The gateway is configured via config.yaml:

Graceful Shutdown

Press Ctrl+C to stop the gateway. It will:
  1. Stop accepting new messages
  2. Complete in-flight requests (15 second timeout)
  3. Close channel connections
  4. Stop all services
  5. Clean up resources
Output:

Tips

  • First Run: Ensure you’ve configured at least one channel before starting the gateway
  • Port Conflicts: If port 8080 is in use, change gateway.port in config
  • Debug Mode: Use -d flag when troubleshooting channel connections
  • Health Checks: Set up monitoring to poll /health endpoint
  • Reverse Proxy: Consider using nginx or similar for production deployments
  • Firewall: Ensure configured port is accessible if using webhooks

Common Issues

No Channels Enabled

Output:
Solution: Configure and enable at least one channel in config.yaml

Port Already in Use

Error:
Solution: Change the port in config or stop the conflicting service

Configuration Error

Error:
Solution: Run picoclaw onboard first to create configuration

Docker Deployment

Example Docker Compose configuration:

Exit Codes

  • 0: Clean shutdown
  • 1: Error (configuration, channel, or service failure)

See Also