Alarme und Benachrichtigungen senden
Machen Sie bereitgestellte Bots handlungsfähig, indem Sie per E-Mail, Slack und Webhooks Alarme senden, wenn sie etwas finden oder ausfallen.
Alarme und Benachrichtigungen senden ist eine kostenlose Web Scraping & Bots-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Web Scraping & Bots-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Web Scraping & Bots-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
From Data to Action
A deployed bot that quietly stores data is only half useful. The real value comes when it notifies you: a price dropped, a keyword appeared, or the bot itself broke.
This lesson covers wiring bots to notification channels.
Choosing a Channel
Pick the channel that fits urgency:
- Email for digests and non-urgent reports.
- Slack/Discord for team-visible real-time alerts.
- Push/SMS for urgent, must-see events.
Sending Email
Python's smtplib sends email through any SMTP server. Build the message, connect securely, and send.
import smtplib
from email.message import EmailMessage
msg = EmailMessage()
msg['Subject'] = 'Price Alert'
msg['From'] = 'bot@example.com'
msg['To'] = 'me@example.com'
msg.set_content('Widget dropped to $7.99')
with smtplib.SMTP_SSL('smtp.example.com', 465) as s:
s.login('bot@example.com', 'password')
s.send_message(msg)Slack via Webhook
Slack incoming webhooks accept a simple JSON POST. No SDK required, just a URL you keep secret.
import requests
requests.post(
'https://hooks.slack.com/services/XXX/YYY/ZZZ',
json={'text': 'Price dropped to $7.99 :tada:'}
)Rich Messages
Most chat webhooks support structured blocks: titles, links, and fields. A well-formatted alert is faster to act on than a wall of text.
payload = {
'blocks': [
{'type': 'section', 'text': {'type': 'mrkdwn', 'text': '*Price Alert*\nWidget: $7.99'}}
]
}
requests.post(webhook_url, json=payload)Generic Webhooks
Webhooks let your bot trigger anything: a Zapier flow, a custom server, or another service. Send a JSON payload and let the receiver decide what to do.
requests.post('https://my-endpoint.example/hook',
json={'event': 'price_drop', 'price': 7.99})Alerting Only on Change
Do not notify on every run. Compare against the last known state and alert only when something meaningful changes, to avoid notification fatigue.
if new_price < last_price:
send_alert('price dropped to ' + str(new_price))
last_price = new_priceThrottling and Deduplication
Suppress repeat alerts for the same event within a window. Track recently-sent keys so a flapping condition does not spam you.
import time
last_sent = {}
def alert_once(key, msg, cooldown=3600):
now = time.time()
if now - last_sent.get(key, 0) > cooldown:
send_alert(msg)
last_sent[key] = nowAlerting on Bot Failure
Notify yourself when the bot itself breaks, not just on data events. Wrap the run and send an alert from the except block so silent crashes never go unnoticed.
try:
run_bot()
except Exception as e:
send_alert('Bot crashed: ' + str(e))
raiseKeeping Secrets Safe
Webhook URLs, SMTP passwords, and API tokens are credentials. Store them in environment variables or a secrets manager, never hard-coded in the repository.
import os
webhook = os.environ['SLACK_WEBHOOK_URL']Confirming Delivery
A notification call can silently fail. Check the response status and log it, so a broken webhook does not leave you unaware that alerts stopped arriving.
resp = requests.post(webhook, json=payload)
if not resp.ok:
log.error('alert delivery failed: %s', resp.status_code)Quick Check
Test your understanding of notifications.
Recap
You learned to make deployed bots actionable: choose a channel, send email via smtplib, post to Slack and generic webhooks, format rich messages, alert only on change, throttle duplicates, notify on bot failure, and keep credentials in environment variables.
Lerne Python mit einem KI-Tutor — kostenlos
Schreibe und führe echten Code in deinem Browser aus, bekomme sofortige Hilfe von einem 24/7 KI-Tutor und setze dein Lernen im Web oder in der App fort.
- Kurse
- 12
- Lektionen
- 48
Häufig gestellte Fragen
Ist die Lektion „Alarme und Benachrichtigungen senden“ kostenlos?
Ja — der vollständige Text von „Alarme und Benachrichtigungen senden“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Web Scraping & Bots-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Web Scraping & Bots-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Alarme und Benachrichtigungen senden“?
Machen Sie bereitgestellte Bots handlungsfähig, indem Sie per E-Mail, Slack und Webhooks Alarme senden, wenn sie etwas finden oder ausfallen. Du übst Web Scraping & Bots mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Web Scraping & Bots zu starten?
Keine Vorkenntnisse erforderlich. Web Scraping & Bots auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.
Wie lange dauert die Lektion „Alarme und Benachrichtigungen senden“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Web Scraping & Bots-Lektion Code schreiben und ausführen?
Ja. Jede Web Scraping & Bots-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Einen Preisüberwachungs-Bot erstellen
- Einen Social-Media-Monitor erstellen
- Bots auf Cloud-Plattformen bereitstellen
- Alarme und Benachrichtigungen senden