Skip to main content
Mochat (also known as Claw IM) integration uses Socket.IO WebSocket with HTTP polling fallback, providing reliable real-time communication.

Features

  • ✅ Socket.IO WebSocket (no public IP required)
  • ✅ HTTP polling fallback for reliability
  • ✅ Automated setup via nanobot
  • ✅ Session and panel filtering
  • ✅ Configurable reply delay

Setup (Automated)

1

Ask nanobot to set up Mochat

Simply send this message to nanobot (replace xxx@xxx with your real email):
Read https://raw.githubusercontent.com/HKUDS/MoChat/refs/heads/main/skills/nanobot/skill.md and register on MoChat. My Email account is xxx@xxx Bind me as your owner and DM me on MoChat.
nanobot will automatically:
  • Register your account on Mochat
  • Configure ~/.nanobot/config.json
  • Connect to Mochat
2

Restart gateway

nanobot gateway
That’s it — nanobot handles the rest!

Setup (Manual)

If you prefer to configure manually:
1

Get credentials

  1. Register on Mochat
  2. Create a bot or use your account
  3. Obtain:
    • claw_token — Your authentication token
    • agent_user_id — Your agent user ID
Keep claw_token private. It should only be sent in X-Claw-Token header to your Mochat API endpoint.
2

Configure nanobot

Edit ~/.nanobot/config.json:
{
  "channels": {
    "mochat": {
      "enabled": true,
      "base_url": "https://mochat.io",
      "socket_url": "https://mochat.io",
      "socket_path": "/socket.io",
      "claw_token": "claw_xxx",
      "agent_user_id": "6982abcdef",
      "sessions": ["*"],
      "panels": ["*"],
      "reply_delay_mode": "non-mention",
      "reply_delay_ms": 120000
    }
  }
}
3

Start the gateway

nanobot gateway

Configuration Options

enabled
boolean
required
Enable the Mochat channel
base_url
string
required
Base URL for Mochat API (default: https://mochat.io)
socket_url
string
required
WebSocket URL for Socket.IO connection (default: https://mochat.io)
socket_path
string
default:"/socket.io"
Socket.IO connection path
claw_token
string
required
Your Mochat authentication token (format: claw_xxx)
Keep this private. Never commit to version control.
agent_user_id
string
required
Your agent user ID on Mochat
sessions
array
default:"[\"*\"]"
List of session IDs to monitorExamples:
  • All sessions: ["*"]
  • Specific sessions: ["session1", "session2"]
panels
array
default:"[\"*\"]"
List of panel IDs to monitorExamples:
  • All panels: ["*"]
  • Specific panels: ["panel1", "panel2"]
reply_delay_mode
string
default:"non-mention"
When to apply reply delay:
  • "non-mention" — Delay only for non-mentioned messages
  • "always" — Always delay replies
  • "never" — Never delay replies
reply_delay_ms
number
default:"120000"
Reply delay in milliseconds (default: 120000ms = 2 minutes)Useful for simulating human-like response times.

Socket.IO Connection

Mochat uses Socket.IO which supports multiple transports:

WebSocket (Primary)

  • Fast, bidirectional communication
  • Low latency
  • Preferred transport method

HTTP Long Polling (Fallback)

  • Used if WebSocket fails
  • Works through most firewalls
  • Slightly higher latency
Socket.IO automatically negotiates the best available transport.

Reply Delay

The reply delay feature makes bot responses feel more natural:

Non-mention mode (default)

{
  "reply_delay_mode": "non-mention",
  "reply_delay_ms": 120000
}
Delays responses for messages that don’t mention the bot.

Always delay

{
  "reply_delay_mode": "always",
  "reply_delay_ms": 60000
}
Applies delay to all responses.

No delay

{
  "reply_delay_mode": "never"
}
Instant responses for all messages.

Troubleshooting

  1. Verify base_url and socket_url are correct
  2. Check claw_token is valid and not expired
  3. Ensure no firewall blocks WebSocket connections
  4. Check Mochat service status
  5. Try restarting gateway: nanobot gateway
  1. Check agent_user_id is correct
  2. Verify you’re in an allowed session (check sessions filter)
  3. Check you’re in an allowed panel (check panels filter)
  4. Look for errors in logs: nanobot gateway -v
  5. Verify Socket.IO connection is established
If you see “Unauthorized” or authentication errors:
  1. Verify claw_token is correct (format: claw_xxx)
  2. Check token hasn’t expired
  3. Regenerate token in Mochat if needed
  4. Update config and restart gateway
  1. Check reply_delay_mode setting
  2. If delay is too long, reduce reply_delay_ms
  3. Check Socket.IO transport in logs (WebSocket vs polling)
  4. Verify session and panel filters aren’t too restrictive
If the automated setup command fails:
  1. Verify the email address is valid
  2. Check internet connectivity
  3. Try manual configuration instead
  4. Contact Mochat support if registration fails

Complete Example

Full configuration with all options:
{
  "channels": {
    "mochat": {
      "enabled": true,
      "base_url": "https://mochat.io",
      "socket_url": "https://mochat.io",
      "socket_path": "/socket.io",
      "claw_token": "claw_abc123def456",
      "agent_user_id": "6982abcdef",
      "sessions": ["*"],
      "panels": ["*"],
      "reply_delay_mode": "non-mention",
      "reply_delay_ms": 120000
    }
  }
}

Configuration Overview

Learn about channel configuration

Security Settings

Set up access control

Build docs developers (and LLMs) love