# new-items-notifier (`ab_workflow/apify-actors`) Actor

Get Telegram or Discord alerts for NEW items in any Apify dataset. Attach it to your scraper as an integration: it remembers what was already sent, filters items and formats messages with a template.

- **URL**: https://apify.com/ab_workflow/apify-actors.md
- **Developed by:** [Aldin Becic](https://apify.com/ab_workflow) (community)
- **Features:** Limited permissions
- **Stats:** 3 total users, 2 monthly users, 99.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 message sents

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

### What does New Items Notifier do?

**New Items Notifier for Telegram & Discord** sends you a message whenever **new items** appear in an Apify dataset. Connect it to any scraper you already run on Apify - job boards, real-estate listings, product prices, news - and get an instant **Telegram** or **Discord** alert for each new result, without receiving the same item twice.

- 🔔 **Only new items** - remembers what was already sent (by URL, ID or any field you choose).
- 🔗 **Works as an integration** - attach it to another Actor and it runs automatically after every successful run.
- 🧹 **Filters** - send only items that match, e.g. `price ≤ 1200` or `title contains "python"`.
- ✍️ **Message templates** - `{{title}}`, `{{price}}`, `{{location.city}}`... with bold text and links.
- 📦 **Per item or digest** - one message per item, or one combined summary message.
- 🧪 **Dry run** - preview the messages before sending anything.
- 💸 **Pay only for delivered messages** - failed or skipped messages are never charged.

This Actor does **not** scrape any website. It only reads a dataset in your own Apify account and posts to the channels you configure.

### Use cases

- **Job alerts** - get a Telegram message for every new job posting your job-board scraper finds.
- **Real-estate alerts** - be the first to see new flats or houses that match your price and location.
- **Price-drop alerts** - notify a Discord channel when a product price goes below your target.
- **Monitoring** - post new reviews, new listings or new search results from your own scheduled runs to your team chat.

### How to use it (step by step)

1. Create a Telegram bot and/or a Discord webhook (see the guides below).
2. Open this Actor's **Input** tab and enter the Telegram bot token + chat ID and/or the Discord webhook URL.
3. Choose a **Dataset** (or attach the Actor as an integration - recommended, see below).
4. Optionally adjust the **message template**, **filters** and the **unique item field** (default: `url`).
5. Tick **Dry run** for the first run to preview messages, then run it for real.

#### How to set up a Telegram bot

1. In Telegram, open a chat with **@BotFather** and send `/newbot`. Choose a name and a username.
2. BotFather replies with a **bot token** such as `123456789:AAH...`. Paste it into **Telegram bot token**. Keep it private.
3. Decide where the bot should post:
   - **Private chat:** open your new bot and press **Start** (bots cannot message you first).
   - **Group:** add the bot to the group.
   - **Channel:** add the bot as an **administrator** with permission to post.
4. Find the **chat ID**: send any message in that chat (or post in the channel), then open this address in your browser, replacing `<TOKEN>` with your token:

   ```
   https://api.telegram.org/bot<TOKEN>/getUpdates
   ```

   Look for `"chat":{"id":...}`. Private chats have a positive number, groups and channels a negative number (often starting with `-100`). For a **public** channel you can also use its username, e.g. `@mychannel`.
5. Paste it into **Telegram chat ID**.

#### How to set up a Discord webhook

1. In Discord, open **Server Settings → Integrations → Webhooks** (or **Edit Channel → Integrations**).
2. Click **New Webhook**, choose the channel and a name.
3. Click **Copy Webhook URL** and paste it into **Discord webhook URL**. It must start with `https://discord.com/api/webhooks/`.

Messages from item data never ping `@everyone`, `@here`, users or roles - mentions are disabled.

#### How to attach it as an integration to another Actor

This is the easiest way to get alerts automatically after every scraper run:

1. Open the Actor (or task) that produces your data, e.g. your job scraper, and go to the **Integrations** tab.
2. Click **Add integration** and search for **New Items Notifier**.
3. In **Start when**, keep **Run succeeded**.
4. Fill in your Telegram and/or Discord details, template and filters.
5. Set **Dataset** to `{{resource.defaultDatasetId}}` (recommended) - this passes the dataset of the run that just finished. If you leave it empty, the dataset is taken from the integration payload automatically.
6. Use a distinct **State key** per alert, e.g. `jobs-berlin`, so separate alerts do not share their "already sent" memory.
7. Save, and use **Test integration** with a past run to try it.

Combine it with a **schedule** on your scraper (e.g. every hour) and you have a complete alert bot.

### Input reference

| Field | Default | Description |
|---|---|---|
| `datasetId` | - | Dataset to read. Optional when running as an integration. |
| `payload` | - | Filled automatically by integrations; its `resource.defaultDatasetId` is used when `datasetId` is empty. |
| `telegramBotToken` | - | Secret. Bot token from @BotFather. |
| `telegramChatId` | - | Numeric chat ID or `@channelusername`. |
| `discordWebhookUrl` | - | Secret. `https://discord.com/api/webhooks/...` (discordapp.com also accepted). |
| `messageTemplate` | `🆕 {{title}}\n{{url}}` | Text with `{{field}}` placeholders. Nested paths like `{{location.city}}` and `{{images.0}}` work. Missing fields render empty. Values are HTML-escaped for Telegram. You may use `<b>`, `<i>`, `<u>`, `<s>`, `<code>`, `<a href="...">` in the template; for Discord they are converted to Markdown. |
| `fields` | `[]` | Extra `field: value` lines below the template. If the template and this list are both empty, the first 10 simple fields are listed. |
| `mode` | `perItem` | `perItem` = one message per item; `digest` = one combined message (split if too long). |
| `digestTitle` | `🆕 {{count}} new item(s)` | Heading of the digest; `{{count}}` = number of new items. |
| `onlyNew` | `true` | Skip items delivered in earlier runs. |
| `dedupeKey` | `url` | Field that identifies an item. If an item lacks it, a SHA-256 hash of the whole item is used. Empty = always hash. |
| `stateKey` | `default` | Name of the "already sent" memory. Use one per alert. |
| `filters` | `[]` | List of `{field, operator, value}`; operators `contains`, `equals`, `gte`, `lte`, `exists`. All must match. Numbers like `"1,200 EUR"` are understood. |
| `maxMessages` | `50` | Max messages per channel per run (1-1000). Items over the cap are kept for the next run. |
| `maxItemsToRead` | `1000` | Max dataset items to read. |
| `sendNoNewItemsNotice` | `false` | Send a short "No new items" message when nothing new was found. |
| `dryRun` | `false` | Build and preview messages only: nothing is sent, nothing is charged, nothing is remembered. |

#### Example input

```json
{
    "datasetId": "{{resource.defaultDatasetId}}",
    "telegramBotToken": "123456789:AA...",
    "telegramChatId": "-1001234567890",
    "messageTemplate": "🆕 <b>{{title}}</b>\n💰 {{price}}\n📍 {{location.city}}\n🔗 {{url}}",
    "filters": [
        { "field": "price", "operator": "lte", "value": "1200" },
        { "field": "title", "operator": "contains", "value": "python" }
    ],
    "dedupeKey": "url",
    "stateKey": "jobs-berlin",
    "mode": "perItem"
}
```

### Output

Every run writes a **delivery log** to its default dataset - one row per item and channel - and a run summary to the `OUTPUT` record of its default key-value store.

```json
[
    {
        "channel": "telegram",
        "itemKey": "https://example.com/jobs/123",
        "status": "sent",
        "httpStatus": 200,
        "error": null,
        "preview": "🆕 Senior Python Developer\n💰 1150\n📍 Berlin\n🔗 https://example.com/jobs/123",
        "sentAt": "2026-11-09T14:00:03.512345+00:00"
    },
    {
        "channel": null,
        "itemKey": "https://example.com/jobs/99",
        "status": "skipped_duplicate",
        "httpStatus": null,
        "error": null,
        "preview": "",
        "sentAt": null
    }
]
```

`status` is one of `sent`, `failed`, `skipped_duplicate`, `filtered`, `skipped_limit` (cap or budget reached - will be retried next run) and `dry_run`. Errors never contain your token or webhook URL.

### How much does it cost?

This Actor uses **pay-per-event** pricing:

| Event | Price | When |
|---|---|---|
| Message delivered (`message-sent`) | **$0.001** (=$1 per 1,000 messages) | Each message successfully posted to Telegram or Discord. Sending one item to both channels = 2 messages. A message longer than the channel limit is split, and each part counts. |
| Actor start (`apify-actor-start`) | $0.00005 per run (Apify default) | Charged automatically by the platform when a run starts. |

**Not charged:** duplicates, filtered items, failed deliveries, dry runs, and runs with invalid input (apart from the tiny start event).

Example: an hourly job scraper that finds ~30 new jobs per day, sent to Telegram only → about 900 messages per month → **about $0.90 + $0.04 in start events**.

You stay in control: set **Maximum cost per run** in the run options. When the limit is reached, the Actor stops sending, keeps the remaining items for the next run, and reports `chargeLimitReached: true` in the summary.

### Limits

- **Message size:** Telegram allows 4,096 characters per message, Discord 2,000. Longer messages are split on line boundaries without breaking formatting.
- **Rate limits:** the Actor sends about 1 message per second to a Telegram chat and stays under Discord's webhook limit (about 5 requests per 2 seconds). If a service answers "too many requests" (HTTP 429), the Actor waits the time it asks for and retries (up to 3 times).
- **Wrong credentials:** if Telegram or Discord rejects the token/webhook (HTTP 401, 403, 404 or "chat not found"), that channel is stopped for the rest of the run, nothing is charged for it, and the run is marked as failed with a clear message.
- **Memory of sent items:** up to the most recent 50,000 items per state key.
- Runs that share the same **State key** should not run at the same time.

### FAQ

#### I didn't receive anything - why?

Check the run's dataset: rows with `skipped_duplicate` were sent before, `filtered` did not match your filters, `failed` shows the error. For Telegram, make sure you pressed **Start** in the bot chat, or that the bot is an admin of the channel.

#### How do I send everything again?

Run once with **Send only new items** turned off, or use a new **State key**, or delete the state record (see Privacy below).

#### Will an item be sent again if sending failed?

Yes. An item is only remembered as sent after at least one channel confirmed delivery. Failed and capped items are retried in the next run.

#### Can I use it with any Actor?

Yes - it works with any dataset. Use field names from your scraper's output in the template, filters and unique item field.

#### Can I run several alerts?

Yes. Create one task or integration per alert and give each its own **State key**.

#### Does it use AI or scrape websites?

No. It only reads your dataset and calls the Telegram Bot API and/or your Discord webhook.

#### Why "limited permissions"?

The Actor only needs to read the dataset you select and keep a small memory of sent items. It cannot access anything else in your Apify account.

### Privacy & data handling

- The Actor processes **only the dataset you point it to** (or the dataset of the run that triggered the integration).
- Items are sent **only to the Telegram chat and/or Discord webhook you configure**. Nothing is sent anywhere else.
- Your bot token and webhook URL are **secret inputs**: stored encrypted by Apify, **never logged, never written to the dataset, key-value store or summary**. Error messages are scrubbed of them.
- The "already sent" memory contains only **SHA-256 fingerprints of item keys** (no item content). It is stored in **your own Apify account**, in the named key-value store `new-items-notifier-state`, record `state-<your state key>`. You can delete the record or the whole store at any time in **Storage → Key-value stores**.
- The run's dataset contains a delivery log with message previews (first 200 characters); it follows your account's normal data retention and you can delete it any time.
- No data is sold or shared with anyone. **No AI** is used.

### Responsibility

You are responsible for the data you send and for where you send it. Only use datasets you have the right to use and redistribute, and comply with the terms of service of Telegram and Discord. Do not use this Actor for spam or to send unsolicited messages to people who have not opted in - send alerts only to your own chats, or to groups and channels whose members agreed to receive them.

### Trademarks

Telegram and Discord are trademarks of their respective owners; this Actor is not affiliated with or endorsed by them.

# Actor input Schema

## `datasetId` (type: `string`):

The dataset whose items you want to be notified about. Leave empty when this Actor runs as an integration of another Actor - the dataset of the run that triggered it is used automatically. Tip: in the integration setup you can set this field to {{resource.defaultDatasetId}}.

## `telegramBotToken` (type: `string`):

Token of your Telegram bot from @BotFather (looks like 123456789:AA...). Stored encrypted; never logged or saved in outputs. Leave empty to skip Telegram.

## `telegramChatId` (type: `string`):

Where the bot posts: a numeric chat ID (e.g. 123456789 for a private chat, -1001234567890 for a group/channel) or a public channel username like @mychannel. The bot must be a member (an admin, for channels).

## `discordWebhookUrl` (type: `string`):

Webhook URL from Discord: Server Settings → Integrations → Webhooks → New Webhook → Copy Webhook URL. Must start with https://discord.com/api/webhooks/. Stored encrypted; never logged. Leave empty to skip Discord.

## `messageTemplate` (type: `string`):

Text of each message. Use {{field}} placeholders, including nested fields like {{location.city}} or {{images.0}}. Missing fields render as empty text. Values are escaped automatically. Telegram HTML tags such as <b>, <i>, <a href="..."> may be used in the template (converted to Markdown for Discord). Clear it to send only the fields listed below.

## `fields` (type: `array`):

Optional. Fields to add below the template as "field: value" lines (nested paths allowed, e.g. location.city). If both the template and this list are empty, the first 10 simple fields of each item are listed.

## `mode` (type: `string`):

"One message per item" posts each new item separately. "Digest" combines all new items into one message (split automatically if it is too long).

## `digestTitle` (type: `string`):

Optional heading of the digest message. {{count}} is replaced by the number of new items. Used only in Digest mode.

## `onlyNew` (type: `boolean`):

Skip items that were already delivered in previous runs (with the same state key). Turn off to send every item that passes the filters.

## `dedupeKey` (type: `string`):

Field that identifies an item, used to recognise items that were already sent (nested paths allowed, e.g. product.id). If an item does not have it, a SHA-256 hash of the whole item is used instead. Leave empty to always use the hash.

## `stateKey` (type: `string`):

Name of the memory of already-sent items. Use a different key for each separate alert (e.g. "jobs-berlin", "flats-vienna"). Letters, digits, - \_ . only.

## `filters` (type: `array`):

Optional. Only items matching ALL filters are sent. Operators: contains (case-insensitive text), equals, gte / lte (numbers, e.g. price lte 1200), exists (field is present and not empty).

## `maxMessages` (type: `integer`):

Safety cap on how many messages are posted to each channel in one run. Items over the cap are not marked as sent, so they are delivered in the next run.

## `maxItemsToRead` (type: `integer`):

How many items to read from the dataset (from the start).

## `sendNoNewItemsNotice` (type: `boolean`):

Send a short "No new items" message when nothing new was found (counts as a delivered message).

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

Build the messages and show previews in the log and output, but send nothing, charge nothing and do not remember items as sent.

## `payload` (type: `object`):

Filled in automatically when this Actor is triggered as an integration (contains the triggering run). You do not need to edit it.

## Actor input object example

```json
{
  "messageTemplate": "🆕 <b>{{title}}</b>\n💰 {{price}}\n🔗 {{url}}",
  "mode": "perItem",
  "digestTitle": "🆕 {{count}} new item(s)",
  "onlyNew": true,
  "dedupeKey": "url",
  "stateKey": "default",
  "maxMessages": 50,
  "maxItemsToRead": 1000,
  "sendNoNewItemsNotice": false,
  "dryRun": false
}
```

# Actor output Schema

## `deliveryLog` (type: `string`):

One row per item and channel with status, HTTP status, error (never contains secrets) and a short message preview.

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

Counts of items read, sent, skipped and failed, charged events and the dedup state location.

# 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 = {
    "messageTemplate": `🆕 <b>{{title}}</b>
💰 {{price}}
🔗 {{url}}`
};

// Run the Actor and wait for it to finish
const run = await client.actor("ab_workflow/apify-actors").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 = { "messageTemplate": """🆕 <b>{{title}}</b>
💰 {{price}}
🔗 {{url}}""" }

# Run the Actor and wait for it to finish
run = client.actor("ab_workflow/apify-actors").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 '{
  "messageTemplate": "🆕 <b>{{title}}</b>\\n💰 {{price}}\\n🔗 {{url}}"
}' |
apify call ab_workflow/apify-actors --silent --output-dataset

```

## MCP server setup

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

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/JUMzzPUjj3QJGAzRc/builds/OKhXTKnXD8dLgDhGg/openapi.json
