This article covers Build a ChatOps Bot That Summarizes in detail. Monitoring tools are great at detecting problems and terrible at explaining them. A typical alert says “CPU > 90% for 10 minutes” and leaves you to figure out why. A ChatOps bot fixes this: it watches your servers, asks an LLM to summarize what is happening in plain language, and posts the result into the chat channel where your team already works. In this guide you will build a simple ChatOps bot with Bash, an LLM API and a Slack incoming webhook.
What a ChatOps Bot Does in This Design – Build a ChatOps Bot That Summarizes
ChatOps means running operations from chat: alerts, reports and commands all live in one channel with a full history. Our ChatOps bot has three jobs:
- Collect: gather key facts from the server (failed services, disk, memory, recent errors).
- Summarize: send the facts to an LLM and get a two-sentence explanation plus a severity guess.
- Post: deliver the summary to Slack with a webhook, so the whole team sees the same information.
The bot runs from cron every 15 minutes, but it only posts when something is actually wrong — a healthy server stays silent.
Prerequisites – Build a ChatOps Bot That Summarizes
- An Ubuntu server with
curlandjqinstalled. - A Slack workspace where you can create an incoming webhook (or a Telegram bot as an alternative).
- An LLM API key, or a local Ollama model for full privacy.
- Optional: a monitoring tool such as Netdata or Zabbix already watching the server.
Step 1: Create the Slack Webhook for Your ChatOps Bot
In Slack, go to Apps → Incoming Webhooks, add it to your workspace and choose the operations channel. Slack gives you a URL like:
https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
Store it like a password — anyone with this URL can post to your channel:
sudo install -m 600 /dev/null /etc/chatops-webhook
echo "https://hooks.slack.com/services/..." | sudo tee /etc/chatops-webhook > /dev/null
Test it immediately:
WEBHOOK=$(sudo cat /etc/chatops-webhook)
curl -s -X POST "$WEBHOOK" -H "Content-Type: application/json" \
-d '{"text": "ChatOps bot is online :wave:"}'
Step 2: Collect Server Facts and Detect Problems
The bot needs a cheap health check. The script below flags three common problems: failed systemd units, a root filesystem above 85%, and less than 10% free memory.
#!/usr/bin/env bash
set -euo pipefail
ISSUES=""
FAILED=$(systemctl --failed --no-legend | wc -l)
[ "$FAILED" -gt 0 ] && ISSUES+="Failed units: $(systemctl --failed --no-legend)\n"
DISK=$(df / | awk 'NR==2 {gsub("%","",$5); print $5}')
[ "$DISK" -gt 85 ] && ISSUES+="Root filesystem at ${DISK}%\n"
MEMFREE=$(free | awk '/Mem:/ {printf "%.0f", $7/$2*100}')
[ "$MEMFREE" -lt 10 ] && ISSUES+="Only ${MEMFREE}% memory available\n"
[ -z "$ISSUES" ] && exit 0 # healthy: stay silent
echo -e "$ISSUES" > /tmp/chatops-issues.txt
Step 3: Summarize with an LLM and Post to Chat
Now add the AI layer and the delivery layer to complete the ChatOps bot:
export OPENAI_API_KEY=$(cat /etc/llm-api-key)
WEBHOOK=$(cat /etc/chatops-webhook)
CONTEXT=$(journalctl -p err --since "15 minutes ago" --no-pager | tail -n 40)
PROMPT="You are a ChatOps bot for a Linux team. Issues detected on $(hostname):
$(cat /tmp/chatops-issues.txt)
Recent errors:
$CONTEXT
Write a Slack alert: first line starts with a severity emoji (🔴/🟡), then one sentence explaining the likely cause, then one suggested next step. Maximum 60 words."
BODY=$(jq -n --arg p "$PROMPT" '{model: "gpt-4o-mini", messages: [{role: "user", content: $p}], temperature: 0.2}')
ANSWER=$(curl -s --max-time 60 https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer $OPENAI_API_KEY" -H "Content-Type: application/json" \
-d "$BODY" | jq -r '.choices[0].message.content // empty')
[ -z "$ANSWER" ] && ANSWER="⚠️ Issues detected on $(hostname), AI summary unavailable: $(cat /tmp/chatops-issues.txt)"
jq -n --arg t "$ANSWER" '{text: $t}' | curl -s -X POST "$WEBHOOK" -H "Content-Type: application/json" -d @-
Schedule the combined script every 15 minutes:
*/15 * * * * /usr/local/bin/chatops-bot.sh >/dev/null 2>&1

Step 4: Adapt the ChatOps Bot for Telegram
No Slack? The same design works with a Telegram bot. Create a bot with BotFather, get the chat ID, and replace the delivery step:
curl -s -X POST "https://api.telegram.org/bot<BOT_TOKEN>/sendMessage" \
-d "chat_id=<CHAT_ID>" --data-urlencode "text=$ANSWER"
Troubleshooting
The bot posts too often. It fires whenever an issue exists. Add a cooldown file: store the hash of the issue text and skip posting if the same hash was sent within the last 2 hours.
Slack returns no_service or 404. The webhook was deleted or the URL is incomplete. Regenerate it in Slack app settings.
The summary is vague. Give the model more context: include the failing unit’s last 20 log lines and the output of df -h or free -h in the prompt.
Nothing posts even during an outage. Run the script manually with bash -x and check each detection threshold — and make sure cron is actually running.
Conclusion
A ChatOps bot turns raw monitoring facts into readable, shared situational awareness. With one webhook, one health-check script and one LLM call, your team gets alerts that explain themselves — cause, severity and next step included. Extend it later with acknowledgement commands or by wiring it into the alert webhooks of your monitoring stack, and it becomes the front door of your incident process.