# Telegram MCP Agent (`inovaflow/mcpify-telegram`) Actor

Connect a Telegram bot and an MCP server. People chat with the bot in plain language; an AI agent (Claude) understands them, calls the Apify MCP server's tools, and replies. Bring your own bot + your own MCP Connector. No Claude or ChatGPT account needed for your users.

- **URL**: https://apify.com/inovaflow/mcpify-telegram.md
- **Developed by:** [inovaflow](https://apify.com/inovaflow) (community)
- **Categories:** AI, MCP servers, Integrations
- **Stats:** 1 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.05 / actor start

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

**Put your Apify tools — and any MCP server — inside any Telegram chat.** Message the bot in plain language and it runs *your* tools and answers right there in the chat.

If you've built or rented an Apify Actor — or any other MCP server — the people who'd actually use it don't live in the Apify Console. They live in Telegram. So we wired a small AI bot into the chat: it understands plain language, calls the tools you connect, and replies in the thread. Your users need **no Claude or ChatGPT account** — they just talk to the bot.

Point it at one MCP server, several, or none — with no tools connected it works as a plain AI chat assistant. When tools are connected, the bot (Claude) figures out which to call, runs it, and writes back the answer.

> 🧪 **Early access.** Pricing is kept lean while we learn how people use it. Your feedback shapes the roadmap — tell us what's missing. 🙏

### Who it's for

- **Teams with Apify tools** — let everyone trigger your scraper or automation from a group chat. *"@bot find new Prague listings under €1,500"*
- **MCP builders** — ship your MCP server to non-technical users without coding or hosting a bot — just create a free Telegram bot token and connect it.
- **Anyone who lives in Telegram** — a personal assistant wired to exactly the tools you choose. *"what about the second one"*
- **Privacy-minded teams** — it runs on **your** Apify account with **your** credentials; your keys and tools never leave it.

### How to set it up

> 🎬 **Prefer to watch?** [2-minute setup video walkthrough](https://www.veed.io/view/4f1adff4-db5f-416e-93cf-76a846bf5607?source=editor&panel=share)

You'll need a free Apify account and a Telegram bot. Five steps.

1. **Create a Telegram bot.** Open [@BotFather](https://t.me/BotFather), send `/newbot`, pick a name and a username ending in `bot`, and copy the token. For **group** use, also set *Bot Settings → Group Privacy → OFF*, then remove and re-add the bot.
2. **(Optional) Connect MCP server(s).** Authorize them in Apify Console → *Settings → API & Integrations → MCP Connectors*, then pick them in this Actor's *MCP server(s)* field. Skip this entirely to use the bot as a plain AI chat assistant.
3. **Add an Apify token.** Paste an Apify API token in the *Apify API token* field — best practice is one scoped to running just this Actor. Without it the bot starts but never receives a single message.
4. **(Optional) Tune the AI.** Pick Haiku (default) or Sonnet, bring your own Anthropic key (BYOK) to skip the AI charge, add a persona, or restrict it to specific chats.
5. **Save as a Task, turn on Standby, and Start it — once.** The bot registers its own webhook and stays reachable, scaling to zero when idle. Then `@mention` it in a group, or just DM it.

### What you get

- **Plain-language answers in the chat** — the bot picks and runs the right tools and replies in Telegram, splitting long answers across messages automatically.
- **Group-aware** — in a group it replies only when `@mentioned` or replied to (so it never spams), and everyone shares one assistant and one memory.
- **Conversation memory** — it remembers the last several messages per chat, so follow-ups like *"what about the second one"* just work.
- **Zero accounts for your users** — they need nothing but Telegram.

### Costs

You pay only for what you use, all on your own Apify account — fully transparent. Three pieces:

| Charge | When | Price |
| --- | --- | --- |
| **Standby compute** | Keeps the bot reachable; scales to zero when idle | Apify's usual compute rate |
| **Actor start** | Each time the bot wakes from idle — about once per run, **not** per message | **$0.05** |
| **AI tokens** (built-in key) | Per reply, by model — Haiku **$1 / $5** per 1M tokens (in / out), Sonnet **$3 / $15** | metered per use |

Greetings and un-addressed group chatter make no AI call and cost nothing. **Bring your own Anthropic key (BYOK)** and the AI tokens drop to **zero** — you pay Anthropic directly; only the start fee and compute remain. The built-in key is available on **paid Apify plans**; on a free plan, add your own key.

> **Tip:** set a *Max cost per run* on the Task to cap spend. Lower *Conversation memory* and *Max tool rounds* for cheaper, snappier replies.

### Notes

- It reads only the messages sent to it and calls only the tools you connect — it logs into nothing on its own and never reveals your keys. Respect the terms of the services your tools reach.
- Runs in **Standby mode** on your Apify account, and must be saved as a **Task** (a bare Actor run gets no input and won't receive messages). After changing any Task setting, **Stop and Start** the Actor so the bot reloads it — a running bot keeps the settings it read at boot.
- Found a bug, want a tweak? Open an issue on the **Issues** tab — custom tweaks on request. 🙏

# Actor input Schema

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

Required. Your bot's token from @BotFather (send /newbot). The bot signs into Telegram with it. For group chats, also set Group Privacy OFF in @BotFather.
## `apifyToken` (type: `string`):

Required. The bot embeds this in its Telegram webhook so Apify lets incoming messages through; without it the bot never receives messages. Best practice: scope it to running just this Actor.
## `mcpConnectors` (type: `array`):

The MCP server(s) whose tools the bot can use. With none connected, the bot replies as a plain AI chat assistant. Authorize them first in Console → Settings → MCP Connectors, then pick them here.
## `anthropicApiKey` (type: `string`):

Optional. Runs the AI on your own Anthropic account, so there's no Apify AI charge. Leave empty to use the built-in key, which needs a paid Apify plan.
## `model` (type: `string`):

Which Claude model replies. Haiku is fast and cheap (default); Sonnet is smarter but pricier.
## `systemPrompt` (type: `string`):

Optional. Extra instructions that shape the bot's persona and behavior.
## `allowedChatIds` (type: `array`):

Optional. Telegram chat IDs the bot may answer in. Leave empty to answer in every chat it's added to.
## `maxToolIterations` (type: `integer`):

How many tool rounds the agent may take per message. Default 12; raise it if multi-step tasks get cut off.
## `maxOutputTokens` (type: `integer`):

Longest a single reply can be, in tokens. Default 2048; longer replies are split across messages.
## `historyWindow` (type: `integer`):

How many recent messages per chat the bot keeps as context. Default 24.

## Actor input object example

```json
{
  "model": "haiku",
  "maxToolIterations": 12,
  "maxOutputTokens": 2048,
  "historyWindow": 24
}
````

# Actor output Schema

# 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 = {
    "model": "haiku"
};

// Run the Actor and wait for it to finish
const run = await client.actor("inovaflow/mcpify-telegram").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 = { "model": "haiku" }

# Run the Actor and wait for it to finish
run = client.actor("inovaflow/mcpify-telegram").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "model": "haiku"
}' |
apify call inovaflow/mcpify-telegram --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=inovaflow/mcpify-telegram",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Telegram MCP Agent",
        "description": "Connect a Telegram bot and an MCP server. People chat with the bot in plain language; an AI agent (Claude) understands them, calls the Apify MCP server's tools, and replies. Bring your own bot + your own MCP Connector. No Claude or ChatGPT account needed for your users.",
        "version": "0.1",
        "x-build-id": "pRbAmYbSb6jN24TQe"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/inovaflow~mcpify-telegram/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-inovaflow-mcpify-telegram",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/inovaflow~mcpify-telegram/runs": {
            "post": {
                "operationId": "runs-sync-inovaflow-mcpify-telegram",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/inovaflow~mcpify-telegram/run-sync": {
            "post": {
                "operationId": "run-sync-inovaflow-mcpify-telegram",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "telegramBotToken",
                    "apifyToken"
                ],
                "properties": {
                    "telegramBotToken": {
                        "title": "Telegram bot token",
                        "type": "string",
                        "description": "Required. Your bot's token from @BotFather (send /newbot). The bot signs into Telegram with it. For group chats, also set Group Privacy OFF in @BotFather."
                    },
                    "apifyToken": {
                        "title": "Apify API token",
                        "type": "string",
                        "description": "Required. The bot embeds this in its Telegram webhook so Apify lets incoming messages through; without it the bot never receives messages. Best practice: scope it to running just this Actor."
                    },
                    "mcpConnectors": {
                        "title": "MCP server(s) the bot can use",
                        "type": "array",
                        "description": "The MCP server(s) whose tools the bot can use. With none connected, the bot replies as a plain AI chat assistant. Authorize them first in Console → Settings → MCP Connectors, then pick them here."
                    },
                    "anthropicApiKey": {
                        "title": "Your own Anthropic API key (optional)",
                        "type": "string",
                        "description": "Optional. Runs the AI on your own Anthropic account, so there's no Apify AI charge. Leave empty to use the built-in key, which needs a paid Apify plan."
                    },
                    "model": {
                        "title": "AI model",
                        "enum": [
                            "haiku",
                            "sonnet"
                        ],
                        "type": "string",
                        "description": "Which Claude model replies. Haiku is fast and cheap (default); Sonnet is smarter but pricier.",
                        "default": "haiku"
                    },
                    "systemPrompt": {
                        "title": "Persona / extra instructions (optional)",
                        "type": "string",
                        "description": "Optional. Extra instructions that shape the bot's persona and behavior."
                    },
                    "allowedChatIds": {
                        "title": "Restrict to specific chats (optional)",
                        "type": "array",
                        "description": "Optional. Telegram chat IDs the bot may answer in. Leave empty to answer in every chat it's added to.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "maxToolIterations": {
                        "title": "Max tool rounds per reply",
                        "minimum": 1,
                        "maximum": 25,
                        "type": "integer",
                        "description": "How many tool rounds the agent may take per message. Default 12; raise it if multi-step tasks get cut off.",
                        "default": 12
                    },
                    "maxOutputTokens": {
                        "title": "Max reply length (tokens)",
                        "minimum": 256,
                        "maximum": 8192,
                        "type": "integer",
                        "description": "Longest a single reply can be, in tokens. Default 2048; longer replies are split across messages.",
                        "default": 2048
                    },
                    "historyWindow": {
                        "title": "Conversation memory (messages)",
                        "minimum": 4,
                        "maximum": 60,
                        "type": "integer",
                        "description": "How many recent messages per chat the bot keeps as context. Default 24.",
                        "default": 24
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
