Loading...
Loading...
Configure Telegram bot notifications via natural language
npx skill4agent add yeachan-heo/oh-my-codex configure-telegram~/.codex/.omx-config.jsonCONFIG_FILE="$HOME/.codex/.omx-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 OMX 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/.codex/.omx-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=OMX 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: ~/.codex/.omx-config.json
You can also set these via environment variables:
OMX_TELEGRAM_BOT_TOKEN=123456789:ABCdefGHI...
OMX_TELEGRAM_CHAT_ID=123456789
To reconfigure: /configure-telegram
To configure Discord: /configure-discordexport OMX_TELEGRAM_BOT_TOKEN="123456789:ABCdefGHIjklMNOpqrsTUVwxyz"
export OMX_TELEGRAM_CHAT_ID="123456789".omx-config.json