// free agents / twitch-live-alert
🔴 Twitch live alert
“Post in my Discord server when my favourite Twitch streamers go live.”
Free, no sign-up. MIT licence. Python standard library only, so there's nothing to pip install.
What it does
Asks Twitch's official API which of your channels are live and posts one message per new stream to a Discord channel webhook, a Telegram chat or Slack. No bot to invite or host: it runs every few minutes from cron or n8n and remembers each stream id, so a stream is announced once. Optional role ping and game filter.
What you need
- Python 3.9+ (no extra packages) or n8n
- A free Twitch app (Client ID and Client Secret from dev.twitch.tv/console)
- A Discord webhook, a Telegram bot token and chat id, or a Slack incoming webhook
5-minute setup
Python
- Install Python 3.9+ and unzip the download.
- Try it with no accounts:
python3 twitch_live_alert.py --demo - Copy
.env.exampleto.envand fill it in. - Run:
set -a; . ./.env; set +a; python3 twitch_live_alert.py(Windows steps in the README).
n8n (no code)
- Workflows, then Import from file, then
twitch-live-alert.n8n.json. - Follow the yellow “Read me” note (credentials or webhook).
- Test workflow, then switch it to Active.
Run it on a schedule
Every 3 minutes with cron:
*/3 * * * * cd /path/to/twitch-live-alert && set -a && . ./.env && set +a && python3 twitch_live_alert.py >> run.log 2>&1On Windows use Task Scheduler. With n8n, the Schedule node does it for you.
Settings
| Variable | What it does |
|---|---|
TWITCH_CLIENT_ID / TWITCH_CLIENT_SECRET | From your app at dev.twitch.tv/console |
CHANNELS | Comma-separated channel names (twitch.tv/name), any number |
DISCORD_WEBHOOK_URL | Where alerts go (channel settings, then Integrations, then Webhooks) |
DISCORD_ROLE_ID | Optional: ping only this role; @everyone in stream titles never pings |
GAMES | Optional: only announce streams in these games, e.g. Valorant,Minecraft |
TELEGRAM_BOT_TOKEN / TELEGRAM_CHAT_ID | Optional: also post to Telegram |
SLACK_WEBHOOK_URL | Optional: also post to Slack |
STATE_FILE | Default twitch_live_state.json (keep it between runs) |
What we tested
- Python, against local stand-ins for the Twitch token and Helix streams APIs, Discord, Telegram and Slack: a channel going live was posted once to all three, the same stream was never posted again, a second channel going live posted only that one, going offline cleared it, and a new stream from the same channel was announced again.
- The Twitch app token is cached in the state file and reused; when Helix answered 401 the script fetched a new token once and carried on. Discord and Telegram HTTP 429 replies were waited out and retried.
- A stream title containing @everyone was posted as plain text with mentions disabled; DISCORD_ROLE_ID pings only that role. GAMES=Valorant skipped a Minecraft stream. If Slack was down, Discord and Telegram still posted and the stream wasn't repeated next run; if every destination failed, it was retried on the next run.
- --demo shows sample alerts with no accounts; --dry-run uses real Twitch data and posts and saves nothing.
- n8n workflow run as an active workflow in a real n8n 2.43 install (every minute for the test, mock Twitch and Discord): the first run posted the live channel, the second posted nothing, and when a second channel went live only that one was posted.
Honest limits
- Not tested with real Twitch keys or a real Discord server: Twitch and Discord were local stand-ins that follow their documented APIs. The real Helix endpoint does answer 401 without a token, as the script expects.
- A check every 3 minutes means an alert can arrive up to 3 minutes after the stream starts. Twitch's EventSub is instant but needs a public HTTPS server.
- If a streamer's connection drops and Twitch starts a new stream, it gets a new id and is announced again.
- The n8n version posts to Discord only and gets a fresh token each run; role pings, game filter, Telegram and Slack are in the Python version.
Related guides
Want one built for your task?
Describe it in one sentence. We build it, test it and email it to you, usually within 24h. Free while we're in beta.