> For the complete documentation index, see [llms.txt](https://www.openclawbook.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.openclawbook.xyz/en/ch21-channel-extension-mechanism/21.3-representative-extension-implementations.md). Agents can also search and read this documentation through its [MCP server](https://www.openclawbook.xyz/~gitbook/mcp).

# 21.3 Representative Extension Implementations

> **Generated by**: Claude Opus 4.6 (initial draft) / Claude Opus 5 (`v2026.3.9` revision) **Token usage**: Input \~820k tokens, Output \~75k tokens (Chapter 21 total) **Source baseline**: `v2026.3.9` (`v2026.3.8-170-g665f67726`)

***

OpenClaw's `extensions/` directory contains **31 official extensions** covering enterprise communication, open-source protocols, social streaming, and regional instant messaging platforms. This section analyzes representative extensions in depth, demonstrating integration patterns for different types of platforms.

***

## 21.3.1 Microsoft Teams Extension (Bot Framework Integration)

### Overview

The MS Teams extension is one of the most complex official extensions, with `extensions/msteams/src/` containing **51 source files**, covering message listening, sending, attachment handling, polls, session storage, and Graph API directory queries.

| Feature                | Description                                                     |
| ---------------------- | --------------------------------------------------------------- |
| Communication Protocol | Microsoft Bot Framework (REST Webhook)                          |
| Authentication         | Azure AD App (appId + appPassword)                              |
| Message Reception      | Express HTTP server listening on `/api/messages`                |
| Message Sending        | Bot Framework SDK's `adapter.process()`                         |
| Special Features       | Adaptive Cards, polls, session persistence, Graph API directory |

### Entry Registration

The MS Teams entry is extremely concise, following the "thin entry" principle:

```typescript
// extensions/msteams/index.ts
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
import { msteamsPlugin } from "./src/channel.js";
import { setMSTeamsRuntime } from "./src/runtime.js";

const plugin = {
  id: "msteams",
  configSchema: emptyPluginConfigSchema(),
  register(api: OpenClawPluginApi) {
    setMSTeamsRuntime(api.runtime);           // Cache runtime reference
    api.registerChannel({ plugin: msteamsPlugin }); // Register channel plugin
  },
};
export default plugin;
```

Note the `setMSTeamsRuntime(api.runtime)` pattern—since plugin modules cannot access `PluginRuntime` at the top level, it must be cached to a module-level variable during `register()` for use by subsequent modules like `monitor.ts` and `send.ts`. This is a common idiom used by all extensions.

### Channel Plugin Definition

`msteamsPlugin` is a complete `ChannelPlugin` implementation containing most of the adapter slots introduced in Chapter 19:

```typescript
// extensions/msteams/src/channel.ts (key structure)
export const msteamsPlugin: ChannelPlugin<ResolvedMSTeamsAccount> = {
  id: "msteams",
  meta: {
    label: "Microsoft Teams",
    selectionLabel: "Microsoft Teams (Bot Framework)",
    aliases: ["teams"],
    order: 60,
  },
  
  // Capability declaration
  capabilities: {
    chatTypes: ["direct", "channel", "thread"],
    polls: true,
    threads: true,
    media: true,
  },
  
  // Adapter implementations
  config: { /* Account management */ },
  security: { /* Security policies */ },
  pairing: { /* Pairing approval */ },
  messaging: { /* Message target resolution */ },
  directory: { /* Directory queries */ },
  resolver: { /* Target ID resolution */ },
  actions: { /* Adaptive Card sending */ },
  outbound: msteamsOutbound,
  status: { /* Status monitoring */ },
  gateway: { /* Start message listening */ },
  threading: { /* Thread context */ },
  groups: { /* Group tool policies */ },
  onboarding: msteamsOnboardingAdapter,
  agentPrompt: { /* Agent tool hints */ },
};
```

### Message Listening: Express + Bot Framework

MS Teams' most unique aspect is its use of **Webhook push** mode rather than long polling. OpenClaw launches an Express HTTP server for this:

```typescript
// extensions/msteams/src/monitor.ts (simplified)
export async function monitorMSTeamsProvider(opts) {
  const port = msteamsCfg.webhook?.port ?? 3978;
  const express = await import("express");          // Dynamic import
  const { sdk, authConfig } = await loadMSTeamsSdkWithAuth(creds);
  
  // Create Bot Framework Adapter
  const adapter = createMSTeamsAdapter(authConfig, sdk);
  
  // Register message handlers
  const handler = registerMSTeamsHandlers(new ActivityHandler(), {
    cfg, runtime, adapter, textLimit, ...
  });
  
  // Start Express server
  const expressApp = express.default();
  expressApp.use(express.json());
  expressApp.use(authorizeJWT(authConfig));          // JWT verification middleware
  expressApp.post("/api/messages", (req, res) => {
    adapter.process(req, res, (context) => handler.run(context));
  });
  
  const httpServer = expressApp.listen(port);
  return { app: expressApp, shutdown: () => httpServer.close() };
}
```

> **Sidebar**: **Bot Framework** is a robot development framework provided by Microsoft. Similar to Telegram Bot API, developers register a Bot and configure a Webhook URL, and Microsoft servers push user messages to that URL via HTTP POST. `ActivityHandler` is the base class in the Bot Framework SDK for handling message activities (Activity), and OpenClaw handles different types of Activity by inheriting from it.

### Adaptive Cards Support

A highlight of MS Teams is support for **Adaptive Cards**—a declarative rich content card format:

```typescript
// extensions/msteams/src/channel.ts — actions adapter
actions: {
  supportsCards: ({ cfg }) => Boolean(resolveMSTeamsCredentials(cfg.channels?.msteams)),
  handleAction: async (ctx) => {
    if (ctx.action === "send" && ctx.params.card) {
      const result = await sendAdaptiveCardMSTeams({
        cfg: ctx.cfg,
        to: ctx.params.to,
        card: ctx.params.card,
      });
      return { content: [{ type: "text", text: JSON.stringify({ ok: true, ...result }) }] };
    }
    return null;   // Non-card operations handled by default
  },
},
```

***

## 21.3.2 Matrix Extension (matrix-js-sdk Integration)

### Overview

Matrix is a **decentralized** open-source communication protocol, forming a stark contrast with MS Teams' centralized model.

| Feature                | Description                                                                     |
| ---------------------- | ------------------------------------------------------------------------------- |
| Communication Protocol | Matrix Client-Server API (REST + Server-Sent Events)                            |
| Authentication         | Homeserver URL + Access Token / Password                                        |
| Message Reception      | matrix-js-sdk's `/sync` long polling                                            |
| Message Sending        | Matrix Client API (`PUT /_matrix/client/v3/rooms/{roomId}/send/...`)            |
| Special Features       | End-to-end encryption (E2EE via matrix-sdk-crypto-nodejs), multiple Homeservers |

### Entry Registration

The Matrix extension's entry structure is identical to MS Teams:

```typescript
// extensions/matrix/index.ts
const plugin = {
  id: "matrix",
  configSchema: emptyPluginConfigSchema(),
  register(api: OpenClawPluginApi) {
    setMatrixRuntime(api.runtime);
    api.registerChannel({ plugin: matrixPlugin });
  },
};
```

### Special Handling for Open-Source Protocols

The Matrix extension's `channel.ts` focuses more on **decentralized features**:

```typescript
// extensions/matrix/src/channel.ts — account support for multiple Homeservers
config: {
  listAccountIds: (cfg) => listMatrixAccountIds(cfg),  // May have multiple accounts
  resolveAccount: (cfg, accountId) => resolveMatrixAccount({ cfg, accountId }),
  deleteAccount: ({ cfg, accountId }) =>
    deleteAccountFromConfigSection({
      cfg, sectionKey: "matrix", accountId,
      clearBaseFields: ["homeserver", "userId", "accessToken", "password", "deviceName"],
    }),
},

// Security policy: Matrix groups default to allowlist policy
security: {
  resolveDmPolicy: ({ account }) => ({
    policy: account.config.dm?.policy ?? "pairing",  // Default pairing mode
    allowFrom: account.config.dm?.allowFrom ?? [],
  }),
},
```

Matrix's target resolution needs to handle multiple ID formats:

```typescript
messaging: {
  targetResolver: {
    looksLikeId: (raw) => {
      const trimmed = raw.trim();
      if (/^(matrix:)?[!#@]/i.test(trimmed)) return true;  // !roomId, #alias, @userId
      return trimmed.includes(":");                          // server:port format
    },
    hint: "<room|alias|user>",
  },
},
```

> **Sidebar**: Matrix's ID system uses sigils (prefix symbols) to distinguish different entities: `@` represents users (e.g., `@alice:matrix.org`), `!` represents rooms (e.g., `!abc123:matrix.org`), `#` represents room aliases (e.g., `#general:matrix.org`). The colon is followed by the Homeserver address. This decentralized ID design allows users to have identities on different servers.

### End-to-End Encryption

The Matrix extension supports E2EE (end-to-end encryption) through `matrix-sdk-crypto-nodejs`. This is a **native Node module** (compiled from Rust), which is the main reason it's placed in an extension rather than a core channel—native module compilation can fail on certain platforms, and placing it in an extension avoids affecting main package installation.

***

## 21.3.3 Twitch Extension

### Overview

Twitch is a streaming platform whose chat system is based on the **IRC (Internet Relay Chat)** protocol.

| Feature                | Description                  |
| ---------------------- | ---------------------------- |
| Communication Protocol | IRC over WebSocket (tmi.js)  |
| Authentication         | OAuth Token                  |
| Message Reception      | IRC WebSocket real-time push |
| Message Sending        | IRC PRIVMSG command          |
| Source Files           | 28 (including tests)         |

### Entry Registration

```typescript
// extensions/twitch/index.ts
const plugin = {
  id: "twitch",
  configSchema: emptyPluginConfigSchema(),
  register(api: OpenClawPluginApi) {
    setTwitchRuntime(api.runtime);
    api.registerChannel({ plugin: twitchPlugin });
  },
};
```

### Specifics of IRC Protocol

Unlike HTTP-based MS Teams and REST API-based Matrix, Twitch uses the **IRC protocol**. This means:

1. **No threading concept**: IRC is a flat message stream with no reply chains or threads
2. **Strict message length limits**: IRC single message limit is 500 bytes
3. **No media support**: IRC supports plain text only
4. **Extremely high real-time**: Persistent connections based on WebSocket

> **Sidebar**: **IRC (Internet Relay Chat)** is a real-time chat protocol born in 1988, one of the oldest chat protocols on the internet. Although replaced by modern instant messaging software, Twitch uses the IRC protocol (with extensions) to support large-scale real-time chat in live streams. IRC's core concepts are "channels" and "messages," with messages pushed bidirectionally through persistent TCP connections.

The Twitch extension's source structure reflects these constraints—it has `access-control.ts` (channel permission management) and `client-manager-registry.ts` (multi-channel connection management), but no threading or media-related modules.

***

## 21.3.4 Nostr Extension

### Overview

Nostr is a **decentralized social protocol**, similar to Matrix but more minimalist.

| Feature                | Description                                  |
| ---------------------- | -------------------------------------------- |
| Communication Protocol | Nostr NIP-04 (encrypted direct messages)     |
| Authentication         | Public-private key pair (Ed25519/Secp256k1)  |
| Message Reception      | Subscribe to events via relays               |
| Message Sending        | Publish signed events to relays              |
| Special Features       | HTTP Profile management, NIP-05 verification |

### Entry Registration: Beyond Simple Channel Registration

The Nostr extension demonstrates a more complex registration pattern—in addition to registering a channel, it also registers an **HTTP handler**:

```typescript
// extensions/nostr/index.ts (simplified)
register(api: OpenClawPluginApi) {
  setNostrRuntime(api.runtime);
  api.registerChannel({ plugin: nostrPlugin });
  
  // Register HTTP handler: provide Nostr Profile management API
  const httpHandler = createNostrProfileHttpHandler({
    getConfigProfile: (accountId) => {
      const cfg = getNostrRuntime().config.loadConfig();
      return resolveNostrAccount({ cfg, accountId }).profile;
    },
    updateConfigProfile: async (accountId, profile) => {
      const cfg = getNostrRuntime().config.loadConfig();
      await getNostrRuntime().config.writeConfigFile({
        ...cfg,
        channels: { ...cfg.channels, nostr: { ...cfg.channels.nostr, profile } },
      });
    },
    getAccountInfo: (accountId) => {
      // Return public key and relay list
    },
  });
  api.registerHttpHandler(httpHandler);
}
```

This shows that plugin registration capabilities are not limited to channels—it can simultaneously register HTTP endpoints to provide management interfaces for Web UI or external tools.

> **Sidebar**: **Nostr (Notes and Other Stuff Transmitted by Relays)** is an extremely minimalist decentralized protocol. Unlike Matrix, Nostr has no concept of server accounts—a user's identity is simply a pair of keys. Messages (called Events) are signed with the private key and published to multiple Relays (relay servers), and receivers subscribe to messages of interest from Relays. NIP-04 is Nostr's encrypted direct message specification.

### Core Components

The Nostr extension's `src/` directory has several noteworthy modules:

* **`nostr-bus.ts`**: Message bus managing WebSocket connections to multiple Relays
* **`nostr-state-store.ts`**: State persistence, recording processed event IDs
* **`seen-tracker.ts`**: Event deduplication, avoiding duplicate processing when receiving the same message from multiple Relays
* **`nostr-profile.ts`**: Nostr Profile (NIP-05) management

***

## 21.3.5 Google Chat Extension

### Overview

Google Chat uses **Webhook push** mode, similar to MS Teams.

| Feature                | Description                    |
| ---------------------- | ------------------------------ |
| Communication Protocol | Google Chat API (HTTP Webhook) |
| Authentication         | Google Cloud Service Account   |
| Message Reception      | HTTP Webhook push              |
| Message Sending        | Google Chat REST API           |

### Entry Registration: Dock + HTTP Handler

Google Chat's registration demonstrates another pattern—simultaneously registering both `dock` and `httpHandler`:

```typescript
// extensions/googlechat/index.ts
register(api: OpenClawPluginApi) {
  setGoogleChatRuntime(api.runtime);
  api.registerChannel({ plugin: googlechatPlugin, dock: googlechatDock });
  api.registerHttpHandler(handleGoogleChatWebhookRequest);
}
```

`dock` is the `ChannelDock` introduced in Chapter 19, providing a channel-level message processing pipeline. `httpHandler` directly handles Webhook requests from Google. This separation design allows Webhook processing and message pipeline to evolve independently.

***

## 21.3.6 Zalo / Zalo Personal Extensions

### Overview

Zalo is Vietnam's largest instant messaging platform. OpenClaw provides **two** Zalo extensions:

| Extension             | Protocol                      | Use Case                    |
| --------------------- | ----------------------------- | --------------------------- |
| `zalo` (Bot API)      | Zalo Official Account API     | Enterprise customer service |
| `zalouser` (Personal) | zca-cli (reverse engineering) | Personal account automation |

### Zalo Bot API

```typescript
// extensions/zalo/index.ts
register(api: OpenClawPluginApi) {
  setZaloRuntime(api.runtime);
  api.registerChannel({ plugin: zaloPlugin, dock: zaloDock });
  api.registerHttpHandler(handleZaloWebhookRequest);  // Webhook reception
}
```

The structure is very similar to Google Chat—Webhook reception + REST API sending.

### Zalo Personal: Tool Registration

The Zalo Personal extension demonstrates a unique pattern—in addition to registering a channel, it also registers an **Agent tool**:

```typescript
// extensions/zalouser/index.ts
register(api: OpenClawPluginApi) {
  setZalouserRuntime(api.runtime);
  api.registerChannel({ plugin: zalouserPlugin, dock: zalouserDock });
  
  // Register Agent tool — allow AI to actively operate Zalo
  api.registerTool({
    name: "zalouser",
    label: "Zalo Personal",
    description: "Send messages and access data via Zalo personal account. " +
      "Actions: send, image, link, friends, groups, me, status.",
    parameters: ZalouserToolSchema,
    execute: executeZalouserTool,
  });
}
```

This means that when users chat with AI through Zalo Personal, the AI can not only reply to messages but also actively send messages, query friend lists, check authentication status, etc. through tool calls—capabilities that pure channel registration cannot achieve.

***

## 21.3.7 Feishu (Lark) Extension

### Overview

The Feishu extension is the **most feature-rich** official extension, with `extensions/feishu/src/` containing 30 source files.

| Feature                | Description                                                                                   |
| ---------------------- | --------------------------------------------------------------------------------------------- |
| Communication Protocol | Feishu Open Platform API                                                                      |
| Authentication         | App ID + App Secret                                                                           |
| Message Reception      | Feishu event subscription (HTTP Webhook)                                                      |
| Special Features       | Multi-dimensional tables, cloud documents, knowledge base, cloud drive, permission management |

### Entry Registration: Most Comprehensive Registration Pattern

The Feishu extension demonstrates the most complex registration pattern—in addition to the channel, it also registers **5 groups of Agent tools**:

```typescript
// extensions/feishu/index.ts
register(api: OpenClawPluginApi) {
  setFeishuRuntime(api.runtime);
  api.registerChannel({ plugin: feishuPlugin });
  
  // Register Feishu cloud document tools
  registerFeishuDocTools(api);    // Create/edit Feishu documents
  registerFeishuWikiTools(api);   // Operate knowledge base
  registerFeishuDriveTools(api);  // Cloud drive file operations
  registerFeishuPermTools(api);   // Permission management
  registerFeishuBitableTools(api); // Multi-dimensional table operations
}
```

This allows AI Agents in the Feishu channel to not only chat but also directly operate Feishu's office suite—creating documents, querying knowledge bases, managing file permissions, reading and writing multi-dimensional tables. This is a perfect embodiment of OpenClaw's plugin system design philosophy: **channels are not just message pipelines, but capability entry points**.

### Source Code Module Overview

```
extensions/feishu/src/
├── channel.ts          # ChannelPlugin definition
├── monitor.ts          # Event subscription listening
├── send.ts             # Message/card sending
├── media.ts            # Image/file upload
├── mention.ts          # @mention parsing
├── reactions.ts        # Emoji reactions
├── typing.ts           # Typing indicator
├── docx.ts             # Cloud document tools
├── wiki.ts             # Knowledge base tools
├── drive.ts            # Cloud drive tools
├── perm.ts             # Permission management tools
├── bitable.ts          # Multi-dimensional table tools
├── doc-schema.ts       # Document tool Schema
├── wiki-schema.ts      # Knowledge base tool Schema
├── drive-schema.ts     # Cloud drive tool Schema
├── perm-schema.ts      # Permission tool Schema
└── tools-config.ts     # Tool configuration
```

Feishu also provides preset Agent Skills in the `skills/` directory, further enhancing AI capabilities in Feishu scenarios.

***

## 21.3.8 LINE Extension

### Overview

LINE is the most popular instant messaging application in Japan and Southeast Asia.

| Feature                | Description                                                               |
| ---------------------- | ------------------------------------------------------------------------- |
| Communication Protocol | LINE Messaging API (HTTP Webhook + REST)                                  |
| Authentication         | Channel Access Token                                                      |
| Message Reception      | Webhook push                                                              |
| Special Features       | Flex Message (rich content templates), Markdown to LINE format conversion |

### Entry Registration: Command Registration

```typescript
// extensions/line/index.ts
register(api: OpenClawPluginApi) {
  setLineRuntime(api.runtime);
  api.registerChannel({ plugin: linePlugin });
  registerLineCardCommand(api);  // Register /card command
}
```

The LINE extension uses `registerCommand()` to register custom commands—users can send `/card` to send LINE Flex Message cards.

### Flex Message and Markdown Conversion

The most unique technical feature of the LINE extension is **Markdown → LINE Flex Message** conversion. Since LINE doesn't support Markdown, the extension provides a complete conversion pipeline:

```typescript
// LINE tools exported via plugin-sdk
export { processLineMessage, hasMarkdownToConvert, stripMarkdown } from "../line/markdown-to-line.js";
export { createInfoCard, createListCard, createImageCard,
         createActionCard, createReceiptCard } from "../line/flex-templates.js";
```

These functions convert Markdown text generated by the Agent into LINE's native Flex Message JSON structure, rendering as beautiful card-style messages on mobile.

***

## Summary of Extension Patterns

By analyzing 8 representative extensions, we can identify several typical registration patterns:

| Pattern               | Representative           | Registration Content                          |
| --------------------- | ------------------------ | --------------------------------------------- |
| **Pure Channel**      | MS Teams, Matrix, Twitch | `registerChannel()`                           |
| **Channel + Dock**    | Google Chat, Zalo        | `registerChannel({ dock })`                   |
| **Channel + HTTP**    | Nostr, Google Chat       | `registerChannel()` + `registerHttpHandler()` |
| **Channel + Tools**   | Zalo Personal, Feishu    | `registerChannel()` + `registerTool()`        |
| **Channel + Command** | LINE                     | `registerChannel()` + `registerCommand()`     |
| **Full-Featured**     | Feishu                   | Channel + 5 tool groups + Skills              |

All extensions share a fixed entry pattern:

```typescript
const plugin = {
  id: "...",
  configSchema: emptyPluginConfigSchema(),
  register(api: OpenClawPluginApi) {
    setXxxRuntime(api.runtime);      // 1. Cache runtime
    api.registerChannel({ ... });     // 2. Register channel
    // 3. Optional: register tools/commands/HTTP/services
  },
};
export default plugin;
```

***

## Summary of This Section

1. **MS Teams extension** is representative of Webhook push mode, receiving Bot Framework messages through an Express HTTP server and supporting Adaptive Cards rich content cards.
2. **Matrix extension** demonstrates integration of decentralized protocols, requiring handling of multiple Homeservers, sigil ID formats, E2EE encryption, and other special requirements; native dependencies are the main reason it's placed in an extension.
3. **Twitch extension** is based on IRC protocol, the most minimalist of all extensions—no threading, no media, plain text only.
4. **Nostr extension**, in addition to channel registration, exposes Profile management API through `registerHttpHandler()`, demonstrating the multi-dimensional registration capabilities of plugins.
5. **Feishu extension is the most feature-rich official extension**, registering cloud documents, knowledge base, cloud drive, permissions, and multi-dimensional tables tool groups in addition to the channel, embodying the "channel as capability entry point" design philosophy.
6. **All extensions share a fixed entry pattern**: cache Runtime → register channel → optionally register additional capabilities. Configuration is declared through the `openclaw.plugin.json` manifest, with plugin IDs globally unique.
