```python:inference/core/workflows/core_steps/sinks/slack/notification/v1.py
from inference.core.workflows.prototypes.block import WorkflowBlockManifest

LONG_DESCRIPTION = """
Send notifications to Slack channels with customizable message content featuring dynamic workflow data parameters, file attachments, cooldown throttling using cache-based session tracking, and optional async background execution for team alerts, monitoring, and real-time communication workflows.

## How This Block Works

This block sends notifications to Slack channels using the Slack Web API, integrating workflow execution results into message content. The block:

1. Checks if the sink is disabled via `disable_sink` flag (if disabled, returns immediately without sending)
2. Generates a cache key for cooldown tracking using the Slack token hash and `cooldown_session_key` (unique per workflow step)
3. Validates cooldown period by checking cache for the last notification timestamp (if enabled, throttles notifications within `cooldown_seconds` of the last sent notification, returning throttling status)
4. Creates or retrieves a Slack WebClient instance for the provided token (caches clients by token hash for efficiency)
5. Formats the message by processing dynamic parameters (replaces placeholders like `{{ $parameters.parameter_name }}` with actual workflow data from `message_parameters`)
6. Applies optional UQL operations to transform parameter values before insertion (e.g., extract class names from detections, calculate metrics, filter data) using `message_parameters_operations`
7. Sends the notification to the specified Slack channel:
   - **Without attachments**: Uses `chat_postMessage` API to send text-only messages
   - **With attachments**: Uses `files_upload_v2` API to upload files with the message as an initial comment
8. Updates the cache with the current notification timestamp (expires after 15 minutes)
9. Executes synchronously or asynchronously based on `fire_and_forget` setting:
   - **Synchronous mode** (`fire_and_forget=False`): Waits for Slack API call completion, returns actual error status for debugging
   - **Asynchronous mode** (`fire_and_forget=True`): Sends notification in background task, workflow continues immediately, error status always False
10. Returns status outputs indicating success, throttling, or errors (includes Slack API error details when available)

The block supports dynamic message content through parameter placeholders that are replaced with workflow data at runtime. Message parameters can be raw workflow outputs or transformed using UQL operations (e.g., extract properties, calculate counts, filter values). Attachments are sourced from other workflow blocks that produce string or binary content (e.g., CSV Formatter for reports, image outputs for visualizations). Cooldown prevents notification spam by enforcing minimum time between sends using cache-based tracking with session keys, enabling per-step throttling in distributed or multi-instance environments.

## Requirements

**Slack API Token**: Requires a Slack API token (Bot Token or User Token) with appropriate permissions:
- Token must have `chat:write` scope to send messages to channels
- Token must have `files:write` scope if using attachments
- Token can be provided via workflow inputs (recommended for security) or stored in workflow definitions
- View [Slack API documentation](https://api.slack.com/tutorials/tracks/getting-a-token) or [Roboflow Blog guide](https://blog.roboflow.com/slack-notification-workflows/) for token generation instructions

**Channel Configuration**: Requires a valid Slack channel identifier (channel ID or channel name starting with `#`). The bot or user associated with the token must be a member of the channel.

**Cooldown Session Key**: The `cooldown_session_key` must be unique for each Slack Notification step in your workflow to enable proper per-step cooldown tracking. The cooldown mechanism uses cache-based storage with a 15-minute expiration time, and cooldown seconds must be between 0 and 900 (15 minutes).

## Common Use Cases

- **Team Alert Notifications**: Send Slack alerts to team channels when specific conditions are detected (e.g., alert security team when unauthorized objects detected, notify operations when anomaly detected, send alerts when detection counts exceed thresholds), enabling real-time team collaboration and incident response
- **Workflow Execution Updates**: Send Slack notifications about workflow execution status and results (e.g., notify team when batch processing completes, send daily summary reports, alert about workflow failures), enabling team visibility into automated processes
- **Detection Summaries**: Send Slack messages with detection results and aggregated statistics (e.g., share lists of detected objects, send counts and classifications, include detection confidence summaries), enabling stakeholders to stay informed about workflow outputs via team communication channels
- **Report Distribution**: Upload and share generated reports and data exports via Slack (e.g., attach CSV reports from CSV Formatter, share exported detection data, include formatted analytics summaries), enabling automated data distribution through team channels
- **Real-Time Monitoring**: Send continuous monitoring updates and status notifications (e.g., notify about system health issues, send periodic performance metrics, alert about processing milestones), enabling real-time visibility for operational monitoring
- **Multi-Channel Broadcasting**: Send notifications to different Slack channels based on workflow conditions or routing logic (e.g., send alerts to different channels per detection type, route notifications by severity level, distribute reports to department-specific channels), enabling targeted communication and notification routing

## Connecting to Other Blocks

This block receives data from workflow steps and sends Slack notifications:

- **After detection or analysis blocks** (e.g., Object Detection, Instance Segmentation, Classification) to send alerts or summaries when objects are detected, classifications are made, or thresholds are exceeded, enabling real-time team notifications and collaboration
- **After data processing blocks** (e.g., Expression, Property Definition, Detections Filter) to include computed metrics, transformed data, or filtered results in Slack notifications, enabling customized reporting with processed data in team channels
- **After formatter blocks** (e.g., CSV Formatter) to attach formatted reports and exports to Slack messages, enabling automated distribution of structured data and analytics through team communication channels
- **In conditional workflows** (e.g., Continue If) to send notifications only when specific conditions are met, enabling event-driven alerting and team communication
- **After aggregation blocks** (e.g., Data Aggregator) to send periodic analytics summaries and statistical reports to Slack, enabling scheduled team updates and trend analysis
- **In monitoring workflows** to send status updates, error notifications, or health check reports, enabling automated system monitoring and incident management through Slack
"""



_AIR_GAPPED_AVAILABILITY: dict = {"available": False, "reason": "requires_internet"}


class BlockManifest(WorkflowBlockManifest):

    @classmethod
    def get_air_gapped_availability(cls) -> dict:
        return _AIR_GAPPED_AVAILABILITY.copy()
```