# NotifyHub — Multi-Channel Notification Dispatcher (`kopachelli/notifyhub`) Actor

Send each notification to Slack, Discord, Telegram or a generic webhook — one dataset item per channel attempt, pay per event. Message bodies are never stored; dryRun validates without sending.

- **URL**: https://apify.com/kopachelli/notifyhub.md
- **Developed by:** [Khristian Kopachelli](https://apify.com/kopachelli) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 notifications

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

**Send each notification to Slack, Discord, Telegram or a generic webhook — one
dataset item per channel attempt, in batch. Message bodies are never stored in the
dataset; channel secrets are masked in every result.**

> **Your credentials stay yours.** Webhook URLs and bot tokens go into the run
> input, which is visible in the Apify Console to whoever can see the run. Use
> least-privilege webhooks. The Actor masks them in the output but cannot hide
> them from the input record.

> **No automatic retry.** A retried send can post the same message twice, so a
> failed delivery is reported honestly (`failed` + reason) and you decide whether
> to resend.

### What it is for

- **Multi-channel alerting.** One message fans out to Slack, Discord, Telegram
  and any HTTPS endpoint in a single run.
- **Deploy/monitoring notifications.** Scheduled runs turn dataset rows or
  upstream events into chat messages.
- **Webhook bridging.** Post to internal tools that accept JSON webhooks, with a
  uniform `{text, sentAtUtc, source}` envelope.

### Input

| Field | Default | Meaning |
|---|---|---|
| `notifications` (required) | — | The messages, one object per notification: `{ "text": "…", "channels": […], "vars": {…} }`. `text` may contain `{{name}}` placeholders filled from `vars`. |
| `dryRun` | false | Validate channels and render templates **without sending anything and without charging**. |
| `maxItems` | 200 | The run stops after this many notifications. The largest value is 200. There is no "unlimited". |
| `fetchConcurrency` | 4 | How many notifications are delivered at the same time (1–16). Each notification's channels run in parallel. Higher values finish faster but burst more requests at the providers. |

#### Channels

Each entry in `channels` is `{ "type": … }` plus its credentials:

| Type | Extra fields | Endpoint |
|---|---|---|
| `slack` | `url` — an `https://hooks.slack.com/…` webhook | POST `{text}` |
| `discord` | `url` — an `https://discord.com/api/webhooks/…` webhook | POST `{content}` |
| `telegram` | `botToken`, `chatId` | POST to `api.telegram.org` |
| `webhook` | `url` — any `https` URL on port 443 with a path | POST `{text, sentAtUtc, source}` |

Hard caps: ≤ 200 notifications, ≤ 10 channels each, ≤ 8 KB text, ≤ 2,000 channel
attempts per run. URLs must be `https` on port 443 and must not embed credentials
(`user:pass@host` is rejected). Private/loopback/link-local addresses are refused for
`webhook` URLs.

### Example input

```json
{
    "notifications": [
        {
            "text": "Deploy finished: {{service}} is live.",
            "vars": { "service": "api" },
            "channels": [
                { "type": "slack", "url": "https://hooks.slack.com/services/YOUR/WEBHOOK" },
                { "type": "discord", "url": "https://discord.com/api/webhooks/YOUR/WEBHOOK" },
                { "type": "telegram", "botToken": "123:ABC", "chatId": "-100123" },
                { "type": "webhook", "url": "https://your-tool.example.com/notify" }
            ]
        }
    ],
    "dryRun": false
}
```

### Output

One dataset item per channel attempt:

| Field | Meaning |
|---|---|
| `notificationIndex`, `channelIndex` | Position in the input (0-based). |
| `channel.type`, `channel.target` | The destination — target is **masked** (origin only, never the secret path or token). |
| `status` | `delivered` (HTTP 2xx), `failed` (see `reason`), `skipped` (invalid channel spec), `dry-run`. |
| `httpStatus`, `latencyMs` | What the endpoint answered and how long it took. |
| `unresolvedVars` | `{{placeholder}}` names that had no matching var. |
| `dryRun`, `fetchedAtUtc` | Run mode and processing time. |

The message body and `vars` values are **never written to the dataset**.

### Pricing

Pay per event: `notifyhub-notification` per notification with at least one valid
channel, `channel-delivered` per successful channel. `dryRun` and fully-invalid
input are free. Final prices are the store owner's decision (see `docs/PRD.md` §7).

### Limits and honesty

- Per-type text ceilings are enforced before sending: Telegram 4,096 characters,
  Discord 2,000, Slack 4,000. Longer text fails with a clear reason instead of a
  wasted API call; the generic webhook has no provider limit (the 8 KB input cap
  applies).
- Discord webhooks are rate-limited (~30 requests/minute per webhook); bursts
  can fail with HTTP 429 — there is no retry, resend deliberately.
- The generic `webhook` channel cannot reach private-network addresses: IP
  literals are refused at validation, and hostnames are DNS-resolved before
  sending — any private/loopback/link-local/metadata answer blocks the send.
  A DNS-rebinding race remains a documented residual risk.

# Actor input Schema

## `notifications` (type: `array`):

The messages to send, one object per notification: { "text": "message", "channels": \[ {"type": "slack", "url": "https://hooks.slack.com/…"} ], "vars": { "name": "value" } }. Text may contain {{name}} placeholders filled from vars. Channel types: slack, discord, telegram (needs botToken + chatId), webhook (any https URL).

## `dryRun` (type: `boolean`):

Validate channels and render templates without sending anything. No messages are delivered and nothing is charged.

## `maxItems` (type: `integer`):

The run stops after this many notifications. There is no "unlimited": the largest value is 200.

## `fetchConcurrency` (type: `integer`):

How many notifications are delivered at the same time. Each notification's channels run in parallel. Higher values finish faster but burst more requests at the providers.

## Actor input object example

```json
{
  "notifications": [
    {
      "text": "Deploy finished: {{service}} is live.",
      "vars": {
        "service": "api"
      },
      "channels": [
        {
          "type": "webhook",
          "url": "https://example.com/notify"
        },
        {
          "type": "slack",
          "url": "https://hooks.slack.com/services/EXAMPLE/EXAMPLE/EXAMPLE"
        }
      ]
    },
    {
      "text": "Daily digest ready.",
      "channels": [
        {
          "type": "discord",
          "url": "https://discord.com/api/webhooks/EXAMPLE/EXAMPLE"
        }
      ]
    }
  ],
  "dryRun": false,
  "maxItems": 200,
  "fetchConcurrency": 4
}
```

# Actor output Schema

## `items` (type: `string`):

One item per channel attempt: channel, masked target, status, HTTP status and latency. Message bodies are never stored.

## `summary` (type: `string`):

How the run ended: notifications received, per-status counts, why it stopped.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "notifications": [
        {
            "text": "Deploy finished: {{service}} is live.",
            "vars": {
                "service": "api"
            },
            "channels": [
                {
                    "type": "webhook",
                    "url": "https://example.com/notify"
                },
                {
                    "type": "slack",
                    "url": "https://hooks.slack.com/services/EXAMPLE/EXAMPLE/EXAMPLE"
                }
            ]
        },
        {
            "text": "Daily digest ready.",
            "channels": [
                {
                    "type": "discord",
                    "url": "https://discord.com/api/webhooks/EXAMPLE/EXAMPLE"
                }
            ]
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("kopachelli/notifyhub").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "notifications": [
        {
            "text": "Deploy finished: {{service}} is live.",
            "vars": { "service": "api" },
            "channels": [
                {
                    "type": "webhook",
                    "url": "https://example.com/notify",
                },
                {
                    "type": "slack",
                    "url": "https://hooks.slack.com/services/EXAMPLE/EXAMPLE/EXAMPLE",
                },
            ],
        },
        {
            "text": "Daily digest ready.",
            "channels": [{
                    "type": "discord",
                    "url": "https://discord.com/api/webhooks/EXAMPLE/EXAMPLE",
                }],
        },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("kopachelli/notifyhub").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "notifications": [
    {
      "text": "Deploy finished: {{service}} is live.",
      "vars": {
        "service": "api"
      },
      "channels": [
        {
          "type": "webhook",
          "url": "https://example.com/notify"
        },
        {
          "type": "slack",
          "url": "https://hooks.slack.com/services/EXAMPLE/EXAMPLE/EXAMPLE"
        }
      ]
    },
    {
      "text": "Daily digest ready.",
      "channels": [
        {
          "type": "discord",
          "url": "https://discord.com/api/webhooks/EXAMPLE/EXAMPLE"
        }
      ]
    }
  ]
}' |
apify call kopachelli/notifyhub --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,kopachelli/notifyhub"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/Sbd2vQjz2JSDtuUHc/builds/YD9T4v1LWhOWAH5Pp/openapi.json
