{"id":9308,"library":"slackweb","title":"Slackweb Incoming Webhook Client","description":"Slackweb is a minimalistic Python library for sending messages to Slack via incoming webhooks. It provides a simple interface to construct and send webhook payloads, supporting basic text, attachments, and Block Kit components. The current version is 1.0.5, with releases occurring infrequently, primarily for bug fixes or minor enhancements.","status":"active","version":"1.0.5","language":"en","source_language":"en","source_url":"https://github.com/satoshi03/slack-python-webhook","tags":["slack","webhook","messaging","notifications"],"install":[{"cmd":"pip install slackweb","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"The main class is `Slack`, not `Client`.","wrong":"from slackweb import Client","symbol":"Slack","correct":"from slackweb import Slack"}],"quickstart":{"code":"import os\nimport slackweb\n\n# Get your Slack Incoming Webhook URL from environment variables\n# e.g., SLACK_WEBHOOK_URL='https://hooks.slack.com/services/T.../B.../...'\nWEBHOOK_URL = os.environ.get('SLACK_WEBHOOK_URL', 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX')\n\nif WEBHOOK_URL == 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX':\n    print(\"WARNING: Please set the SLACK_WEBHOOK_URL environment variable to a valid Slack Incoming Webhook URL.\")\n    print(\"Skipping quickstart execution due to missing URL.\")\nelse:\n    try:\n        slack = slackweb.Slack(url=WEBHOOK_URL)\n        \n        # Send a simple text message\n        slack.notify(text=\"Hello from slackweb! This is a test message.\")\n        print(\"Successfully sent a simple Slack message.\")\n\n        # Send a message to a specific channel with a username and emoji icon\n        slack.notify(\n            channel=\"#general\", \n            username=\"My Python Bot\", \n            icon_emoji=\":robot_face:\", \n            text=\"Another message with custom sender info.\"\n        )\n        print(\"Successfully sent a Slack message with custom sender info.\")\n\n        # Send a message with an attachment\n        slack.notify(\n            attachments=[\n                {\n                    \"title\": \"Example Attachment\",\n                    \"text\": \"This is an attachment with some extra info.\",\n                    \"color\": \"#36a64f\"\n                }\n            ]\n        )\n        print(\"Successfully sent a Slack message with an attachment.\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n        print(\"Please ensure your SLACK_WEBHOOK_URL is correct and accessible.\")","lang":"python","description":"This quickstart demonstrates how to initialize the `Slack` client with your webhook URL and send various types of messages, including simple text, messages with custom sender information, and messages with attachments. Ensure `SLACK_WEBHOOK_URL` is set in your environment."},"warnings":[{"fix":"If you need broader Slack API functionality, switch to the `slack_sdk` library. `pip install slack_sdk`.","message":"This library is *only* for Slack Incoming Webhooks. It does not support the full Slack Web API (e.g., chat.postMessage, users.list, RTM API) or Bot Token authentication. For full API access, use `slack_sdk` (the official Python Slack SDK).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always initialize `slackweb.Slack` by passing the webhook URL: `slack = slackweb.Slack(url='YOUR_WEBHOOK_URL')`.","message":"Prior to v1.0.3, the `Slack` object could potentially be instantiated without a `url` parameter and set later. As of v1.0.3, it is strongly recommended (and effectively required for immediate use) to pass the webhook URL directly to the constructor.","severity":"deprecated","affected_versions":"<1.0.3 behavior, 1.0.3+"},{"fix":"For complex Block Kit layouts, construct the `blocks` payload as a Python dictionary according to Slack's API docs and pass it directly to `slack.notify(blocks=...)`.","message":"The library might not immediately support the newest Slack Block Kit features or advanced authentication methods like OAuth token exchange. Always refer to the official Slack API documentation for the latest webhook payload structure.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Use the `slack_sdk` library for full Slack Web API access. If you only need webhooks, use `slack.notify()`.","cause":"Attempting to use full Slack Web API methods (like `chat_postMessage`) with the `slackweb` library, which is designed only for incoming webhooks.","error":"AttributeError: 'Slack' object has no attribute 'chat_postMessage'"},{"fix":"Ensure your Slack webhook URL starts with `https://hooks.slack.com/...`.","cause":"The webhook URL provided to `slackweb.Slack` is missing the `http://` or `https://` scheme.","error":"requests.exceptions.MissingSchema: Invalid URL 'YOUR_WEBHOOK_URL': No schema supplied. Perhaps you meant https://YOUR_WEBHOOK_URL?"},{"fix":"Pass the webhook URL directly to the constructor: `slack = slackweb.Slack(url='YOUR_WEBHOOK_URL')`.","cause":"You tried to instantiate `slackweb.Slack()` without providing the `url` parameter in versions 1.0.3 and later.","error":"TypeError: __init__() missing 1 required positional argument: 'url'"}]}