← Back to Plugins
Channels

Gochat Extension

M0Yi By M0Yi 👁 6 views ▲ 0 votes

GoChat channel plugin for OpenClaw - custom chat backend with local and relay modes

GitHub

Install

npm install --production

Configuration Example

channels:
  gochat:
    # Operation mode: local or relay
    mode: local

    # DM policy: open, pairing, allowlist, disabled
    dmPolicy: open

    # Port for local mode HTTP server (default: 9750)
    directPort: 9750

    # Allowlist for DM senders (sender IDs)
    allowFrom:
      - user123
      - user456

    # Per-conversation settings
    conversations:
      general:
        requireMention: false
        enabled: true

    # Media settings
    mediaMaxMb: 25

    # Account-specific settings
    accounts:
      main:
        mode: local
        dmPolicy: open

README

# GoChat Plugin for OpenClaw

A channel plugin for [OpenClaw](https://github.com/m0yi/openclaw) that enables custom chat backend integration via HTTP webhook. Supports **two operation modes**:

- **Local mode** โ€” Zero-config built-in HTTP API server on port 9750
- **Relay mode** โ€” WebSocket relay connection to the GoChat platform at `wss://fund.moyi.vip/ws/plugin`

## Features

- ๐ŸŒ Webhook-based message handling (send & receive)
- ๐Ÿ–ผ๏ธ Media support (images, audio, video, file attachments)
- ๐Ÿ”’ Flexible DM policies (open, pairing, allowlist, disabled)
- ๐Ÿ‘ฅ Group chat support with per-conversation configuration
- โšก Automatic reconnection for relay mode
- ๐Ÿ”‘ Auto-generated secrets (local mode)
- ๐Ÿ“ Full message history and conversation management
- ๐Ÿš€ Zero-config local mode for quick setup

## Requirements

- OpenClaw >= 2026.3.28
- Node.js >= 18
- npm >= 9

---

## Quick Install (One Command)

```bash
curl -sL https://raw.githubusercontent.com/M0Yi/gochat-extension/main/install.sh | bash
```

For relay mode:

```bash
curl -sL https://raw.githubusercontent.com/M0Yi/gochat-extension/main/install.sh | bash -s -- --relay
```

---

<!-- AI-INSTALL-CONTEXT
     This section is an instruction block for AI assistants (e.g. OpenClaw, Codex, Copilot).
     When a user asks to "install gochat", "set up gochat", or "add the gochat plugin",
     follow the steps below verbatim. Do NOT skip any step. Do NOT paraphrase.

     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚  AI ASSISTANT INSTALLATION PROCEDURE FOR @m0yi/gochat              โ”‚
     โ”‚  Target: OpenClaw channel plugin (gochat)                          โ”‚
     โ”‚  Repo:   https://github.com/M0Yi/gochat-extension                 โ”‚
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

     STEP 1 โ€” Detect environment
       - Run: node --version && npm --version
       - Run: openclaw --version   (if not found โ†’ warn user to install OpenClaw first)
       - Determine OpenClaw state dir: echo $OPENCLAW_STATE_DIR (fallback: ~/.openclaw)

     STEP 2 โ€” Download and install
       - Run: curl -sL https://raw.githubusercontent.com/M0Yi/gochat-extension/main/install.sh | bash
       - If user wants relay mode, add: bash -s -- --relay
       - If install.sh fails โ†’ fall back to manual method:
           git clone https://github.com/M0Yi/gochat-extension.git /tmp/gochat-extension
           cp -r /tmp/gochat-extension ~/.openclaw/extensions/gochat
           cd ~/.openclaw/extensions/gochat && npm install --production

     STEP 3 โ€” Verify installation
       - Run: ls ~/.openclaw/extensions/gochat/package.json
       - Run: test -f ~/.openclaw/extensions/gochat/node_modules/ws/index.js && echo "OK"
       - If either fails โ†’ report the error and suggest manual troubleshooting.

     STEP 4 โ€” Report result to user
       - On success, print:
           "GoChat plugin installed successfully.
            Mode: local (default) โ€” built-in server starts on port 9750.
            Start OpenClaw: openclaw start"
       - If relay was chosen, mention:
           "Mode: relay โ€” plugin will auto-connect to ws://localhost:9750/ws/plugin"

     DO NOT:
       - Do NOT modify OpenClaw config files unless the user explicitly asks.
       - Do NOT start OpenClaw automatically after install.
       - Do NOT install node_modules globally or modify system PATH.
-->

## Installation from Git Repository

### Option 1: Clone and Install

```bash
# Clone the repository
git clone https://github.com/M0Yi/gochat-extension.git
cd gochat-extension

# Run the installer
chmod +x install.sh
./install.sh

# Or install with specific mode:
./install.sh --local   # Local mode (default, zero-config)
./install.sh --relay    # Relay mode (WebSocket relay)
```

### Option 2: Install via npm

```bash
# Install globally via npm
npm install -g @m0yi/gochat

# Then link to OpenClaw extensions
openclaw extension link @m0yi/gochat
```

### Option 3: Manual Installation

```bash
# Copy to OpenClaw extensions directory
cp -r gochat-extension ~/.openclaw/extensions/gochat

# Install dependencies
cd ~/.openclaw/extensions/gochat
npm install
```

## Installation from Tarball

```bash
# Download the latest release tarball
curl -L https://github.com/M0Yi/gochat-extension/releases/latest/download/gochat-extension.tar.gz -o gochat-extension.tar.gz

# Install
chmod +x install.sh
./install.sh --from-tarball gochat-extension.tar.gz
```

## Configuration

### Quick Start (Local Mode)

Local mode requires no configuration โ€” the plugin auto-starts an HTTP server on port 9750.

```bash
# After installation, start OpenClaw
openclaw start

# Or run interactive setup
openclaw gochat setup
```

### Relay Mode Setup

Relay mode connects to the GoChat platform WebSocket relay.

```bash
# Install with relay mode
./install.sh --relay

# Configure relay URL (if not using default)
# Edit ~/.openclaw/config.yaml:
channels:
  gochat:
    mode: relay
    relayPlatformUrl: wss://fund.moyi.vip/ws/plugin
```

### Configuration File

Edit `~/.openclaw/config.yaml`:

```yaml
channels:
  gochat:
    # Operation mode: local or relay
    mode: local

    # DM policy: open, pairing, allowlist, disabled
    dmPolicy: open

    # Port for local mode HTTP server (default: 9750)
    directPort: 9750

    # Allowlist for DM senders (sender IDs)
    allowFrom:
      - user123
      - user456

    # Per-conversation settings
    conversations:
      general:
        requireMention: false
        enabled: true

    # Media settings
    mediaMaxMb: 25

    # Account-specific settings
    accounts:
      main:
        mode: local
        dmPolicy: open
```

### Environment Variables

| Variable | Description | Default |
|----------|-------------|---------|
| `GOCHAT_WEBHOOK_SECRET` | Webhook signing secret | Auto-generated |
| `OPENCLAW_STATE_DIR` | OpenClaw state directory | `~/.openclaw` |
| `GOCHAT_DIRECT_PORT` | Local server port | `9750` |

## Usage

### Starting OpenClaw

```bash
# Start with GoChat plugin
openclaw start

# Check plugin status
openclaw status

# View logs
openclaw logs -f gochat
```

### Interactive Setup

```bash
# Run GoChat setup wizard
openclaw gochat setup
```

### Sending Messages

Once configured, the GoChat channel integrates with OpenClaw's messaging system. Use the standard OpenClaw send commands:

```
send @user "Hello via GoChat!"
send #channel "Message to channel"
```

## Architecture

```
gochat-extension/
โ”œโ”€โ”€ index.ts              # Plugin entry point
โ”œโ”€โ”€ setup-entry.ts        # Setup wizard entry
โ”œโ”€โ”€ runtime-api.ts        # Runtime API exports
โ”œโ”€โ”€ api.ts                # Public API exports
โ”œโ”€โ”€ install.sh            # Installation script
โ”œโ”€โ”€ package.json           # npm package definition
โ”œโ”€โ”€ openclaw.plugin.json   # OpenClaw plugin manifest
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ channel.ts         # Main channel plugin
โ”‚   โ”œโ”€โ”€ accounts.ts        # Account resolution
โ”‚   โ”œโ”€โ”€ config-schema.ts   # Configuration schema
โ”‚   โ”œโ”€โ”€ config-surface.ts  # Config surface/UI
โ”‚   โ”œโ”€โ”€ setup-core.ts      # Setup core logic
โ”‚   โ”œโ”€โ”€ setup-surface.ts   # Setup UI/surface
โ”‚   โ”œโ”€โ”€ send.ts            # Message sending
โ”‚   โ”œโ”€โ”€ inbound.ts         # Inbound handling
โ”‚   โ”œโ”€โ”€ normalize.ts       # Target normalization
โ”‚   โ”œโ”€โ”€ policy.ts          # Policy resolution
โ”‚   โ”œโ”€โ”€ runtime.ts         # Runtime setup
โ”‚   โ”œโ”€โ”€ session-route.ts   # Session routing
โ”‚   โ”œโ”€โ”€ secret-input.ts    # Secret input handling
โ”‚   โ”œโ”€โ”€ types.ts           # TypeScript types
โ”‚   โ”œโ”€โ”€ task-tools.ts      # Task tools
โ”‚   โ”œโ”€โ”€ direct/            # Local HTTP server
โ”‚   โ”‚   โ”œโ”€โ”€ server.ts
โ”‚   โ”‚   โ””โ”€โ”€ storage.ts
โ”‚   โ””โ”€โ”€ gochat/            # GoChat protocol
โ”‚       โ”œโ”€โ”€ monitor.ts     # WebSocket monitor
โ”‚       โ”œโ”€โ”€ relay-ws.ts   # WebSocket relay
โ”‚       โ””โ”€โ”€ auth.ts        # Authentication
โ””โ”€โ”€ skills/
    โ””โ”€โ”€ eink-task-reminder/ # Optional skill
```

## API Reference

### Mode: Local

Local mode runs a built-in HTTP server that:
- Receives inbound messages via POST `/webhook`
- Provides health check at GET `/health`
- Auto-generates webhook secret on first start
- Stores conversations and messages locally

### Mode: Relay

Relay mode maintains a WebSocket connection to the GoChat platform:
- Auto-registers channel on first connection
- Bi-directional message streaming
- Automatic reconnection on disconnect
- Platform-managed secrets and routing

## Troubleshooting

### Plugin not loading

```bash
# Check OpenClaw version
openclaw --version

# Verify extension installation
ls -la ~/.openclaw/extensions/gochat

# View detailed logs
openclaw logs -f
```

### Local mode not responding

```bash
# Check if port is available
lsof -i :9750

# Verify configuration
cat ~/.openclaw/config.yaml | grep -A10 gochat
```

### Relay mode connection issues

```bash
# Test WebSocket connectivity
wscat -c ws://localhost:9750/ws/plugin

# Check relay URL configuration
openclaw config get channels.gochat.relayPlatformUrl
```

## Contributing

Contributions are welcome! Please read our contributing guidelines before submitting PRs.

## License

MIT License - see [LICENSE](LICENSE) for details.

## Links

- [OpenClaw Repository](https://github.com/m0yi/openclaw)
- [GoChat Server](https://github.com/m0yi/gochat-server)
- [Issue Tracker](https://github.com/M0Yi/gochat-extension/issues)
- [Documentation](https://docs.openclaw.dev/channels/gochat)
channels

Comments

Sign in to leave a comment

Loading comments...