← All deliverables

Deliverable 6 of 6

AI bot block alert script

A quarterly manual audit finds a problem that's already cost you a quarter of visibility. This script catches it within the hour instead — the moment a legitimate AI crawler starts getting silently blocked.

1
bash script, hardened
4
crawlers monitored
Hourly
recommended cron interval

The actual script

#!/bin/bash
# ai_bot_block_alert.sh — Alerts when live-retrieval AI crawlers are being blocked.
# Reference: The AI Search Playbook, Chapter 3.5

set -euo pipefail

LOG_FILE="${AI_BOT_LOG_FILE:-/var/log/nginx/access.log}"
SLACK_WEBHOOK_URL="${SLACK_WEBHOOK_URL:-}"

# ... validates webhook and log file exist, then:
BLOCKED=$(grep -E "OAI-SearchBot|PerplexityBot|Claude-User|Google-Extended" "$LOG_FILE" | \
  awk -F'"' '$3 ~ /^ (403|429|503)/' | wc -l)

What it actually monitors

Four live-retrieval crawlers, specifically — OAI-SearchBot (ChatGPT Search), PerplexityBot, Claude-User, and Google-Extended — checked against 403, 429, and 503 response codes in your server logs. If any of these are being blocked, a Slack message fires immediately rather than waiting for someone to run a manual check.

Setup, from the script's own header

  1. chmod +x ai_bot_block_alert.sh
  2. export SLACK_WEBHOOK_URL="https://hooks.slack.com/services/..."
  3. Add to crontab for hourly runs: 0 * * * * /path/to/ai_bot_block_alert.sh
Hardened, not just illustrative

The version in the bundle has proper error handling for a missing webhook URL or log file — it fails loudly and specifically rather than silently doing nothing. Full deployment walkthrough: Implementation Guide, Part 3.2.

Every item above ships together in one bundle — no upsells, no tiers.

Get the full bundle — $297