configure-notifications

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Configure Notifications

配置通知

Set up OMC notification integrations so you're alerted when sessions end, need input, or complete background tasks.
设置OMC通知集成,以便在会话结束、需要输入或完成后台任务时向你发送提醒。

Routing

路由规则

Detect which provider the user wants based on their request or argument:
  • If the trigger or argument contains "telegram" → follow the Telegram section
  • If the trigger or argument contains "discord" → follow the Discord section
  • If the trigger or argument contains "slack" → follow the Slack section
  • If no provider is specified, use AskUserQuestion:
Question: "Which notification service would you like to configure?"
Options:
  1. Telegram - Bot token + chat ID. Works on mobile and desktop.
  2. Discord - Webhook or bot token + channel ID.
  3. Slack - Incoming webhook URL.

根据用户的请求或参数检测其想要使用的服务提供商:
  • 如果触发词或参数包含"telegram" → 参考Telegram部分
  • 如果触发词或参数包含"discord" → 参考Discord部分
  • 如果触发词或参数包含"slack" → 参考Slack部分
  • 如果未指定服务提供商,使用AskUserQuestion:
问题: "你想要配置哪个通知服务?"
选项:
  1. Telegram - 需要机器人令牌 + 聊天ID,支持移动端和桌面端
  2. Discord - 需要Webhook或机器人令牌 + 频道ID
  3. Slack - 需要传入Webhook URL

Telegram Setup

Telegram设置

Set up Telegram notifications so OMC can message you when sessions end, need input, or complete background tasks.
配置Telegram通知,这样OMC就可以在会话结束、需要输入或完成后台任务时给你发消息。

How This Skill Works

功能说明

This is an interactive, natural-language configuration skill. Walk the user through setup by asking questions with AskUserQuestion. Write the result to
~/.claude/.omc-config.json
.
这是一个交互式的自然语言配置技能,通过AskUserQuestion提问引导用户完成配置,最终将结果写入
~/.claude/.omc-config.json

Step 1: Detect Existing Configuration

步骤1:检测现有配置

bash
CONFIG_FILE="$HOME/.claude/.omc-config.json"

if [ -f "$CONFIG_FILE" ]; then
  HAS_TELEGRAM=$(jq -r '.notifications.telegram.enabled // false' "$CONFIG_FILE" 2>/dev/null)
  CHAT_ID=$(jq -r '.notifications.telegram.chatId // empty' "$CONFIG_FILE" 2>/dev/null)
  PARSE_MODE=$(jq -r '.notifications.telegram.parseMode // "Markdown"' "$CONFIG_FILE" 2>/dev/null)

  if [ "$HAS_TELEGRAM" = "true" ]; then
    echo "EXISTING_CONFIG=true"
    echo "CHAT_ID=$CHAT_ID"
    echo "PARSE_MODE=$PARSE_MODE"
  else
    echo "EXISTING_CONFIG=false"
  fi
else
  echo "NO_CONFIG_FILE"
fi
If existing config is found, show the user what's currently configured and ask if they want to update or reconfigure.
bash
CONFIG_FILE="$HOME/.claude/.omc-config.json"

if [ -f "$CONFIG_FILE" ]; then
  HAS_TELEGRAM=$(jq -r '.notifications.telegram.enabled // false' "$CONFIG_FILE" 2>/dev/null)
  CHAT_ID=$(jq -r '.notifications.telegram.chatId // empty' "$CONFIG_FILE" 2>/dev/null)
  PARSE_MODE=$(jq -r '.notifications.telegram.parseMode // "Markdown"' "$CONFIG_FILE" 2>/dev/null)

  if [ "$HAS_TELEGRAM" = "true" ]; then
    echo "EXISTING_CONFIG=true"
    echo "CHAT_ID=$CHAT_ID"
    echo "PARSE_MODE=$PARSE_MODE"
  else
    echo "EXISTING_CONFIG=false"
  fi
else
  echo "NO_CONFIG_FILE"
fi
如果检测到现有配置,向用户展示当前配置内容,并询问是否需要更新或重新配置。

Step 2: Create a Telegram Bot

步骤2:创建Telegram机器人

Guide the user through creating a bot if they don't have one:
To set up Telegram notifications, you need a Telegram bot token and your chat ID.

CREATE A BOT (if you don't have one):
1. Open Telegram and search for @BotFather
2. Send /newbot
3. Choose a name (e.g., "My OMC Notifier")
4. Choose a username (e.g., "my_omc_bot")
5. BotFather will give you a token like: 123456789:ABCdefGHIjklMNOpqrsTUVwxyz

GET YOUR CHAT ID:
1. Start a chat with your new bot (send /start)
2. Visit: https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates
3. Look for "chat":{"id":YOUR_CHAT_ID}
   - Personal chat IDs are positive numbers (e.g., 123456789)
   - Group chat IDs are negative numbers (e.g., -1001234567890)
如果用户还没有Telegram机器人,引导其完成创建:
要设置Telegram通知,你需要一个Telegram机器人令牌和你的聊天ID。

创建机器人(如果还没有的话):
1. 打开Telegram,搜索@BotFather
2. 发送/newbot命令
3. 为机器人设置名称(比如:"我的OMC通知机器人")
4. 为机器人设置用户名(比如:"my_omc_bot")
5. BotFather会给你一个类似这样的令牌:123456789:ABCdefGHIjklMNOpqrsTUVwxyz

获取你的聊天ID:
1. 和你新创建的机器人发起聊天(发送/start命令)
2. 访问地址:https://api.telegram.org/bot<你的机器人令牌>/getUpdates
3. 查找"chat":{"id":你的聊天ID}字段
   - 私人聊天ID是正数(比如:123456789)
   - 群组聊天ID是负数(比如:-1001234567890)

Step 3: Collect Bot Token

步骤3:收集机器人令牌

Use AskUserQuestion:
Question: "Paste your Telegram bot token (from @BotFather)"
The user will type their token in the "Other" field.
Validate the token:
  • Must match pattern:
    digits:alphanumeric
    (e.g.,
    123456789:ABCdefGHI...
    )
  • If invalid, explain the format and ask again
使用AskUserQuestion:
问题: "请粘贴你的Telegram机器人令牌(来自@BotFather)"
用户会在"其他"字段输入他们的令牌。
校验令牌格式:
  • 必须匹配
    数字:字母数字组合
    的格式(比如:
    123456789:ABCdefGHI...
  • 如果格式无效,说明正确格式并重新询问

Step 4: Collect Chat ID

步骤4:收集聊天ID

Use AskUserQuestion:
Question: "Paste your Telegram chat ID (the number from getUpdates API)"
The user will type their chat ID in the "Other" field.
Validate the chat ID:
  • Must be a number (positive for personal, negative for groups)
  • If invalid, offer to help them find it:
bash
undefined
使用AskUserQuestion:
问题: "请粘贴你的Telegram聊天ID(来自getUpdates API的数字)"
用户会在"其他"字段输入他们的聊天ID。
校验聊天ID格式:
  • 必须是数字(私人聊天为正,群组聊天为负)
  • 如果格式无效,提供帮助用户查找的方法:
bash
undefined

Help user find their chat ID

帮助用户查找聊天ID

BOT_TOKEN="USER_PROVIDED_TOKEN" echo "Fetching recent messages to find your chat ID..." curl -s "https://api.telegram.org/bot${BOT_TOKEN}/getUpdates" | jq '.result[-1].message.chat.id // .result[-1].message.from.id // "No messages found - send /start to your bot first"'
undefined
BOT_TOKEN="用户提供的令牌" echo "正在获取最近消息以查找你的聊天ID..." curl -s "https://api.telegram.org/bot${BOT_TOKEN}/getUpdates" | jq '.result[-1].message.chat.id // .result[-1].message.from.id // "未找到消息 - 请先给你的机器人发送/start命令"'
undefined

Step 5: Choose Parse Mode

步骤5:选择解析模式

Use AskUserQuestion:
Question: "Which message format do you prefer?"
Options:
  1. Markdown (Recommended) - Bold, italic, code blocks with Markdown syntax
  2. HTML - Bold, italic, code with HTML tags
使用AskUserQuestion:
问题: "你偏好哪种消息格式?"
选项:
  1. Markdown(推荐) - 支持Markdown语法的粗体、斜体、代码块
  2. HTML - 支持HTML标签的粗体、斜体、代码

Step 6: Configure Events

步骤6:配置触发事件

Use AskUserQuestion with multiSelect:
Question: "Which events should trigger Telegram notifications?"
Options (multiSelect: true):
  1. Session end (Recommended) - When a Claude session finishes
  2. Input needed - When Claude is waiting for your response (great for long-running tasks)
  3. Session start - When a new session begins
  4. Session continuing - When a persistent mode keeps the session alive
Default selection: session-end + ask-user-question.
使用支持多选的AskUserQuestion:
问题: "哪些事件应该触发Telegram通知?"
选项(支持多选:是):
  1. 会话结束(推荐) - 当Claude会话完成时
  2. 需要输入 - 当Claude等待你的响应时(非常适合长时间运行的任务)
  3. 会话开始 - 当新会话启动时
  4. 会话持续中 - 当持久化模式保持会话存活时
默认选中:session-end + ask-user-question

Step 7: Write Configuration

步骤7:写入配置

Read the existing config, merge the new Telegram settings, and write back:
bash
CONFIG_FILE="$HOME/.claude/.omc-config.json"
mkdir -p "$(dirname "$CONFIG_FILE")"

if [ -f "$CONFIG_FILE" ]; then
  EXISTING=$(cat "$CONFIG_FILE")
else
  EXISTING='{}'
fi
读取现有配置,合并新的Telegram设置,再写回配置文件:
bash
CONFIG_FILE="$HOME/.claude/.omc-config.json"
mkdir -p "$(dirname "$CONFIG_FILE")"

if [ -f "$CONFIG_FILE" ]; then
  EXISTING=$(cat "$CONFIG_FILE")
else
  EXISTING='{}'
fi

BOT_TOKEN, CHAT_ID, PARSE_MODE are collected from user

BOT_TOKEN、CHAT_ID、PARSE_MODE都是从用户处收集的值

echo "$EXISTING" | jq
--arg token "$BOT_TOKEN"
--arg chatId "$CHAT_ID"
--arg parseMode "$PARSE_MODE"
'.notifications = (.notifications // {enabled: true}) | .notifications.enabled = true | .notifications.telegram = { enabled: true, botToken: $token, chatId: $chatId, parseMode: $parseMode }' > "$CONFIG_FILE"
undefined
echo "$EXISTING" | jq
--arg token "$BOT_TOKEN"
--arg chatId "$CHAT_ID"
--arg parseMode "$PARSE_MODE"
'.notifications = (.notifications // {enabled: true}) | .notifications.enabled = true | .notifications.telegram = { enabled: true, botToken: $token, chatId: $chatId, parseMode: $parseMode }' > "$CONFIG_FILE"
undefined

Add event-specific config if user didn't select all events:

如果用户没有选中所有事件,添加事件专属配置:

For each event NOT selected, disable it:
bash
undefined
对每个未选中的事件,将其禁用:
bash
undefined

Example: disable session-start if not selected

示例:如果未选中会话开始则禁用该事件

echo "$(cat "$CONFIG_FILE")" | jq
'.notifications.events = (.notifications.events // {}) | .notifications.events["session-start"] = {enabled: false}' > "$CONFIG_FILE"
undefined
echo "$(cat "$CONFIG_FILE")" | jq
'.notifications.events = (.notifications.events // {}) | .notifications.events["session-start"] = {enabled: false}' > "$CONFIG_FILE"
undefined

Step 8: Test the Configuration

步骤8:测试配置

After writing config, offer to send a test notification:
Use AskUserQuestion:
Question: "Send a test notification to verify the setup?"
Options:
  1. Yes, test now (Recommended) - Send a test message to your Telegram chat
  2. No, I'll test later - Skip testing
写入配置后,询问用户是否要发送测试通知:
使用AskUserQuestion:
问题: "是否发送测试通知验证设置是否正常?"
选项:
  1. 是,现在测试(推荐) - 发送测试消息到你的Telegram聊天
  2. 否,稍后再测试 - 跳过测试

If testing:

如果选择测试:

bash
BOT_TOKEN="USER_PROVIDED_TOKEN"
CHAT_ID="USER_PROVIDED_CHAT_ID"
PARSE_MODE="Markdown"

RESPONSE=$(curl -s -w "\n%{http_code}" \
  "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
  -d "chat_id=${CHAT_ID}" \
  -d "parse_mode=${PARSE_MODE}" \
  -d "text=OMC test notification - Telegram is configured!")

HTTP_CODE=$(echo "$RESPONSE" | tail -1)
BODY=$(echo "$RESPONSE" | head -1)

if [ "$HTTP_CODE" = "200" ]; then
  echo "Test notification sent successfully!"
else
  echo "Failed (HTTP $HTTP_CODE):"
  echo "$BODY" | jq -r '.description // "Unknown error"' 2>/dev/null || echo "$BODY"
fi
Report success or failure. Common issues:
  • 401 Unauthorized: Bot token is invalid
  • 400 Bad Request: chat not found: Chat ID is wrong, or user hasn't sent
    /start
    to the bot
  • Network error: Check connectivity to api.telegram.org
bash
BOT_TOKEN="用户提供的令牌"
CHAT_ID="用户提供的聊天ID"
PARSE_MODE="Markdown"

RESPONSE=$(curl -s -w "\n%{http_code}" \
  "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
  -d "chat_id=${CHAT_ID}" \
  -d "parse_mode=${PARSE_MODE}" \
  -d "text=OMC测试通知 - Telegram已配置成功!")

HTTP_CODE=$(echo "$RESPONSE" | tail -1)
BODY=$(echo "$RESPONSE" | head -1)

if [ "$HTTP_CODE" = "200" ]; then
  echo "测试通知发送成功!"
else
  echo "发送失败(HTTP $HTTP_CODE):"
  echo "$BODY" | jq -r '.description // "未知错误"' 2>/dev/null || echo "$BODY"
fi
上报成功或失败结果。常见问题:
  • 401未授权:机器人令牌无效
  • 400错误请求:聊天未找到:聊天ID错误,或者用户还没有给机器人发送
    /start
    命令
  • 网络错误:检查到api.telegram.org的网络连接

Step 9: Confirm

步骤9:确认完成

Display the final configuration summary:
Telegram Notifications Configured!

  Bot:        @your_bot_username
  Chat ID:    123456789
  Format:     Markdown
  Events:     session-end, ask-user-question

Config saved to: ~/.claude/.omc-config.json

You can also set these via environment variables:
  OMC_TELEGRAM_BOT_TOKEN=123456789:ABCdefGHI...
  OMC_TELEGRAM_CHAT_ID=123456789

To reconfigure: /oh-my-claudecode:configure-notifications telegram
To configure Discord: /oh-my-claudecode:configure-notifications discord
To configure Slack: /oh-my-claudecode:configure-notifications slack
展示最终的配置汇总:
Telegram通知已配置完成!

  机器人:      @你的机器人用户名
  聊天ID:    123456789
  格式:     Markdown
  触发事件:     session-end, ask-user-question

配置已保存到: ~/.claude/.omc-config.json

你也可以通过环境变量设置这些配置:
  OMC_TELEGRAM_BOT_TOKEN=123456789:ABCdefGHI...
  OMC_TELEGRAM_CHAT_ID=123456789

重新配置命令: /oh-my-claudecode:configure-notifications telegram
配置Discord通知: /oh-my-claudecode:configure-notifications discord
配置Slack通知: /oh-my-claudecode:configure-notifications slack

Environment Variable Alternative

环境变量替代方案

Users can skip this wizard entirely by setting env vars in their shell profile:
bash
export OMC_TELEGRAM_BOT_TOKEN="123456789:ABCdefGHIjklMNOpqrsTUVwxyz"
export OMC_TELEGRAM_CHAT_ID="123456789"
Env vars are auto-detected by the notification system without needing
.omc-config.json
.

用户可以通过在shell配置文件中设置环境变量,完全跳过这个配置向导:
bash
export OMC_TELEGRAM_BOT_TOKEN="123456789:ABCdefGHIjklMNOpqrsTUVwxyz"
export OMC_TELEGRAM_CHAT_ID="123456789"
通知系统会自动检测环境变量,不需要
.omc-config.json
文件。

Discord Setup

Discord设置

Set up Discord notifications so OMC can ping you when sessions end, need input, or complete background tasks.
配置Discord通知,这样OMC就可以在会话结束、需要输入或完成后台任务时提醒你。

How This Skill Works

功能说明

This is an interactive, natural-language configuration skill. Walk the user through setup by asking questions with AskUserQuestion. Write the result to
~/.claude/.omc-config.json
.
这是一个交互式的自然语言配置技能,通过AskUserQuestion提问引导用户完成配置,最终将结果写入
~/.claude/.omc-config.json

Step 1: Detect Existing Configuration

步骤1:检测现有配置

bash
CONFIG_FILE="$HOME/.claude/.omc-config.json"

if [ -f "$CONFIG_FILE" ]; then
  # Check for existing discord config
  HAS_DISCORD=$(jq -r '.notifications.discord.enabled // false' "$CONFIG_FILE" 2>/dev/null)
  HAS_DISCORD_BOT=$(jq -r '.notifications["discord-bot"].enabled // false' "$CONFIG_FILE" 2>/dev/null)
  WEBHOOK_URL=$(jq -r '.notifications.discord.webhookUrl // empty' "$CONFIG_FILE" 2>/dev/null)
  MENTION=$(jq -r '.notifications.discord.mention // empty' "$CONFIG_FILE" 2>/dev/null)

  if [ "$HAS_DISCORD" = "true" ] || [ "$HAS_DISCORD_BOT" = "true" ]; then
    echo "EXISTING_CONFIG=true"
    echo "WEBHOOK_CONFIGURED=$HAS_DISCORD"
    echo "BOT_CONFIGURED=$HAS_DISCORD_BOT"
    [ -n "$WEBHOOK_URL" ] && echo "WEBHOOK_URL=$WEBHOOK_URL"
    [ -n "$MENTION" ] && echo "MENTION=$MENTION"
  else
    echo "EXISTING_CONFIG=false"
  fi
else
  echo "NO_CONFIG_FILE"
fi
If existing config is found, show the user what's currently configured and ask if they want to update or reconfigure.
bash
CONFIG_FILE="$HOME/.claude/.omc-config.json"

if [ -f "$CONFIG_FILE" ]; then
  # 检查现有Discord配置
  HAS_DISCORD=$(jq -r '.notifications.discord.enabled // false' "$CONFIG_FILE" 2>/dev/null)
  HAS_DISCORD_BOT=$(jq -r '.notifications["discord-bot"].enabled // false' "$CONFIG_FILE" 2>/dev/null)
  WEBHOOK_URL=$(jq -r '.notifications.discord.webhookUrl // empty' "$CONFIG_FILE" 2>/dev/null)
  MENTION=$(jq -r '.notifications.discord.mention // empty' "$CONFIG_FILE" 2>/dev/null)

  if [ "$HAS_DISCORD" = "true" ] || [ "$HAS_DISCORD_BOT" = "true" ]; then
    echo "EXISTING_CONFIG=true"
    echo "WEBHOOK_CONFIGURED=$HAS_DISCORD"
    echo "BOT_CONFIGURED=$HAS_DISCORD_BOT"
    [ -n "$WEBHOOK_URL" ] && echo "WEBHOOK_URL=$WEBHOOK_URL"
    [ -n "$MENTION" ] && echo "MENTION=$MENTION"
  else
    echo "EXISTING_CONFIG=false"
  fi
else
  echo "NO_CONFIG_FILE"
fi
如果检测到现有配置,向用户展示当前配置内容,并询问是否需要更新或重新配置。

Step 2: Choose Discord Method

步骤2:选择Discord通知方式

Use AskUserQuestion:
Question: "How would you like to send Discord notifications?"
Options:
  1. Webhook (Recommended) - Create a webhook in your Discord channel. Simple, no bot needed. Just paste the URL.
  2. Bot API - Use a Discord bot token + channel ID. More flexible, requires a bot application.
使用AskUserQuestion:
问题: "你想要通过哪种方式发送Discord通知?"
选项:
  1. Webhook(推荐) - 在你的Discord频道中创建一个webhook,简单无需机器人,只需要粘贴URL即可
  2. Bot API - 使用Discord机器人令牌 + 频道ID,更灵活,需要创建机器人应用

Step 3A: Webhook Setup

步骤3A:Webhook设置

If user chose Webhook:
Use AskUserQuestion:
Question: "Paste your Discord webhook URL. To create one: Server Settings > Integrations > Webhooks > New Webhook > Copy URL"
The user will type their webhook URL in the "Other" field.
Validate the URL:
  • Must start with
    https://discord.com/api/webhooks/
    or
    https://discordapp.com/api/webhooks/
  • If invalid, explain the format and ask again
如果用户选择Webhook:
使用AskUserQuestion:
问题: "请粘贴你的Discord webhook URL。创建方法:服务器设置 > 集成 > Webhooks > 新建Webhook > 复制URL"
用户会在"其他"字段输入他们的webhook URL。
校验URL格式:
  • 必须以
    https://discord.com/api/webhooks/
    https://discordapp.com/api/webhooks/
    开头
  • 如果格式无效,说明正确格式并重新询问

Step 3B: Bot API Setup

步骤3B:Bot API设置

If user chose Bot API:
Ask two questions:
  1. "Paste your Discord bot token" - From discord.com/developers > Your App > Bot > Token
  2. "Paste the channel ID" - Right-click channel > Copy Channel ID (requires Developer Mode)
如果用户选择Bot API:
询问两个问题:
  1. "请粘贴你的Discord机器人令牌" - 来自discord.com/developers > 你的应用 > 机器人 > 令牌
  2. "请粘贴频道ID" - 右键点击频道 > 复制频道ID(需要开启开发者模式)

Step 4: Configure Mention (User Ping)

步骤4:配置@提醒(Ping用户)

Use AskUserQuestion:
Question: "Would you like notifications to mention (ping) someone?"
Options:
  1. Yes, mention a user - Tag a specific user by their Discord user ID
  2. Yes, mention a role - Tag a role by its role ID
  3. No mentions - Just post the message without pinging anyone
使用AskUserQuestion:
问题: "你希望通知消息@提醒(ping)特定对象吗?"
选项:
  1. 是,@提醒某个用户 - 通过Discord用户ID标记特定用户
  2. 是,@提醒某个角色 - 通过角色ID标记某个角色
  3. 不需要提醒 - 仅发布消息,不ping任何人

If user wants to mention a user:

如果用户想要@提醒某个用户:

Ask: "What is the Discord user ID to mention? (Right-click user > Copy User ID, requires Developer Mode)"
The mention format is:
<@USER_ID>
(e.g.,
<@1465264645320474637>
)
询问:"要@的Discord用户ID是什么?(右键点击用户 > 复制用户ID,需要开启开发者模式)"
提醒格式为:
<@用户ID>
(比如:
<@1465264645320474637>

If user wants to mention a role:

如果用户想要@提醒某个角色:

Ask: "What is the Discord role ID to mention? (Server Settings > Roles > right-click role > Copy Role ID)"
The mention format is:
<@&ROLE_ID>
(e.g.,
<@&123456789>
)
询问:"要@的Discord角色ID是什么?(服务器设置 > 角色 > 右键点击角色 > 复制角色ID)"
提醒格式为:
<@&角色ID>
(比如:
<@&123456789>

Step 5: Configure Events

步骤5:配置触发事件

Use AskUserQuestion with multiSelect:
Question: "Which events should trigger Discord notifications?"
Options (multiSelect: true):
  1. Session end (Recommended) - When a Claude session finishes
  2. Input needed - When Claude is waiting for your response (great for long-running tasks)
  3. Session start - When a new session begins
  4. Session continuing - When a persistent mode keeps the session alive
Default selection: session-end + ask-user-question.
使用支持多选的AskUserQuestion:
问题: "哪些事件应该触发Discord通知?"
选项(支持多选:是):
  1. 会话结束(推荐) - 当Claude会话完成时
  2. 需要输入 - 当Claude等待你的响应时(非常适合长时间运行的任务)
  3. 会话开始 - 当新会话启动时
  4. 会话持续中 - 当持久化模式保持会话存活时
默认选中:session-end + ask-user-question

Step 6: Optional Username Override

步骤6:可选自定义发送者名称

Use AskUserQuestion:
Question: "Custom bot display name? (Shows as the webhook sender name in Discord)"
Options:
  1. OMC (default) - Display as "OMC"
  2. Claude Code - Display as "Claude Code"
  3. Custom - Enter a custom name
使用AskUserQuestion:
问题: "是否自定义机器人显示名称?(作为Discord中webhook的发送者名称显示)"
选项:
  1. OMC(默认) - 显示为"OMC"
  2. Claude Code - 显示为"Claude Code"
  3. 自定义 - 输入自定义名称

Step 7: Write Configuration

步骤7:写入配置

Read the existing config, merge the new Discord settings, and write back:
bash
CONFIG_FILE="$HOME/.claude/.omc-config.json"
mkdir -p "$(dirname "$CONFIG_FILE")"

if [ -f "$CONFIG_FILE" ]; then
  EXISTING=$(cat "$CONFIG_FILE")
else
  EXISTING='{}'
fi
读取现有配置,合并新的Discord设置,再写回配置文件:
bash
CONFIG_FILE="$HOME/.claude/.omc-config.json"
mkdir -p "$(dirname "$CONFIG_FILE")"

if [ -f "$CONFIG_FILE" ]; then
  EXISTING=$(cat "$CONFIG_FILE")
else
  EXISTING='{}'
fi

For Webhook method:

针对Webhook方式:

Build the notifications object with the collected values and merge into
.omc-config.json
using jq:
bash
undefined
使用收集到的值构建通知对象,并用jq合并到
.omc-config.json
bash
undefined

WEBHOOK_URL, MENTION, USERNAME are collected from user

WEBHOOK_URL、MENTION、USERNAME都是从用户处收集的值

EVENTS is the list of enabled events

EVENTS是启用的事件列表

echo "$EXISTING" | jq
--arg url "$WEBHOOK_URL"
--arg mention "$MENTION"
--arg username "$USERNAME"
'.notifications = (.notifications // {enabled: true}) | .notifications.enabled = true | .notifications.discord = { enabled: true, webhookUrl: $url, mention: (if $mention == "" then null else $mention end), username: (if $username == "" then null else $username end) }' > "$CONFIG_FILE"
undefined
echo "$EXISTING" | jq
--arg url "$WEBHOOK_URL"
--arg mention "$MENTION"
--arg username "$USERNAME"
'.notifications = (.notifications // {enabled: true}) | .notifications.enabled = true | .notifications.discord = { enabled: true, webhookUrl: $url, mention: (if $mention == "" then null else $mention end), username: (if $username == "" then null else $username end) }' > "$CONFIG_FILE"
undefined

For Bot API method:

针对Bot API方式:

bash
echo "$EXISTING" | jq \
  --arg token "$BOT_TOKEN" \
  --arg channel "$CHANNEL_ID" \
  --arg mention "$MENTION" \
  '.notifications = (.notifications // {enabled: true}) |
   .notifications.enabled = true |
   .notifications["discord-bot"] = {
     enabled: true,
     botToken: $token,
     channelId: $channel,
     mention: (if $mention == "" then null else $mention end)
   }' > "$CONFIG_FILE"
bash
echo "$EXISTING" | jq \
  --arg token "$BOT_TOKEN" \
  --arg channel "$CHANNEL_ID" \
  --arg mention "$MENTION" \
  '.notifications = (.notifications // {enabled: true}) |
   .notifications.enabled = true |
   .notifications["discord-bot"] = {
     enabled: true,
     botToken: $token,
     channelId: $channel,
     mention: (if $mention == "" then null else $mention end)
   }' > "$CONFIG_FILE"

Add event-specific config if user didn't select all events:

如果用户没有选中所有事件,添加事件专属配置:

For each event NOT selected, disable it:
bash
undefined
对每个未选中的事件,将其禁用:
bash
undefined

Example: disable session-start if not selected

示例:如果未选中会话开始则禁用该事件

echo "$(cat "$CONFIG_FILE")" | jq
'.notifications.events = (.notifications.events // {}) | .notifications.events["session-start"] = {enabled: false}' > "$CONFIG_FILE"
undefined
echo "$(cat "$CONFIG_FILE")" | jq
'.notifications.events = (.notifications.events // {}) | .notifications.events["session-start"] = {enabled: false}' > "$CONFIG_FILE"
undefined

Step 8: Test the Configuration

步骤8:测试配置

After writing config, offer to send a test notification:
Use AskUserQuestion:
Question: "Send a test notification to verify the setup?"
Options:
  1. Yes, test now (Recommended) - Send a test message to your Discord channel
  2. No, I'll test later - Skip testing
写入配置后,询问用户是否要发送测试通知:
使用AskUserQuestion:
问题: "是否发送测试通知验证设置是否正常?"
选项:
  1. 是,现在测试(推荐) - 发送测试消息到你的Discord频道
  2. 否,稍后再测试 - 跳过测试

If testing:

如果选择测试:

bash
undefined
bash
undefined

For webhook:

针对webhook方式:

curl -s -o /dev/null -w "%{http_code}"
-H "Content-Type: application/json"
-d "{"content": "${MENTION:+$MENTION\n}OMC test notification - Discord is configured!"}"
"$WEBHOOK_URL"

Report success or failure. If it fails, help the user debug (check URL, permissions, etc.).
curl -s -o /dev/null -w "%{http_code}"
-H "Content-Type: application/json"
-d "{"content": "${MENTION:+$MENTION\n}OMC测试通知 - Discord已配置成功!"}"
"$WEBHOOK_URL"

上报成功或失败结果。如果失败,帮助用户排查问题(检查URL、权限等)。

Step 9: Confirm

步骤9:确认完成

Display the final configuration summary:
Discord Notifications Configured!

  Method:   Webhook / Bot API
  Mention:  <@1465264645320474637> (or "none")
  Events:   session-end, ask-user-question
  Username: OMC

Config saved to: ~/.claude/.omc-config.json

You can also set these via environment variables:
  OMC_DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/...
  OMC_DISCORD_MENTION=<@1465264645320474637>

To reconfigure: /oh-my-claudecode:configure-notifications discord
To configure Telegram: /oh-my-claudecode:configure-notifications telegram
To configure Slack: /oh-my-claudecode:configure-notifications slack
展示最终的配置汇总:
Discord通知已配置完成!

  方式:   Webhook / Bot API
  提醒对象:  <@1465264645320474637> (或 "无")
  触发事件:   session-end, ask-user-question
  发送者名称: OMC

配置已保存到: ~/.claude/.omc-config.json

你也可以通过环境变量设置这些配置:
  OMC_DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/...
  OMC_DISCORD_MENTION=<@1465264645320474637>

重新配置命令: /oh-my-claudecode:configure-notifications discord
配置Telegram通知: /oh-my-claudecode:configure-notifications telegram
配置Slack通知: /oh-my-claudecode:configure-notifications slack

Environment Variable Alternative

环境变量替代方案

Users can skip this wizard entirely by setting env vars in their shell profile:
Webhook method:
bash
export OMC_DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/..."
export OMC_DISCORD_MENTION="<@1465264645320474637>"  # optional
Bot API method:
bash
export OMC_DISCORD_NOTIFIER_BOT_TOKEN="your-bot-token"
export OMC_DISCORD_NOTIFIER_CHANNEL="your-channel-id"
export OMC_DISCORD_MENTION="<@1465264645320474637>"  # optional
Env vars are auto-detected by the notification system without needing
.omc-config.json
.

用户可以通过在shell配置文件中设置环境变量,完全跳过这个配置向导:
Webhook方式:
bash
export OMC_DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/..."
export OMC_DISCORD_MENTION="<@1465264645320474637>"  # 可选
Bot API方式:
bash
export OMC_DISCORD_NOTIFIER_BOT_TOKEN="你的机器人令牌"
export OMC_DISCORD_NOTIFIER_CHANNEL="你的频道ID"
export OMC_DISCORD_MENTION="<@1465264645320474637>"  # 可选
通知系统会自动检测环境变量,不需要
.omc-config.json
文件。

Slack Setup

Slack设置

Set up Slack notifications so OMC can message you when sessions end, need input, or complete background tasks.
配置Slack通知,这样OMC就可以在会话结束、需要输入或完成后台任务时给你发消息。

How This Skill Works

功能说明

This is an interactive, natural-language configuration skill. Walk the user through setup by asking questions with AskUserQuestion. Write the result to
~/.claude/.omc-config.json
.
这是一个交互式的自然语言配置技能,通过AskUserQuestion提问引导用户完成配置,最终将结果写入
~/.claude/.omc-config.json

Step 1: Detect Existing Configuration

步骤1:检测现有配置

bash
CONFIG_FILE="$HOME/.claude/.omc-config.json"

if [ -f "$CONFIG_FILE" ]; then
  HAS_SLACK=$(jq -r '.notifications.slack.enabled // false' "$CONFIG_FILE" 2>/dev/null)
  WEBHOOK_URL=$(jq -r '.notifications.slack.webhookUrl // empty' "$CONFIG_FILE" 2>/dev/null)
  MENTION=$(jq -r '.notifications.slack.mention // empty' "$CONFIG_FILE" 2>/dev/null)
  CHANNEL=$(jq -r '.notifications.slack.channel // empty' "$CONFIG_FILE" 2>/dev/null)

  if [ "$HAS_SLACK" = "true" ]; then
    echo "EXISTING_CONFIG=true"
    [ -n "$WEBHOOK_URL" ] && echo "WEBHOOK_URL=$WEBHOOK_URL"
    [ -n "$MENTION" ] && echo "MENTION=$MENTION"
    [ -n "$CHANNEL" ] && echo "CHANNEL=$CHANNEL"
  else
    echo "EXISTING_CONFIG=false"
  fi
else
  echo "NO_CONFIG_FILE"
fi
If existing config is found, show the user what's currently configured and ask if they want to update or reconfigure.
bash
CONFIG_FILE="$HOME/.claude/.omc-config.json"

if [ -f "$CONFIG_FILE" ]; then
  HAS_SLACK=$(jq -r '.notifications.slack.enabled // false' "$CONFIG_FILE" 2>/dev/null)
  WEBHOOK_URL=$(jq -r '.notifications.slack.webhookUrl // empty' "$CONFIG_FILE" 2>/dev/null)
  MENTION=$(jq -r '.notifications.slack.mention // empty' "$CONFIG_FILE" 2>/dev/null)
  CHANNEL=$(jq -r '.notifications.slack.channel // empty' "$CONFIG_FILE" 2>/dev/null)

  if [ "$HAS_SLACK" = "true" ]; then
    echo "EXISTING_CONFIG=true"
    [ -n "$WEBHOOK_URL" ] && echo "WEBHOOK_URL=$WEBHOOK_URL"
    [ -n "$MENTION" ] && echo "MENTION=$MENTION"
    [ -n "$CHANNEL" ] && echo "CHANNEL=$CHANNEL"
  else
    echo "EXISTING_CONFIG=false"
  fi
else
  echo "NO_CONFIG_FILE"
fi
如果检测到现有配置,向用户展示当前配置内容,并询问是否需要更新或重新配置。

Step 2: Create a Slack Incoming Webhook

步骤2:创建Slack传入Webhook

Guide the user through creating a webhook if they don't have one:
To set up Slack notifications, you need a Slack incoming webhook URL.

CREATE A WEBHOOK:
1. Go to https://api.slack.com/apps
2. Click "Create New App" > "From scratch"
3. Name your app (e.g., "OMC Notifier") and select your workspace
4. Go to "Incoming Webhooks" in the left sidebar
5. Toggle "Activate Incoming Webhooks" to ON
6. Click "Add New Webhook to Workspace"
7. Select the channel where notifications should be posted
8. Copy the webhook URL (starts with https://hooks.slack.com/services/...)
如果用户还没有Slack传入Webhook,引导其完成创建:
要设置Slack通知,你需要一个Slack传入Webhook URL。

创建Webhook:
1. 访问https://api.slack.com/apps
2. 点击"Create New App" > "From scratch"
3. 为应用命名(比如:"OMC通知器")并选择你的工作区
4. 点击左侧边栏的"Incoming Webhooks"
5. 把"Activate Incoming Webhooks"切换为开启状态
6. 点击"Add New Webhook to Workspace"
7. 选择通知要发送到的频道
8. 复制webhook URL(以https://hooks.slack.com/services/...开头)

Step 3: Collect Webhook URL

步骤3:收集Webhook URL

Use AskUserQuestion:
Question: "Paste your Slack incoming webhook URL (starts with https://hooks.slack.com/services/...)"
The user will type their webhook URL in the "Other" field.
Validate the URL:
  • Must start with
    https://hooks.slack.com/services/
  • If invalid, explain the format and ask again
使用AskUserQuestion:
问题: "请粘贴你的Slack传入Webhook URL(以https://hooks.slack.com/services/...开头)"
用户会在"其他"字段输入他们的webhook URL。
校验URL格式:
  • 必须以
    https://hooks.slack.com/services/
    开头
  • 如果格式无效,说明正确格式并重新询问

Step 4: Configure Mention (User/Group Ping)

步骤4:配置@提醒(Ping用户/群组)

Use AskUserQuestion:
Question: "Would you like notifications to mention (ping) someone?"
Options:
  1. Yes, mention a user - Tag a specific user by their Slack member ID
  2. Yes, mention a channel - Use @channel to notify everyone in the channel
  3. Yes, mention @here - Notify only active members in the channel
  4. No mentions - Just post the message without pinging anyone
使用AskUserQuestion:
问题: "你希望通知消息@提醒(ping)特定对象吗?"
选项:
  1. 是,@提醒某个用户 - 通过Slack成员ID标记特定用户
  2. 是,@提醒整个频道 - 使用@channel通知频道内所有人
  3. 是,@提醒在线成员 - 使用@here仅通知频道内的活跃成员
  4. 不需要提醒 - 仅发布消息,不ping任何人

If user wants to mention a user:

如果用户想要@提醒某个用户:

Ask: "What is the Slack member ID to mention? (Click on a user's profile > More (⋯) > Copy member ID)"
The mention format is:
<@MEMBER_ID>
(e.g.,
<@U1234567890>
)
询问:"要@的Slack成员ID是什么?(点击用户头像 > 更多(⋯) > 复制成员ID)"
提醒格式为:
<@成员ID>
(比如:
<@U1234567890>

If user wants @channel:

如果用户想要@整个频道:

The mention format is:
<!channel>
提醒格式为:
<!channel>

If user wants @here:

如果用户想要@在线成员:

The mention format is:
<!here>
提醒格式为:
<!here>

Step 5: Configure Events

步骤5:配置触发事件

Use AskUserQuestion with multiSelect:
Question: "Which events should trigger Slack notifications?"
Options (multiSelect: true):
  1. Session end (Recommended) - When a Claude session finishes
  2. Input needed - When Claude is waiting for your response (great for long-running tasks)
  3. Session start - When a new session begins
  4. Session continuing - When a persistent mode keeps the session alive
Default selection: session-end + ask-user-question.
使用支持多选的AskUserQuestion:
问题: "哪些事件应该触发Slack通知?"
选项(支持多选:是):
  1. 会话结束(推荐) - 当Claude会话完成时
  2. 需要输入 - 当Claude等待你的响应时(非常适合长时间运行的任务)
  3. 会话开始 - 当新会话启动时
  4. 会话持续中 - 当持久化模式保持会话存活时
默认选中:session-end + ask-user-question

Step 6: Optional Channel Override

步骤6:可选覆盖默认通知频道

Use AskUserQuestion:
Question: "Override the default notification channel? (The webhook already has a default channel)"
Options:
  1. Use webhook default (Recommended) - Post to the channel selected during webhook setup
  2. Override channel - Specify a different channel (e.g., #alerts)
If override, ask for the channel name (e.g.,
#alerts
).
使用AskUserQuestion:
问题: "是否覆盖默认的通知频道?(Webhook已经配置了默认频道)"
选项:
  1. 使用Webhook默认频道(推荐) - 发送到Webhook创建时选择的频道
  2. 覆盖频道 - 指定其他频道(比如:#alerts)
如果选择覆盖,询问频道名称(比如:
#alerts
)。

Step 7: Optional Username Override

步骤7:可选自定义发送者名称

Use AskUserQuestion:
Question: "Custom bot display name? (Shows as the webhook sender name in Slack)"
Options:
  1. OMC (default) - Display as "OMC"
  2. Claude Code - Display as "Claude Code"
  3. Custom - Enter a custom name
使用AskUserQuestion:
问题: "是否自定义机器人显示名称?(作为Slack中webhook的发送者名称显示)"
选项:
  1. OMC(默认) - 显示为"OMC"
  2. Claude Code - 显示为"Claude Code"
  3. 自定义 - 输入自定义名称

Step 8: Write Configuration

步骤8:写入配置

Read the existing config, merge the new Slack settings, and write back:
bash
CONFIG_FILE="$HOME/.claude/.omc-config.json"
mkdir -p "$(dirname "$CONFIG_FILE")"

if [ -f "$CONFIG_FILE" ]; then
  EXISTING=$(cat "$CONFIG_FILE")
else
  EXISTING='{}'
fi
读取现有配置,合并新的Slack设置,再写回配置文件:
bash
CONFIG_FILE="$HOME/.claude/.omc-config.json"
mkdir -p "$(dirname "$CONFIG_FILE")"

if [ -f "$CONFIG_FILE" ]; then
  EXISTING=$(cat "$CONFIG_FILE")
else
  EXISTING='{}'
fi

WEBHOOK_URL, MENTION, USERNAME, CHANNEL are collected from user

WEBHOOK_URL、MENTION、USERNAME、CHANNEL都是从用户处收集的值

echo "$EXISTING" | jq
--arg url "$WEBHOOK_URL"
--arg mention "$MENTION"
--arg username "$USERNAME"
--arg channel "$CHANNEL"
'.notifications = (.notifications // {enabled: true}) | .notifications.enabled = true | .notifications.slack = { enabled: true, webhookUrl: $url, mention: (if $mention == "" then null else $mention end), username: (if $username == "" then null else $username end), channel: (if $channel == "" then null else $channel end) }' > "$CONFIG_FILE"
undefined
echo "$EXISTING" | jq
--arg url "$WEBHOOK_URL"
--arg mention "$MENTION"
--arg username "$USERNAME"
--arg channel "$CHANNEL"
'.notifications = (.notifications // {enabled: true}) | .notifications.enabled = true | .notifications.slack = { enabled: true, webhookUrl: $url, mention: (if $mention == "" then null else $mention end), username: (if $username == "" then null else $username end), channel: (if $channel == "" then null else $channel end) }' > "$CONFIG_FILE"
undefined

Add event-specific config if user didn't select all events:

如果用户没有选中所有事件,添加事件专属配置:

For each event NOT selected, disable it:
bash
undefined
对每个未选中的事件,将其禁用:
bash
undefined

Example: disable session-start if not selected

示例:如果未选中会话开始则禁用该事件

echo "$(cat "$CONFIG_FILE")" | jq
'.notifications.events = (.notifications.events // {}) | .notifications.events["session-start"] = {enabled: false}' > "$CONFIG_FILE"
undefined
echo "$(cat "$CONFIG_FILE")" | jq
'.notifications.events = (.notifications.events // {}) | .notifications.events["session-start"] = {enabled: false}' > "$CONFIG_FILE"
undefined

Step 9: Test the Configuration

步骤9:测试配置

After writing config, offer to send a test notification:
Use AskUserQuestion:
Question: "Send a test notification to verify the setup?"
Options:
  1. Yes, test now (Recommended) - Send a test message to your Slack channel
  2. No, I'll test later - Skip testing
写入配置后,询问用户是否要发送测试通知:
使用AskUserQuestion:
问题: "是否发送测试通知验证设置是否正常?"
选项:
  1. 是,现在测试(推荐) - 发送测试消息到你的Slack频道
  2. 否,稍后再测试 - 跳过测试

If testing:

如果选择测试:

bash
undefined
bash
undefined

For webhook:

针对webhook方式:

MENTION_PREFIX="" if [ -n "$MENTION" ]; then MENTION_PREFIX="${MENTION}\n" fi
curl -s -o /dev/null -w "%{http_code}"
-H "Content-Type: application/json"
-d "{"text": "${MENTION_PREFIX}OMC test notification - Slack is configured!"}"
"$WEBHOOK_URL"

Report success or failure. Common issues:
- **403 Forbidden**: Webhook URL is invalid or revoked
- **404 Not Found**: Webhook URL is incorrect
- **channel_not_found**: Channel override is invalid
- **Network error**: Check connectivity to hooks.slack.com
MENTION_PREFIX="" if [ -n "$MENTION" ]; then MENTION_PREFIX="${MENTION}\n" fi
curl -s -o /dev/null -w "%{http_code}"
-H "Content-Type: application/json"
-d "{"text": "${MENTION_PREFIX}OMC测试通知 - Slack已配置成功!"}"
"$WEBHOOK_URL"

上报成功或失败结果。常见问题:
- **403禁止访问**:Webhook URL无效或已被撤销
- **404未找到**:Webhook URL不正确
- **channel_not_found**:覆盖的频道无效
- **网络错误**:检查到hooks.slack.com的网络连接

Step 10: Confirm

步骤10:确认完成

Display the final configuration summary:
Slack Notifications Configured!

  Webhook:  https://hooks.slack.com/services/T00/B00/xxx...
  Mention:  <@U1234567890> (or "none")
  Channel:  #alerts (or "webhook default")
  Events:   session-end, ask-user-question
  Username: OMC

Config saved to: ~/.claude/.omc-config.json

You can also set these via environment variables:
  OMC_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/...
  OMC_SLACK_MENTION=<@U1234567890>

To reconfigure: /oh-my-claudecode:configure-notifications slack
To configure Discord: /oh-my-claudecode:configure-notifications discord
To configure Telegram: /oh-my-claudecode:configure-notifications telegram
展示最终的配置汇总:
Slack通知已配置完成!

  Webhook:  https://hooks.slack.com/services/T00/B00/xxx...
  提醒对象:  <@U1234567890> (或 "无")
  频道:  #alerts (或 "webhook默认")
  触发事件:   session-end, ask-user-question
  发送者名称: OMC

配置已保存到: ~/.claude/.omc-config.json

你也可以通过环境变量设置这些配置:
  OMC_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/...
  OMC_SLACK_MENTION=<@U1234567890>

重新配置命令: /oh-my-claudecode:configure-notifications slack
配置Discord通知: /oh-my-claudecode:configure-notifications discord
配置Telegram通知: /oh-my-claudecode:configure-notifications telegram

Environment Variable Alternative

环境变量替代方案

Users can skip this wizard entirely by setting env vars in their shell profile:
bash
export OMC_SLACK_WEBHOOK_URL="https://hooks.slack.com/services/T00/B00/xxx"
export OMC_SLACK_MENTION="<@U1234567890>"  # optional
Env vars are auto-detected by the notification system without needing
.omc-config.json
.
用户可以通过在shell配置文件中设置环境变量,完全跳过这个配置向导:
bash
export OMC_SLACK_WEBHOOK_URL="https://hooks.slack.com/services/T00/B00/xxx"
export OMC_SLACK_MENTION="<@U1234567890>"  # 可选
通知系统会自动检测环境变量,不需要
.omc-config.json
文件。

Slack Mention Formats

Slack提醒格式参考

TypeFormatExample
User
<@MEMBER_ID>
<@U1234567890>
Channel
<!channel>
<!channel>
Here
<!here>
<!here>
Everyone
<!everyone>
<!everyone>
User Group
<!subteam^GROUP_ID>
<!subteam^S1234567890>

类型格式示例
用户
<@成员ID>
<@U1234567890>
频道
<!channel>
<!channel>
在线成员
<!here>
<!here>
所有人
<!everyone>
<!everyone>
用户组
<!subteam^群组ID>
<!subteam^S1234567890>

Platform Activation Flags

平台激活标志

All notification platforms require activation via CLI flags per session:
  • omc --telegram
    — Activates Telegram notifications (sets
    OMC_TELEGRAM=1
    )
  • omc --discord
    — Activates Discord notifications (sets
    OMC_DISCORD=1
    )
  • omc --slack
    — Activates Slack notifications (sets
    OMC_SLACK=1
    )
  • omc --webhook
    — Activates webhook notifications (sets
    OMC_WEBHOOK=1
    )
  • omc --openclaw
    — Activates OpenClaw gateway integration (sets
    OMC_OPENCLAW=1
    )
Without these flags, configured platforms remain dormant. This prevents unwanted notifications during development while keeping configuration persistent.
Examples:
  • omc --telegram --discord
    — Telegram + Discord active
  • omc --telegram --slack --webhook
    — Telegram + Slack + Webhook active
  • omc --telegram --openclaw
    — Telegram + OpenClaw active
  • omc
    — No notifications sent (all platforms require explicit activation)

所有通知平台都需要在每个会话中通过CLI标志激活:
  • omc --telegram
    — 激活Telegram通知(设置
    OMC_TELEGRAM=1
  • omc --discord
    — 激活Discord通知(设置
    OMC_DISCORD=1
  • omc --slack
    — 激活Slack通知(设置
    OMC_SLACK=1
  • omc --webhook
    — 激活Webhook通知(设置
    OMC_WEBHOOK=1
  • omc --openclaw
    — 激活OpenClaw网关集成(设置
    OMC_OPENCLAW=1
如果不带这些标志,已配置的平台会保持休眠状态,这样可以避免开发过程中收到不必要的通知,同时保留配置持久化。
示例:
  • omc --telegram --discord
    — 同时激活Telegram + Discord通知
  • omc --telegram --slack --webhook
    — 同时激活Telegram + Slack + Webhook通知
  • omc --telegram --openclaw
    — 同时激活Telegram + OpenClaw通知
  • omc
    — 不发送任何通知(所有平台都需要显式激活)

Hook Event Templates

Hook事件模板

Customize notification messages per event and per platform using
omc_config.hook.json
.
通过
omc_config.hook.json
为每个事件和每个平台自定义通知消息。

Routing

路由规则

If the trigger or argument contains "hook", "template", or "customize messages" → follow this section.
如果触发词或参数包含"hook"、"template"或"customize messages" → 参考本部分内容。

Step 1: Detect Existing Hook Config

步骤1:检测现有Hook配置

Check if
~/.claude/omc_config.hook.json
exists. If it does, show the current configuration. If not, explain what it does.
Hook event templates let you customize the notification messages sent to each platform.
You can set different messages for Discord vs Telegram vs Slack, and control which
events fire on which platform.

Config file: ~/.claude/omc_config.hook.json
检查
~/.claude/omc_config.hook.json
是否存在。如果存在,展示当前配置;如果不存在,说明其作用。
Hook事件模板允许你自定义发送到每个平台的通知消息。
你可以为Discord、Telegram、Slack设置不同的消息,还可以控制哪些事件在哪个平台触发。

配置文件: ~/.claude/omc_config.hook.json

Step 2: Choose Event to Configure

步骤2:选择要配置的事件

Use AskUserQuestion:
Question: "Which event would you like to configure templates for?"
Options:
  1. session-end - When a Claude session finishes (most common)
  2. ask-user-question - When Claude is waiting for input
  3. session-idle - When Claude finishes and waits for input
  4. session-start - When a new session begins
使用AskUserQuestion:
问题: "你想要为哪个事件配置模板?"
选项:
  1. session-end - 当Claude会话结束时(最常用)
  2. ask-user-question - 当Claude等待输入时
  3. session-idle - 当Claude完成任务并等待输入时
  4. session-start - 当新会话启动时

Step 3: Show Available Variables

步骤3:展示可用变量

Display the template variables available for the chosen event:
Available template variables:

RAW FIELDS:
  {{sessionId}}      - Session identifier
  {{timestamp}}      - ISO timestamp
  {{tmuxSession}}    - tmux session name
  {{projectPath}}    - Full project directory path
  {{projectName}}    - Project directory basename
  {{reason}}         - Stop/end reason
  {{activeMode}}     - Active OMC mode name
  {{question}}       - Question text (ask-user-question only)
  {{agentName}}      - Agent name (agent-call only)
  {{agentType}}      - Agent type (agent-call only)

COMPUTED (smart formatting):
  {{duration}}       - Human-readable duration (e.g., "5m 23s")
  {{time}}           - Locale time string
  {{modesDisplay}}   - Comma-separated modes or empty
  {{iterationDisplay}} - "3/10" format or empty
  {{agentDisplay}}   - "2/5 completed" or empty
  {{projectDisplay}} - Project name with fallbacks
  {{footer}}         - tmux + project info line
  {{tmuxTailBlock}}  - Recent output in code fence or empty
  {{reasonDisplay}}  - Reason with "unknown" fallback

CONDITIONALS:
  {{#if variableName}}content shown when truthy{{/if}}
展示选中事件支持的模板变量:
可用模板变量:

原始字段:
  {{sessionId}}      - 会话标识符
  {{timestamp}}      - ISO时间戳
  {{tmuxSession}}    - tmux会话名称
  {{projectPath}}    - 项目目录完整路径
  {{projectName}}    - 项目目录basename
  {{reason}}         - 停止/结束原因
  {{activeMode}}     - 激活的OMC模式名称
  {{question}}       - 问题文本(仅ask-user-question事件可用)
  {{agentName}}      - Agent名称(仅agent-call事件可用)
  {{agentType}}      - Agent类型(仅agent-call事件可用)

计算字段(智能格式化):
  {{duration}}       - 人类可读的耗时(比如:"5m 23s")
  {{time}}           - 本地化时间字符串
  {{modesDisplay}}   - 逗号分隔的模式列表或空
  {{iterationDisplay}} - "3/10"格式或空
  {{agentDisplay}}   - "2/5 completed"或空
  {{projectDisplay}} - 带降级的项目名称
  {{footer}}         - tmux + 项目信息行
  {{tmuxTailBlock}}  - 代码块包裹的最近输出或空
  {{reasonDisplay}}  - 带"unknown"降级的原因

条件判断:
  {{#if variableName}}变量为真时显示的内容{{/if}}

Step 4: Collect Template

步骤4:收集模板

Use AskUserQuestion:
Question: "Enter the message template for this event (use {{variables}} for dynamic content)"
Options:
  1. Use default template - Keep the built-in message format
  2. Simple summary - Short one-line format
  3. Custom - Enter your own template
If "Simple summary", use a pre-built compact template:
  • session-end:
    {{projectDisplay}} session ended ({{duration}}) — {{reasonDisplay}}
  • ask-user-question:
    Input needed on {{projectDisplay}}: {{question}}
  • session-idle:
    {{projectDisplay}} is idle. {{#if reason}}Reason: {{reason}}{{/if}}
  • session-start:
    Session started: {{projectDisplay}} at {{time}}
使用AskUserQuestion:
问题: "请输入该事件的消息模板(使用{{变量名}}插入动态内容)"
选项:
  1. 使用默认模板 - 保留内置的消息格式
  2. 简洁摘要 - 简短的单行格式
  3. 自定义 - 输入你自己的模板
如果选择"简洁摘要",使用预置的紧凑模板:
  • session-end:
    {{projectDisplay}}会话已结束({{duration}})— {{reasonDisplay}}
  • ask-user-question:
    {{projectDisplay}}需要输入:{{question}}
  • session-idle:
    {{projectDisplay}}处于空闲状态。{{#if reason}}原因:{{reason}}{{/if}}
  • session-start:
    会话已启动:{{projectDisplay}} 于 {{time}}

Step 5: Per-Platform Overrides

步骤5:按平台覆盖配置

Use AskUserQuestion:
Question: "Do you want different messages for specific platforms?"
Options:
  1. No, same for all (Recommended) - Use the same template everywhere
  2. Yes, customize per platform - Set different templates for Discord, Telegram, Slack
If per-platform: ask for each enabled platform's template separately.
使用AskUserQuestion:
问题: "你需要为特定平台设置不同的消息吗?"
选项:
  1. 不需要,所有平台通用(推荐) - 所有平台使用相同模板
  2. 是,按平台自定义 - 为Discord、Telegram、Slack分别设置不同模板
如果选择按平台自定义:分别询问每个已启用平台的模板。

Step 6: Write Configuration

步骤6:写入配置

Read or create
~/.claude/omc_config.hook.json
and merge the new settings:
json
{
  "version": 1,
  "enabled": true,
  "events": {
    "<event-name>": {
      "enabled": true,
      "template": "<user-provided-template>",
      "platforms": {
        "discord": { "template": "<discord-specific>" },
        "telegram": { "template": "<telegram-specific>" }
      }
    }
  }
}
读取或创建
~/.claude/omc_config.hook.json
并合并新的设置:
json
{
  "version": 1,
  "enabled": true,
  "events": {
    "<事件名称>": {
      "enabled": true,
      "template": "<用户提供的模板>",
      "platforms": {
        "discord": { "template": "<discord专属模板>" },
        "telegram": { "template": "<telegram专属模板>" }
      }
    }
  }
}

Step 7: Validate and Test

步骤7:校验和测试

Validate the template using
validateTemplate()
to check for unknown variables. If any are found, warn the user and offer to correct.
Offer to send a test notification with the new template.
使用
validateTemplate()
校验模板,检查是否有未知变量。如果发现未知变量,警告用户并提供修改建议。
询问用户是否要使用新模板发送测试通知。

Example Config

配置示例

json
{
  "version": 1,
  "enabled": true,
  "events": {
    "session-end": {
      "enabled": true,
      "template": "Session {{sessionId}} ended after {{duration}}. Reason: {{reasonDisplay}}",
      "platforms": {
        "discord": {
          "template": "**Session Complete** | `{{projectDisplay}}` | {{duration}} | {{reasonDisplay}}"
        },
        "telegram": {
          "template": "Done: {{projectDisplay}} ({{duration}})\n{{#if contextSummary}}Summary: {{contextSummary}}{{/if}}"
        }
      }
    },
    "ask-user-question": {
      "enabled": true,
      "template": "{{#if question}}{{question}}{{/if}}\nWaiting for input on {{projectDisplay}}"
    }
  }
}

json
{
  "version": 1,
  "enabled": true,
  "events": {
    "session-end": {
      "enabled": true,
      "template": "会话{{sessionId}}在{{duration}}后结束。原因:{{reasonDisplay}}",
      "platforms": {
        "discord": {
          "template": "**会话完成** | `{{projectDisplay}}` | {{duration}} | {{reasonDisplay}}"
        },
        "telegram": {
          "template": "已完成:{{projectDisplay}} ({{duration}})\n{{#if contextSummary}}摘要:{{contextSummary}}{{/if}}"
        }
      }
    },
    "ask-user-question": {
      "enabled": true,
      "template": "{{#if question}}{{question}}{{/if}}\n等待{{projectDisplay}}的输入"
    }
  }
}

Related

相关内容

  • /oh-my-claudecode:configure-openclaw
    — Configure OpenClaw gateway integration

  • /oh-my-claudecode:configure-openclaw
    — 配置OpenClaw网关集成

Custom Integration (OpenClaw, n8n, CLI, etc.)

自定义集成(OpenClaw、n8n、CLI等)

Configure custom webhooks and CLI commands for services beyond the native Discord/Telegram/Slack integrations.
为原生Discord/Telegram/Slack之外的服务配置自定义webhook和CLI命令。

Routing

路由规则

If the user says "custom integration", "openclaw", "n8n", "webhook", "cli command", or similar → follow this section.
如果用户说"custom integration"、"openclaw"、"n8n"、"webhook"、"cli command"或类似表述 → 参考本部分内容。

Migration from OpenClaw

从OpenClaw迁移

If
~/.claude/omc_config.openclaw.json
exists, detect and offer migration:
Step 1: Detect Legacy Config
bash
LEGACY_CONFIG="$HOME/.claude/omc_config.openclaw.json"
if [ -f "$LEGACY_CONFIG" ]; then
  echo "LEGACY_FOUND=true"
  # Check if already migrated
  if jq -e '.customIntegrations.integrations[] | select(.preset == "openclaw")' "$CONFIG_FILE" >/dev/null 2>&1; then
    echo "ALREADY_MIGRATED=true"
  else
    echo "ALREADY_MIGRATED=false"
  fi
else
  echo "LEGACY_FOUND=false"
fi
Step 2: Offer Migration If legacy found and not migrated:
Question: "Existing OpenClaw configuration detected. Would you like to migrate it to the new format?"
Options:
  1. Yes, migrate now - Convert legacy config to custom integration
  2. No, configure fresh - Skip migration and start new
  3. Show me the legacy config first - Display current OpenClaw settings
If migrate:
  • Read
    omc_config.openclaw.json
  • Transform to custom integration format
  • Save to
    .omc-config.json
  • Backup legacy to
    omc_config.openclaw.json.bak
  • Show success message
如果存在
~/.claude/omc_config.openclaw.json
,检测到后询问用户是否需要迁移:
步骤1:检测旧版配置
bash
LEGACY_CONFIG="$HOME/.claude/omc_config.openclaw.json"
if [ -f "$LEGACY_CONFIG" ]; then
  echo "LEGACY_FOUND=true"
  # 检查是否已迁移
  if jq -e '.customIntegrations.integrations[] | select(.preset == "openclaw")' "$CONFIG_FILE" >/dev/null 2>&1; then
    echo "ALREADY_MIGRATED=true"
  else
    echo "ALREADY_MIGRATED=false"
  fi
else
  echo "LEGACY_FOUND=false"
fi
步骤2:询问是否迁移 如果检测到旧版配置且未迁移:
问题: "检测到现有OpenClaw配置,你想要将其迁移到新格式吗?"
选项:
  1. 是,现在迁移 - 将旧版配置转换为自定义集成格式
  2. 否,重新配置 - 跳过迁移,从头开始配置
  3. 先查看旧版配置 - 展示当前OpenClaw设置
如果选择迁移:
  • 读取
    omc_config.openclaw.json
  • 转换为自定义集成格式
  • 保存到
    .omc-config.json
  • 将旧版配置备份为
    omc_config.openclaw.json.bak
  • 展示成功消息

Custom Integration Wizard

自定义集成向导

Step 1: Select Integration Type
Question: "Which type of custom integration would you like to configure?"
Options:
  1. OpenClaw Gateway - Wake external automations and AI agents
  2. n8n Webhook - Trigger n8n workflows
  3. ClawdBot - Send notifications to ClawdBot
  4. Generic Webhook - Custom HTTPS webhook
  5. Generic CLI Command - Execute shell command on events
步骤1:选择集成类型
问题: "你想要配置哪种类型的自定义集成?"
选项:
  1. OpenClaw Gateway - 唤醒外部自动化和AI Agent
  2. n8n Webhook - 触发n8n工作流
  3. ClawdBot - 发送通知到ClawdBot
  4. 通用Webhook - 自定义HTTPS webhook
  5. 通用CLI命令 - 事件触发时执行shell命令

OpenClaw/n8n/ClawdBot Preset Flow

OpenClaw/n8n/ClawdBot预设流程

Step 2: Gateway URL
Question: "What is your gateway/webhook URL?"
Validation:
  • Must be HTTPS (except localhost for development)
  • Must be valid URL format
Step 3: Authentication (Optional)
Question: "Does your gateway require authentication?"
Options:
  1. Bearer token - Authorization: Bearer <token>
  2. Custom header - Name and value
  3. No authentication
If Bearer: ask for token If Custom: ask for header name and value
Step 4: Events
Use AskUserQuestion with multiSelect:
Question: "Which events should trigger this integration?"
Options (with defaults from preset):
  • session-start
  • session-end
  • session-stop
  • session-idle
  • ask-user-question
Default for OpenClaw: session-start, session-end, stop Default for n8n: session-end, ask-user-question
Step 5: Test
Question: "Send a test notification to verify the configuration?"
Options:
  1. Yes, test now - Send test webhook
  2. No, skip test
If test:
bash
undefined
步骤2:网关URL
问题: "你的网关/webhook URL是什么?"
校验规则:
  • 必须是HTTPS(开发环境下localhost除外)
  • 必须是有效的URL格式
步骤3:身份认证(可选)
问题: "你的网关需要身份认证吗?"
选项:
  1. Bearer令牌 - Authorization: Bearer <令牌>
  2. 自定义请求头 - 名称和值
  3. 不需要认证
如果选择Bearer:询问令牌 如果选择自定义:询问请求头名称和值
步骤4:触发事件
使用支持多选的AskUserQuestion:
问题: "哪些事件应该触发这个集成?"
选项(带预设默认值):
  • session-start
  • session-end
  • session-stop
  • session-idle
  • ask-user-question
OpenClaw默认选中:session-start, session-end, stop n8n默认选中:session-end, ask-user-question
步骤5:测试
问题: "是否发送测试通知验证配置是否正常?"
选项:
  1. 是,现在测试 - 发送测试webhook
  2. 否,跳过测试
如果选择测试:
bash
undefined

For webhook integrations

针对webhook集成

curl -X POST
-H "Content-Type: application/json"
${AUTH_HEADER:+"-H "$AUTH_HEADER""}
-d '{"event":"test","instruction":"OMC test notification","timestamp":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}'
"$WEBHOOK_URL"

Show result (HTTP status, any error).

**Step 6: Write Configuration**

Merge into `.omc-config.json`:

```json
{
  "notifications": { /* existing native configs */ },
  "customIntegrations": {
    "enabled": true,
    "integrations": [
      {
        "id": "my-openclaw",
        "type": "webhook",
        "preset": "openclaw",
        "enabled": true,
        "config": {
          "url": "https://my-gateway.example.com/wake",
          "method": "POST",
          "headers": {
            "Content-Type": "application/json",
            "Authorization": "Bearer ..."
          },
          "bodyTemplate": "{\\"event\\":\\"{{event}}\\",\\"instruction\\":\\"Session {{sessionId}} {{event}}\\",\\"timestamp\\":\\"{{timestamp}}\\"}",
          "timeout": 10000
        },
        "events": ["session-start", "session-end"]
      }
    ]
  }
}
curl -X POST
-H "Content-Type: application/json"
${AUTH_HEADER:+"-H "$AUTH_HEADER""}
-d '{"event":"test","instruction":"OMC测试通知","timestamp":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}'
"$WEBHOOK_URL"

展示结果(HTTP状态码、任何错误信息)。

**步骤6:写入配置**

合并到`.omc-config.json`:

```json
{
  "notifications": { /* 现有原生配置 */ },
  "customIntegrations": {
    "enabled": true,
    "integrations": [
      {
        "id": "my-openclaw",
        "type": "webhook",
        "preset": "openclaw",
        "enabled": true,
        "config": {
          "url": "https://my-gateway.example.com/wake",
          "method": "POST",
          "headers": {
            "Content-Type": "application/json",
            "Authorization": "Bearer ..."
          },
          "bodyTemplate": "{\\"event\\":\\"{{event}}\\",\\"instruction\\":\\"Session {{sessionId}} {{event}}\\",\\"timestamp\\":\\"{{timestamp}}\\"}",
          "timeout": 10000
        },
        "events": ["session-start", "session-end"]
      }
    ]
  }
}

Generic Webhook Flow

通用Webhook流程

Step 2: URL Ask for webhook URL (HTTPS required).
Step 3: Method Ask for HTTP method (GET, POST, PUT, PATCH, DELETE). Default: POST.
Step 4: Headers Ask for headers in "Name: Value" format, one per line. Default: Content-Type: application/json
Step 5: Body Template Show available template variables and ask for body template (JSON or other format).
Default:
json
{
  "event": "{{event}}",
  "sessionId": "{{sessionId}}",
  "projectName": "{{projectName}}",
  "timestamp": "{{timestamp}}"
}
Step 6: Timeout Ask for timeout in milliseconds (1000-60000). Default: 10000.
Step 7: Events Multi-select events.
Step 8: Test and Save Same as preset flow.
步骤2:URL 询问webhook URL(必须是HTTPS)。
步骤3:请求方法 询问HTTP方法(GET、POST、PUT、PATCH、DELETE)。默认:POST。
步骤4:请求头 询问请求头,格式为"名称: 值",每行一个。默认:Content-Type: application/json
步骤5:请求体模板 展示可用模板变量,询问请求体模板(JSON或其他格式)。
默认值:
json
{
  "event": "{{event}}",
  "sessionId": "{{sessionId}}",
  "projectName": "{{projectName}}",
  "timestamp": "{{timestamp}}"
}
步骤6:超时时间 询问超时时间,单位为毫秒(1000-60000)。默认:10000。
步骤7:触发事件 多选触发事件。
步骤8:测试和保存 和预设流程一致。

Generic CLI Command Flow

通用CLI命令流程

Step 2: Command
Question: "What command should be executed? (single executable, no arguments)"
Example:
curl
,
/usr/local/bin/my-script
,
notify-send
Validation:
  • No spaces
  • No shell metacharacters
Step 3: Arguments
Question: "Command arguments (use {{variable}} for dynamic values). Enter one per line."
Example:
-X
POST
-d
{"event":"{{event}}","session":"{{sessionId}}"}
https://my-api.com/notify
Show available template variables reference.
Step 4: Timeout Ask for timeout (1000-60000ms). Default: 5000.
Step 5: Events Multi-select events.
Step 6: Test and Save
For test, execute command with test values:
bash
$COMMAND "${ARGS[@]//{{event}}/test}"
Show stdout/stderr and exit code.
步骤2:命令
问题: "要执行的命令是什么?(单个可执行文件,不带参数)"
示例:
curl
/usr/local/bin/my-script
notify-send
校验规则:
  • 不能包含空格
  • 不能包含shell元字符
步骤3:参数
问题: "命令参数(使用{{变量}}插入动态值),每行一个。"
示例:
-X
POST
-d
{"event":"{{event}}","session":"{{sessionId}}"}
https://my-api.com/notify
展示可用模板变量参考。
步骤4:超时时间 询问超时时间(1000-60000毫秒)。默认:5000。
步骤5:触发事件 多选触发事件。
步骤6:测试和保存
测试时,使用测试值执行命令:
bash
$COMMAND "${ARGS[@]//{{event}}/test}"
展示stdout/stderr和退出码。

Managing Custom Integrations

管理自定义集成

List existing:
bash
jq '.customIntegrations.integrations[] | {id, type, preset, enabled, events}' "$CONFIG_FILE"
Disable/Enable:
bash
undefined
列出现有集成:
bash
jq '.customIntegrations.integrations[] | {id, type, preset, enabled, events}' "$CONFIG_FILE"
禁用/启用:
bash
undefined

Disable

禁用

jq '.customIntegrations.integrations = [.customIntegrations.integrations[] | if .id == "my-integration" then .enabled = false else . end]' "$CONFIG_FILE"
jq '.customIntegrations.integrations = [.customIntegrations.integrations[] | if .id == "my-integration" then .enabled = false else . end]' "$CONFIG_FILE"

Enable

启用

jq '.customIntegrations.integrations = [.customIntegrations.integrations[] | if .id == "my-integration" then .enabled = true else . end]' "$CONFIG_FILE"

**Remove:**
```bash
jq '.customIntegrations.integrations = [.customIntegrations.integrations[] | select(.id != "my-integration")]' "$CONFIG_FILE"
jq '.customIntegrations.integrations = [.customIntegrations.integrations[] | if .id == "my-integration" then .enabled = true else . end]' "$CONFIG_FILE"

**删除:**
```bash
jq '.customIntegrations.integrations = [.customIntegrations.integrations[] | select(.id != "my-integration")]' "$CONFIG_FILE"

Template Variables Reference

模板变量参考

All custom integrations support these template variables:
VariableDescriptionExample
{{sessionId}}
Unique session ID
sess_abc123
{{projectPath}}
Full project path
/home/user/my-project
{{projectName}}
Project directory name
my-project
{{timestamp}}
ISO 8601 timestamp
2026-03-05T14:30:00Z
{{event}}
Event name
session-end
{{duration}}
Human-readable duration
45s
{{durationMs}}
Duration in milliseconds
45000
{{reason}}
Stop/end reason
completed
{{tmuxSession}}
tmux session name
claude:my-project
Session-end only:
  • {{agentsSpawned}}
    ,
    {{agentsCompleted}}
    ,
    {{modesUsed}}
    ,
    {{contextSummary}}
Ask-user-question only:
  • {{question}}

所有自定义集成都支持以下模板变量:
变量描述示例
{{sessionId}}
唯一会话ID
sess_abc123
{{projectPath}}
项目完整路径
/home/user/my-project
{{projectName}}
项目目录名称
my-project
{{timestamp}}
ISO 8601时间戳
2026-03-05T14:30:00Z
{{event}}
事件名称
session-end
{{duration}}
人类可读的耗时
45s
{{durationMs}}
耗时(毫秒)
45000
{{reason}}
停止/结束原因
completed
{{tmuxSession}}
tmux会话名称
claude:my-project
仅session-end事件可用:
  • {{agentsSpawned}}
    {{agentsCompleted}}
    {{modesUsed}}
    {{contextSummary}}
仅ask-user-question事件可用:
  • {{question}}

Related

相关内容

  • Template variables:
    src/notifications/template-variables.ts
  • Validation:
    src/notifications/validation.ts
  • Presets:
    src/notifications/presets.ts
  • 模板变量:
    src/notifications/template-variables.ts
  • 校验逻辑:
    src/notifications/validation.ts
  • 预设配置:
    src/notifications/presets.ts