Oref Alerts Slack Bot

March 2, 2026 · View on GitHub

Real-time Pikud HaOref (Israel Home Front Command) emergency alerts in Slack. Users pin their locations and get @mentioned when an alert affects their area.

Features

  • Polls the official oref.org.il endpoint every 3 seconds
  • Color-coded severity sidebar (red for danger, yellow for drills)
  • English alert labels with Hebrew zone names
  • Users subscribe to zones via /oref pin <zone> and get @mentioned
  • Threaded check-in prompt after each alert — react ✅ to confirm you're safe
  • Dynamic zone list fetched from Pikud HaOref and cached locally
  • Runs via Socket Mode — no public URL or ngrok needed
  • SQLite storage, Docker-ready

Slack App Setup

  1. Go to api.slack.com/apps
  2. Click Create New AppFrom an app manifest
  3. Select your workspace
  4. Paste the contents of slack-manifest.yml
  5. Click Create

Option B: Create manually

  1. Go to api.slack.com/appsCreate New AppFrom scratch
  2. Name it Oref Alerts, select your workspace

Enable Socket Mode:

  1. Go to Settings → Socket Mode → toggle Enable Socket Mode
  2. Create an App-Level Token with the connections:write scope — save the xapp-... token

Add slash command:

  1. Go to Features → Slash CommandsCreate New Command
    • Command: /oref
    • Short description: Manage Oref alert location subscriptions
    • Usage hint: [pin|unpin|zones|my-locations] [zone name or search query]

Set bot scopes:

  1. Go to Features → OAuth & Permissions → Scopes → Bot Token Scopes
    • channels:manage, chat:write, commands, im:history, reactions:write, users:read

Install:

  1. Go to Settings → Install AppInstall to Workspace
  2. Copy the Bot User OAuth Token (xoxb-...)

Get the channel ID

  1. In Slack, right-click the channel where alerts should be posted → View channel details → scroll to the bottom to find the Channel ID (starts with C)

Configuration

Copy .env.example to .env and fill in:

SLACK_BOT_TOKEN=xoxb-...          # Bot User OAuth Token (step 8)
SLACK_APP_TOKEN=xapp-...          # App-Level Token (step 4)
ALERT_CHANNEL_ID=C0123456789      # Channel ID (step 9)

Optional:

DB_PATH=./oref.db                 # SQLite database path
DATA_DIR=./data                   # Zone cache directory
POLL_INTERVAL=3                   # Seconds between polls

Running

cp .env.example .env
# edit .env with your tokens

docker compose up --build

Locally with uv

uv sync
uv run python -m oref_alerts.main

Usage

Once the bot is running and connected to Slack:

CommandDescription
/oref zones תל אביבSearch for zones matching a query
/oref pin תל אביב - מרכז העירSubscribe to alerts for a zone
/oref unpin תל אביב - מרכז העירUnsubscribe from a zone
/oref my-locationsList your pinned zones
/oref lang enSwitch to English responses
/orefShow help

All responses are ephemeral (only visible to you). When an alert fires, the bot posts to the configured channel and @mentions users who have pinned the affected zones. A threaded check-in prompt follows each alert — team members react ✅ to signal they're safe.

Development

uv sync                  # install deps including dev
uv run pytest            # run tests

Architecture

asyncio event loop
├── Slack Socket Mode (outbound WebSocket)
│   ├── /oref slash command handler
│   └── DM handler (pin/unpin/zones via direct message)
├── Oref Poller (aiohttp, every 3s)
│   └── Alert Processor → dedup → lookup users → Block Kit message → Slack
│       └── Threaded check-in prompt with seeded ✅ reaction
└── Zone Refresher (every 12h)
    └── Fetch zone list from oref.org.il → cache to disk

Invite the bot

After setup, invite the bot to your alerts channel:

/invite @Oref Alerts