# Telegram Message Sender Pro (`xtech/telegram-message-sender-pro`) Actor

Send automated messages to Telegram chats and channels. Perfect for notifications, alerts, marketing messages, and automated communication workflows. Supports text messages, rich formatting, and advanced delivery options.

- **URL**: https://apify.com/xtech/telegram-message-sender-pro.md
- **Developed by:** [Xtech](https://apify.com/xtech) (community)
- **Categories:** Automation, Social media, Developer tools
- **Features:** Limited permissions
- **Stats:** 8 total users, 0 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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

## 🚀 Telegram Message Sender PRO

Send automated messages to Telegram chats and channels. Perfect for notifications, alerts, marketing messages, and automated communication workflows. Supports text messages, custom formatting, and advanced delivery options.

### 📥 Input Parameters

| Parameter              | Type   | Required | Description                                      |
| ---------------------- | ------ | -------- | ------------------------------------------------ |
| `botToken`             | String | ✅       | Your Telegram bot token (get it from @BotFather) |
| `messages`             | Array  | ✅       | List of messages to send to Telegram             |
| `delayBetweenMessages` | Number | ❌       | Delay in seconds between messages (default: 1)   |

#### Message Object Properties

| Property                | Type    | Required | Description                                                        |
| ----------------------- | ------- | -------- | ------------------------------------------------------------------ |
| `chatId`                | String  | ✅       | Chat ID or username (@channel_name) where to send the message      |
| `text`                  | String  | ✅       | Message text content (max 4096 characters)                         |
| `parseMode`             | String  | ❌       | Message formatting: "Markdown", "MarkdownV2", "HTML", or "" (none) |
| `disableWebPagePreview` | Boolean | ❌       | Disable link previews (default: false)                             |
| `disableNotification`   | Boolean | ❌       | Send message silently (default: false)                             |

#### Example Input

```json
{
    "botToken": "1234567890:ABCDefGhIJKlMnOpQrStUvWxYz",
    "messages": [
        {
            "chatId": "@my_channel",
            "text": "🚀 **Hello World!**\n\nThis is a test message from Apify.",
            "parseMode": "Markdown",
            "disableWebPagePreview": false,
            "disableNotification": false
        },
        {
            "chatId": "-1001234567890",
            "text": "Alert: System status update",
            "disableNotification": true
        }
    ],
    "delayBetweenMessages": 2
}
```

### 📤 Output Data

Each sent message produces a detailed result with delivery information and status:

#### Successful Message Result

```json
{
    "success": true,
    "messageId": 123,
    "chatId": "@my_channel",
    "text": "🚀 **Hello World!**\n\nThis is a test message from Apify.",
    "parseMode": "Markdown",
    "sentAt": "2024-01-01T12:00:00.000Z",
    "botUsername": "my_bot",
    "disableWebPagePreview": false,
    "disableNotification": false,
    "retryAttempt": 0
}
```

#### Failed Message Result

```json
{
    "success": false,
    "chatId": "@invalid_channel",
    "text": "This message failed to send",
    "sentAt": "2024-01-01T12:00:00.000Z",
    "error": "Bad Request: chat not found",
    "errorCode": "400",
    "disableWebPagePreview": false,
    "disableNotification": false,
    "retryAttempt": 0
}
```

### 🤖 Getting Started

#### 1. Create a Telegram Bot

1. Open Telegram and search for **@BotFather**
2. Send `/newbot` command
3. Choose a name and username for your bot
4. Copy the bot token (format: `123456789:ABCDefGhIJKlMnOpQrStUvWxYz`)

#### 2. Get Chat IDs

**For Channels:**

- Create a public channel: use `@channel_username`
- For private channels: use the numeric chat ID (starts with `-100`)

**For Groups:**

- Add your bot to the group
- Use the numeric group ID (negative number)

**For Private Chats:**

- Use the user's numeric ID (positive number)

#### 3. Configure and Run

1. **Set Bot Token**: Enter your bot token from @BotFather
2. **Add Messages**: Configure your messages with target chats and content
3. **Run Actor**: Execute and monitor message delivery in real-time
4. **View Results**: Check delivery status and message IDs in the dataset

### 📊 Key Features

- ✅ **Multiple Message Types**: Send to channels, groups, and private chats
- ✅ **Rich Formatting**: Support for Markdown, HTML, and plain text
- ✅ **Delivery Control**: Silent messages, link preview control, and rate limiting
- ✅ **Robust Error Handling**: Comprehensive error logging and detailed failure reasons
- ✅ **Batch Processing**: Send multiple messages with configurable delays
- ✅ **Real-time Monitoring**: Live delivery status and message tracking
- ✅ **Structured Output**: Detailed results with timestamps and metadata
- ✅ **Token Validation**: Automatic bot token verification and authentication

### 🔧 Advanced Usage

#### Message Formatting Examples

**Markdown:**

```json
{
    "text": "*Bold text*\n_Italic text_\n`Code text`\n[Link](https://example.com)",
    "parseMode": "Markdown"
}
```

**HTML:**

```json
{
    "text": "<b>Bold text</b>\n<i>Italic text</i>\n<code>Code text</code>\n<a href=\"https://example.com\">Link</a>",
    "parseMode": "HTML"
}
```

#### Rate Limiting

To avoid Telegram rate limits:

- Set `delayBetweenMessages` to 1-3 seconds for bulk sends
- Monitor error responses for rate limit warnings
- Consider splitting large batches across multiple runs

#### Error Handling

Common error scenarios:

- **Bot not added to channel**: Add bot as admin to target channels
- **Invalid chat ID**: Verify chat IDs and permissions
- **Message too long**: Keep messages under 4096 characters
- **Rate limiting**: Increase delay between messages

### 🚨 Important Notes

- **Bot Permissions**: Ensure your bot has permission to send messages to target chats
- **Character Limits**: Telegram messages are limited to 4096 characters
- **Rate Limits**: Respect Telegram's rate limits (30 messages/second to different chats)
- **Security**: Keep your bot token secure and never share it publicly

### 📞 Support

For issues with:

- **Bot Creation**: Contact @BotFather on Telegram
- **Rate Limits**: Check [Telegram Bot documentation](https://core.telegram.org/bots/api)
- **Actor Issues**: Review the error messages in the dataset output

***

**Built with ❤️ by XTech**

# Actor input Schema

## `botToken` (type: `string`):

Your Telegram bot token (get it from @BotFather)

## `messages` (type: `array`):

List of messages to send to Telegram

## `delayBetweenMessages` (type: `integer`):

Delay in seconds between sending messages to avoid rate limiting

## Actor input object example

```json
{
  "delayBetweenMessages": 1
}
```

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("xtech/telegram-message-sender-pro").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("xtech/telegram-message-sender-pro").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 '{}' |
apify call xtech/telegram-message-sender-pro --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,xtech/telegram-message-sender-pro"
        }
    }
}
```

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/HJUcYLaYqgFHB0Hbg/builds/SAfLYEdhKGI6jm4cg/openapi.json
