Setu Recipes: reusable digital workers across every app.Browse templates

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

TypeScript
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).
InputTypeDescription
chat_idstringRequiredChat id (integer as text, e.g. 123456789 or -1001234567890) or @channelusername
message_idintegerRequiredId of the message to delete
TypeScript
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.
InputTypeDescription
chat_idstringRequiredChat id (integer as text, e.g. 123456789 or -1001234567890) or @channelusername
message_idintegerRequiredId of the message to edit
textstringRequiredNew text, 1-4096 characters
parse_modestringOptionalText formatting mode
TypeScript
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.
InputTypeDescription
chat_idstringRequiredChat id (integer as text, e.g. 123456789 or -1001234567890) or @channelusername
from_chat_idstringRequiredChat id or @username of the chat holding the original message
message_idintegerRequiredId of the message in from_chat_id
disable_notificationbooleanOptionalSend silently
TypeScript
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.
InputTypeDescription
chat_idstringRequiredChat id (integer as text, e.g. 123456789 or -1001234567890) or @channelusername
TypeScript
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.
InputTypeDescription
chat_idstringRequiredChat id (integer as text, e.g. 123456789 or -1001234567890) or @channelusername
user_idintegerRequiredTelegram user id
TypeScript
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.

TypeScript
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.
InputTypeDescription
offsetintegerOptionalId of the first update to return; set to last update_id + 1 to confirm earlier ones
limitintegerOptionalNumber of updates, 1-100
timeoutintegerOptionalLong-polling seconds, 0 returns at once
TypeScript
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.
InputTypeDescription
chat_idstringRequiredChat id (integer as text, e.g. 123456789 or -1001234567890) or @channelusername
textstringRequiredMessage text, 1-4096 characters
parse_modestringOptionalText formatting mode
disable_notificationbooleanOptionalSend silently
message_thread_idintegerOptionalForum topic id
TypeScript
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.
InputTypeDescription
chat_idstringRequiredChat id (integer as text, e.g. 123456789 or -1001234567890) or @channelusername
photostringRequiredPublic image URL (max 10 MB) or a Telegram file_id
captionstringOptionalCaption, up to 1024 characters
parse_modestringOptionalCaption formatting mode
TypeScript
await setu.execute({
  userId: "user_1",
  action: "telegram.send_photo",
  input: {
    "chat_id": "<chat_id>",
    "photo": "<photo>"
  },
});