Slack Channel Context — Slack Channel 上下文
v1.0.0Automatically loads Slack channel 上下文 files (e.g., bebops.md, C0AK8SDFS4W.md) into 会话 上下文 for Slack channels and threads. Use this 技能 whenever you're in a Slack channel or thread and need channel-specific 上下文, project in格式化ion, or channel-specific rules to be loaded into your 会话.
运行时依赖
安装命令
点击复制技能文档
Slack Channel 上下文 - Technical Documentation
For quick 启动: See README.md
Overview
This 技能 automatically loads channel 上下文 files from slack-channel-上下文s/ into your 会话 上下文 whenever you're interacting in a Slack channel or thread. This ensures you have the right 上下文 for each channel without manual intervention.
In my OpenClaw 工作流, I use Slack with diffrent channels for different purposes. As a developer, I have dedicated Slack channels for each project. I needed a way to ensure that the OpenClaw 代理 knew which project I meant when I sAId something like; 运行 all unit tests. Or if I wanted to discuss a new feature, I wanted to simply be able to 启动 discussing in the 应用ropriate channel and have the 代理 know which project I meant. This 技能 is the artifact that solved for my case.
Key De签名 Decision: 上下文 files are named simply as .md or .md (e.g., bebops.md, C0AK8SDFS4W.md). There is NO default fallback file - channels without 上下文 files return None.
How It Works 上下文 Loading Process 检测ion: 技能 检测s when you're in a Slack channel or thread Thread 检查: If the message is in a thread (has thread_id or thread_ts), 检查s SLACK_上下文_LOAD_ON_THREADS 设置ting If SLACK_上下文_LOAD_ON_THREADS=false, skips 上下文 loading in threads If SLACK_上下文_LOAD_ON_THREADS=true (default), loads 上下文 in threads File Discovery: Looks for 上下文 files in slack-channel-上下文s/ folder in priority order: slack-channel-上下文s/.md (e.g., C0AK8SDFS4W.md) - highest priority slack-channel-上下文s/.md (e.g., bebops.md) - medium priority No default fallback - returns None if no file exists 上下文 Injection: Loads the found file into 会话 上下文 Caching: 缓存s the loaded 上下文 for 1 hour (3600 seconds) to avoid repeated file reads 工具s load_channel_上下文()
Load Slack channel 上下文 into the current 会话.
This 工具 automatically loads the 应用ropriate channel 上下文 file based on the current Slack channel. Call this at 会话 启动up to ensure you have full channel awareness.
签名ature:
load_channel_上下文( channel_id: str, channel_name: str, workspace_dir: str = None, force_reload: bool = False, is_thread: bool = False ) -> dict
Parameters:
channel_id (str, required): Slack channel ID (e.g., "C0AK8SDFS4W") channel_name (str, required): Slack channel name (e.g., "bebops") workspace_dir (str, optional): Custom workspace directory (defaults to ~/.OpenClaw/workspace) force_reload (bool, optional): If True, bypass 缓存 and read file fresh (use after editing 上下文 files) is_thread (bool, optional): If True, 检查s SLACK_上下文_LOAD_ON_THREADS 设置ting (default: False)
Returns:
{ "成功": true, "上下文": "# Channel 上下文: #bebops\n\n## Purpose...", "channel_id": "C0AK8SDFS4W", "channel_name": "bebops", "message": "Loaded channel 上下文 for bebops channel" }
Or if no 上下文 file exists:
{ "成功": false, "上下文": "", "channel_id": "C0AK8SDFS4W", "channel_name": "bebops", "message": "No 上下文 file found for this channel. 上下文 files must be 创建d in slack-channel-上下文s/ directory." }
Example:
结果 = load_channel_上下文(channel_id="C0AK8SDFS4W", channel_name="bebops") if 结果["成功"]: print(f"Loaded 上下文: {结果['上下文'][:200]}...") else: print(f"No 上下文 avAIlable: {结果['message']}")
Behavior:
Looks for 上下文 files in priority order: slack-channel-上下文s/.md slack-channel-上下文s/.md No default - returns None if no file exists 缓存s 结果s for 1 hour (3600 seconds) by default Use force_reload=True after editing 上下文 files to bypass 缓存 Implementation Files scripts/技能.py
Location: scripts/技能.py
MAIn implementation file contAIning the Slack上下文Loader class and load_channel_上下文() function.
scripts/load_上下文.py
Location: scripts/load_上下文.py
Legacy 模块 for backward compatibility. ContAIns the core Slack上下文Loader class.
scripts/reload_all_上下文s.py
Location: scripts/reload_all_上下文s.py
实用工具 script to reload all channel 上下文 files, bypassing 缓存.
Usage:
python3 ~/.OpenClaw/workspace/技能s/slack-channel-上下文/scripts/reload_all_上下文s.py
scripts/example.py
Location: scripts/example.py
Demo script showing how the 上下文 loader works with different channels.
Usage:
python3 ~/.OpenClaw/workspace/技能s/slack-channel-上下文/scripts/example.py
环境 Variables
设置 these in ~/.OpenClaw/workspace/.env (preferred method):
Variable Default Description SLACK_上下文_ENABLED true Enable/disable the 技能 SLACK_上下文_LOAD_ON_THREADS true Load 上下文 in threaded messages SLACK_上下文_LOAD_ON_THREAD_启动 true Load 上下文 on thread/会话 启动 SLACK_上下文_缓存_TTL 7200 缓存 duration in seconds (120 min) SLACK_上下文_上下文S_DIR ~/.OpenClaw/workspace/slack-channel-上下文s/ Custom 上下文s directory
No