Messages
Understanding message handling in OpenClaw.
Message Structure
Every message contains:
json5
{
id: "msg_123",
role: "user", // user, assistant, system
content: "Hello!",
channel: "whatsapp",
timestamp: "2024-01-15T10:30:00Z",
metadata: {
userId: "user_123",
sessionId: "session_456"
}
}Message Types
User Messages
Messages from users via channels.
Assistant Messages
Responses generated by the agent.
System Messages
Internal messages for context/instructions.
Message Flow
Channel → Gateway → Agent → Model → Response → Channel- Channel receives user message
- Gateway routes to appropriate agent
- Agent sends to model with context
- Model generates response
- Response sent back through channel
Content Types
OpenClaw supports various content types:
| Type | Description |
|---|---|
| Text | Plain text messages |
| Images | Image attachments |
| Files | Document attachments |
| Audio | Voice messages |
Message Formatting
Messages are normalized across channels:
- Markdown preserved where supported
- Code blocks formatted appropriately
- Links made clickable