Loading...
Loading...
Configure notification integrations (Telegram, Discord, Slack) via natural language
npx skill4agent add yeachan-heo/oh-my-claudecode configure-notifications~/.claude/.omc-config.jsonCONFIG_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"
fiTo 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)digits:alphanumeric123456789:ABCdefGHI...# Help user find their chat 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"'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
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"# Example: disable session-start if not selected
echo "$(cat "$CONFIG_FILE")" | jq \
'.notifications.events = (.notifications.events // {}) |
.notifications.events["session-start"] = {enabled: false}' > "$CONFIG_FILE"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/startTelegram 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 slackexport OMC_TELEGRAM_BOT_TOKEN="123456789:ABCdefGHIjklMNOpqrsTUVwxyz"
export OMC_TELEGRAM_CHAT_ID="123456789".omc-config.json~/.claude/.omc-config.jsonCONFIG_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"
fihttps://discord.com/api/webhooks/https://discordapp.com/api/webhooks/<@USER_ID><@1465264645320474637><@&ROLE_ID><@&123456789>CONFIG_FILE="$HOME/.claude/.omc-config.json"
mkdir -p "$(dirname "$CONFIG_FILE")"
if [ -f "$CONFIG_FILE" ]; then
EXISTING=$(cat "$CONFIG_FILE")
else
EXISTING='{}'
fi.omc-config.json# WEBHOOK_URL, MENTION, USERNAME are collected from user
# EVENTS is the list of enabled 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"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"# Example: disable session-start if not selected
echo "$(cat "$CONFIG_FILE")" | jq \
'.notifications.events = (.notifications.events // {}) |
.notifications.events["session-start"] = {enabled: false}' > "$CONFIG_FILE"# For 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"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 slackexport OMC_DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/..."
export OMC_DISCORD_MENTION="<@1465264645320474637>" # optionalexport OMC_DISCORD_NOTIFIER_BOT_TOKEN="your-bot-token"
export OMC_DISCORD_NOTIFIER_CHANNEL="your-channel-id"
export OMC_DISCORD_MENTION="<@1465264645320474637>" # optional.omc-config.json~/.claude/.omc-config.jsonCONFIG_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"
fiTo 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/...)https://hooks.slack.com/services/<@MEMBER_ID><@U1234567890><!channel><!here>#alertsCONFIG_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
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"# Example: disable session-start if not selected
echo "$(cat "$CONFIG_FILE")" | jq \
'.notifications.events = (.notifications.events // {}) |
.notifications.events["session-start"] = {enabled: false}' > "$CONFIG_FILE"# For 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"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 telegramexport OMC_SLACK_WEBHOOK_URL="https://hooks.slack.com/services/T00/B00/xxx"
export OMC_SLACK_MENTION="<@U1234567890>" # optional.omc-config.json| Type | Format | Example |
|---|---|---|
| User | | |
| Channel | | |
| Here | | |
| Everyone | | |
| User Group | | |
omc --telegramOMC_TELEGRAM=1omc --discordOMC_DISCORD=1omc --slackOMC_SLACK=1omc --webhookOMC_WEBHOOK=1omc --openclawOMC_OPENCLAW=1omc --telegram --discordomc --telegram --slack --webhookomc --telegram --openclawomcomc_config.hook.json~/.claude/omc_config.hook.jsonHook 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.jsonAvailable 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}}{{projectDisplay}} session ended ({{duration}}) — {{reasonDisplay}}Input needed on {{projectDisplay}}: {{question}}{{projectDisplay}} is idle. {{#if reason}}Reason: {{reason}}{{/if}}Session started: {{projectDisplay}} at {{time}}~/.claude/omc_config.hook.json{
"version": 1,
"enabled": true,
"events": {
"<event-name>": {
"enabled": true,
"template": "<user-provided-template>",
"platforms": {
"discord": { "template": "<discord-specific>" },
"telegram": { "template": "<telegram-specific>" }
}
}
}
}validateTemplate(){
"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}}"
}
}
}/oh-my-claudecode:configure-openclaw~/.claude/omc_config.openclaw.jsonLEGACY_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"
fiomc_config.openclaw.json.omc-config.jsonomc_config.openclaw.json.bak# For webhook integrations
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".omc-config.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"]
}
]
}
}{
"event": "{{event}}",
"sessionId": "{{sessionId}}",
"projectName": "{{projectName}}",
"timestamp": "{{timestamp}}"
}curl/usr/local/bin/my-scriptnotify-send-X
POST
-d
{"event":"{{event}}","session":"{{sessionId}}"}
https://my-api.com/notify$COMMAND "${ARGS[@]//{{event}}/test}"jq '.customIntegrations.integrations[] | {id, type, preset, enabled, events}' "$CONFIG_FILE"# Disable
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"jq '.customIntegrations.integrations = [.customIntegrations.integrations[] | select(.id != "my-integration")]' "$CONFIG_FILE"| Variable | Description | Example |
|---|---|---|
| Unique session ID | |
| Full project path | |
| Project directory name | |
| ISO 8601 timestamp | |
| Event name | |
| Human-readable duration | |
| Duration in milliseconds | |
| Stop/end reason | |
| tmux session name | |
{{agentsSpawned}}{{agentsCompleted}}{{modesUsed}}{{contextSummary}}{{question}}src/notifications/template-variables.tssrc/notifications/validation.tssrc/notifications/presets.ts