slack-webhook

raw JSON →
1.0.7 verified Fri May 01 auth: no python

slack-webhook is a Python client library for Slack Incoming Webhooks, supporting Python 3.6 and above. Version 1.0.7 is the latest release, with infrequent updates.

pip install slack-webhook
error ModuleNotFoundError: No module named 'slack_webhook'
cause Package installed but import path is wrong (e.g., 'import slackwebhook' without underscore).
fix
Use: from slack_webhook import Slack
error requests.exceptions.MissingSchema: Invalid URL 'hooks.slack.com/services/...': No scheme supplied
cause Webhook URL provided without 'https://' prefix.
fix
Ensure the webhook URL starts with 'https://'.
error AttributeError: module 'slack_webhook' has no attribute 'Slack'
cause Import statement uses 'import slack_webhook' but tries to access Slack class incorrectly.
fix
Use: from slack_webhook import Slack
gotcha The webhook URL passed to Slack() must be the full URL, including 'https://hooks.slack.com/services/...'. Omitting the protocol or path will cause a connection error.
fix Ensure the URL is copied exactly from the Slack App configuration.
gotcha The Slack client does not verify the webhook URL or handle errors gracefully. Invalid URLs or network issues may raise unhandled exceptions.
fix Wrap calls in try/except blocks and check the response status.
deprecated The library is not actively maintained; last release was in 2020. Consider using the official slack-sdk library for webhooks.
fix Migrate to slack_sdk.webhook.WebhookClient from the slack-sdk package.

Sends a simple text message to a Slack channel via an Incoming Webhook URL.

from slack_webhook import Slack

webhook_url = os.environ.get('SLACK_WEBHOOK_URL', '')
slack = Slack(url=webhook_url)
slack.post(text="Hello, Slack!")