{"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.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install slackweb"],"cli":null},"imports":["from slackweb import Slack"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}