-
Notifications
You must be signed in to change notification settings - Fork 1.6k
en workshop impl platform adapter
This article will use the aiocqhttp adapter as an example to explain how to implement a new message platform adapter for LangBot, in order to integrate new message platform protocols such as WhatsApp and Discord.
Add a new message platform adapter, for example: integrate WhatsApp, Discord, etc.
- Base class: `pkg.platform.adapter.MessageSourceAdapter`
- Decorator: `pkg.platform.adapter.adapter_class(name: str)`
- Reference implementation: `pkg.platform.sources/`
To implement a message platform adapter, we essentially need to implement a class that inherits from the base class and register it using the decorator. Finally, it will be available for users to select and use during runtime.
Create a new file aiocqhttp.py in the pkg/platform/sources/ directory:
from .. import adapter
@adapter.adapter_class("aiocqhttp")
class AiocqhttpAdapter(adapter.MessageSourceAdapter):
passAlso import this module in pkg/platform/manager.py at line 40:
from .sources import nakuru, aiocqhttp, qqbotpyFinally, write your own manifest file by referring to other adapters' manifest files.
The main work of a message platform adapter is to receive events from the message platform protocol, convert them into LangBot's format, pass them to the core components, and after LangBot's core components process them, pass the content that needs to be replied to the message platform adapter, which then converts the content into the platform protocol format and sends it to the message platform.
The following diagram shows the processing patterns for two scenarios: message platform protocol without SDK and with mature SDK. In the first case, we need to implement connection management and network format data conversion to LB message Python objects according to the message platform protocol documentation. In the second case, the message platform has a mature SDK, we only need to create connections according to the SDK documentation, register event listeners, and implement message converters.

In the pkg.platform.sources.aiocqhttp file, we can see not only AiocqhttpAdapter, but also class AiocqhttpMessageConverter(adapter.MessageConverter): and class AiocqhttpEventConverter(adapter.EventConverter):.
-
MessageConverteris used for converting between LangBot messages and platform messages. -
EventConverteris used for converting between LangBot events and platform events.
TBC...
Automatically synchronized from langbot-app/langbot-wiki.
简体中文
指南
开发者
- 插件开发
- 插件 SDK API
- 核心开发
文章
- 浏览
- 产品动态
- 技术解析
- 教程与集成
- 公告
API 参考
- Service API
English
Guides
Developers
-
Plugin Development
- Plugin Development Tutorial
- Completing Plugin Configuration Information
- Plugin Directory Structure
- Component Development
- Code Style Guide
- Migration Guide
- Publish Plugin
- Plugin SDK API
- Core Development
Articles
- Browse
- Product Updates
- Engineering
-
Tutorials & Integrations
- LangTARS: Open-Source AI Agent for Remote PC Control — Works with Dify, n8n & 10+ Messaging Platforms
- How to Connect DeepSeek R1 to WeChat, Discord & Telegram in 5 Minutes (FREE)
- Deploy Your Own AI Bot to Discord, Telegram & WeChat in 5 Minutes
- Finally Got My Dify Agent Working in Discord, Telegram and Slack
- How I Built a Multi-Platform AI Bot with Langflow's Drag-and-Drop Workflows
- How I Built a Multi-Platform AI Chatbot with n8n and LangBot
- LangBot 4.6.0 External Knowledge Base Tutorial: Integrating Dify with LangBot for RAG-powered Conversations
- Announcements
API Reference
- Service API
Other pages
日本語
ガイド
開発者
- プラグイン開発
- プラグイン SDK API
- コア開発
記事
- 一覧
- 製品アップデート
- エンジニアリング
-
チュートリアルと連携
- LangTARS:Dify・n8n と連携するオープンソース PC 操作 Agent
- DeepSeek R1 を WeChat・Discord・Telegram に5分で接続する方法
- AI Bot を Discord・Telegram・WeChat に5分でデプロイ
- Dify Agent を Discord・Telegram・Slack で動かす
- Langflow のドラッグ&ドロップでマルチプラットフォーム AI Bot を構築
- n8n と LangBot でマルチプラットフォーム AI Chatbot を構築
- LangBot 4.6.0 外部ナレッジベース入門:Dify と連携した RAG 会話
- お知らせ
API リファレンス
- Service API