Integrations / Telegram Bot
Telegram Bot
Telegram Bot API: send, forward, edit and delete messages and photos as your bot, read incoming updates, and look up chats and members. Bot token from @BotFather.
9 actions
API key
4 read4 write1 destructive
Calls api.telegram.org
Connect
const conn = await setu.connections.initiate({ userId: "user_1", toolkit: "telegram" });
console.log(conn.connectUrl); // show this to your user
await conn.waitUntilActive();Permissions requested
This toolkit uses a single credential and requests no scopes.
Actions
Delete messagedestructivetelegram.delete_messageDelete a message (only possible within 48 hours of sending, and subject to the bot's permissions in the chat).
| Input | Type | Description | |
|---|---|---|---|
chat_id | string | Required | Chat id (integer as text, e.g. 123456789 or -1001234567890) or @channelusername |
message_id | integer | Required | Id of the message to delete |
await setu.execute({
userId: "user_1",
action: "telegram.delete_message",
input: {
"chat_id": "<chat_id>",
"message_id": 1
},
confirm: true,
});Edit message textwritetelegram.edit_message_textEdit the text of a message the bot sent earlier.
| Input | Type | Description | |
|---|---|---|---|
chat_id | string | Required | Chat id (integer as text, e.g. 123456789 or -1001234567890) or @channelusername |
message_id | integer | Required | Id of the message to edit |
text | string | Required | New text, 1-4096 characters |
parse_mode | string | Optional | Text formatting mode |
await setu.execute({
userId: "user_1",
action: "telegram.edit_message_text",
input: {
"chat_id": "<chat_id>",
"message_id": 1,
"text": "<text>"
},
});Forward messagewritetelegram.forward_messageForward an existing message from one chat to another.
| Input | Type | Description | |
|---|---|---|---|
chat_id | string | Required | Chat id (integer as text, e.g. 123456789 or -1001234567890) or @channelusername |
from_chat_id | string | Required | Chat id or @username of the chat holding the original message |
message_id | integer | Required | Id of the message in from_chat_id |
disable_notification | boolean | Optional | Send silently |
await setu.execute({
userId: "user_1",
action: "telegram.forward_message",
input: {
"chat_id": "<chat_id>",
"from_chat_id": "<from_chat_id>",
"message_id": 1
},
});Get chatreadtelegram.get_chatGet up-to-date information about a chat: type, title or username, description and permissions.
| Input | Type | Description | |
|---|---|---|---|
chat_id | string | Required | Chat id (integer as text, e.g. 123456789 or -1001234567890) or @channelusername |
await setu.execute({
userId: "user_1",
action: "telegram.get_chat",
input: {
"chat_id": "<chat_id>"
},
});Get chat memberreadtelegram.get_chat_memberGet a member's role and status in a chat. Only guaranteed to work for other users if the bot is an admin there.
| Input | Type | Description | |
|---|---|---|---|
chat_id | string | Required | Chat id (integer as text, e.g. 123456789 or -1001234567890) or @channelusername |
user_id | integer | Required | Telegram user id |
await setu.execute({
userId: "user_1",
action: "telegram.get_chat_member",
input: {
"chat_id": "<chat_id>",
"user_id": 1
},
});Get bot inforeadtelegram.get_meCheck the bot token and return the bot's id, name and username.
No input.
await setu.execute({
userId: "user_1",
action: "telegram.get_me",
input: {},
});Get updatesreadtelegram.get_updatesRead new incoming messages and events sent to the bot (long polling). Passing offset confirms and discards all older updates; do not use if a webhook is set.
| Input | Type | Description | |
|---|---|---|---|
offset | integer | Optional | Id of the first update to return; set to last update_id + 1 to confirm earlier ones |
limit | integer | Optional | Number of updates, 1-100 |
timeout | integer | Optional | Long-polling seconds, 0 returns at once |
await setu.execute({
userId: "user_1",
action: "telegram.get_updates",
input: {},
});Send messagewritetelegram.send_messageSend a text message to a chat, group or channel as the bot.
| Input | Type | Description | |
|---|---|---|---|
chat_id | string | Required | Chat id (integer as text, e.g. 123456789 or -1001234567890) or @channelusername |
text | string | Required | Message text, 1-4096 characters |
parse_mode | string | Optional | Text formatting mode |
disable_notification | boolean | Optional | Send silently |
message_thread_id | integer | Optional | Forum topic id |
await setu.execute({
userId: "user_1",
action: "telegram.send_message",
input: {
"chat_id": "<chat_id>",
"text": "<text>"
},
});Send photo by URLwritetelegram.send_photoSend a photo to a chat from a public HTTPS image URL (or an existing Telegram file_id), with an optional caption.
| Input | Type | Description | |
|---|---|---|---|
chat_id | string | Required | Chat id (integer as text, e.g. 123456789 or -1001234567890) or @channelusername |
photo | string | Required | Public image URL (max 10 MB) or a Telegram file_id |
caption | string | Optional | Caption, up to 1024 characters |
parse_mode | string | Optional | Caption formatting mode |
await setu.execute({
userId: "user_1",
action: "telegram.send_photo",
input: {
"chat_id": "<chat_id>",
"photo": "<photo>"
},
});