OpenClaw is designed to be extensible. This guide covers how to customize and extend your AI assistant.
Understanding the Architecture
OpenClaw consists of three main components:
- Channel Adapters - Handle communication with different platforms
- Agent Core - Processes messages and generates responses
- Skill System - Extends functionality with custom capabilities
Creating Custom Skills
Basic Skill Structure
A skill is a module that adds specific capabilities:
``typescript
import { Skill } from 'openclaw';
export const mySkill: Skill = {
name: 'weather',
description: 'Get weather information',
patterns: ['weather in {city}', 'what\'s the weather'],
handler: async (context) => {
const city = context.match.city;
const weather = await fetchWeather(city);
return The weather in ${city} is ${weather};
}
};
`
Registering Your Skill
`json
{
"skills": {
"enabled": ["weather", "calculator", "custom"]
}
}
`
Custom System Prompts
Defining Behavior
`json
{
"agent": {
"model": "claude-4-5-sonnet",
"systemPrompt": "You are a helpful coding assistant. When the user asks about code, provide clear explanations with examples. Use code blocks for all code snippets."
}
}
`
Context Variables
Pass dynamic context to your AI:
`json
{
"agent": {
"context": {
"userName": "John",
"userRole": "developer",
"currentProject": "openclaw"
}
}
}
`
Webhook Integration
Outgoing Webhooks
Trigger actions when specific events occur:
`json
{
"webhooks": {
"outgoing": [
{
"event": "message_received",
"url": "https://your-server.com/webhook",
"method": "POST"
}
]
}
}
`
Incoming Webhooks
Allow external systems to trigger AI responses:
`json
{
"webhooks": {
"incoming": {
"enabled": true,
"path": "/webhook/github"
}
}
}
`
Database Integration
Storing Conversations
`typescript
import { Database } from 'openclaw';
const db = new Database({
type: 'postgres',
connection: process.env.DATABASE_URL
});
// Store conversation
await db.conversations.create({
channel: 'telegram',
userId: '12345',
messages: conversationHistory
});
`
Custom Data Storage
`json
{
"storage": {
"type": "custom",
"provider": "./my-storage-plugin"
}
}
`
Advanced Configuration
Rate Limiting
`json
{
"limits": {
"messagesPerMinute": 10,
"messagesPerHour": 500,
"maxTokensPerDay": 100000
}
}
`
Fallback Responses
`json
{
"fallback": {
"onError": "I apologize, but I encountered an error. Please try again.",
"onTimeout": "I'm taking longer than usual. Please wait a moment.",
"onRateLimit": "You've sent too many messages. Please wait before trying again."
}
}
`
Testing Your Customization
Development Mode
`bash
openclaw dev --reload
`
Logging
`json
{
"logging": {
"level": "debug",
"channels": ["console", "file"]
}
}
`
Debugging Tips
- Use
openclaw dev for live reloading
- Check logs in
~/.openclaw/logs/
- Use the
--verbose` flag for detailed output
Conclusion
OpenClaw's extensibility allows you to create a truly personalized AI assistant. Start with simple customizations and build up to more complex integrations as needed.
Check our documentation for more advanced topics like:
- Building custom channel adapters
- Creating AI agent plugins
- Multi-tenant configurations