# Telegram on boxd

> Telegram is a cloud-based messaging app with a focus on security and speed. Build bots to send messages, manage chats, and interact with users.

- Page: https://boxd.sh/integrations/telegram/
- CLI: `run telegram` (18 commands, 2 marked common)
- SDK: `import { telegram } from "@boxd/run"`; every parameter and response type is at `@boxd/run/telegram`
- Triggers: none
- Connect: `run auth telegram` (API key), or https://app.boxd.sh/integrations/detail/telegram
- All integrations: https://boxd.sh/integrations/ (Markdown: https://boxd.sh/integrations/index.md)

## From the shell

```sh
run auth telegram      # once: prints a link to connect your account
run telegram           # list its commands
run telegram get-me
```

Parameters are flags (`--flag value`); object and array parameters take a JSON string. Output is YAML, or JSON with `--json`. Calls use your own connection; `--scope <name>` uses a connection shared with your team.

## From a script

```ts
import { every, telegram } from "@boxd/run";

every("1 hour", async () => {
  const result = await telegram.getMe();
  console.log(result);
});
```

Run it with `run telegram.run.ts`. Telegram has no triggers; `every()` polls on a schedule, keeps the script running as a job, and wakes the machine when it is due.

## Commands

Required flags are listed; `run telegram <command> --help` lists the optional ones. "common" marks what `run telegram` shows without `--all`.

| Command | SDK method | Required flags | Optional | Description |
|---|---|---|---|---|
| `answer-callback-query` | `telegram.answerCallbackQuery()` | `--callback-query-id` | 4 | Use this method to send answers to callback queries sent from inline keyboards |
| `create-chat-invite-link` | `telegram.createChatInviteLink()` | `--chat-id` | 0 | Generate a new primary invite link for a chat; any previously generated primary link is revoked |
| `delete-message` | `telegram.deleteMessage()` | `--chat-id` `--message-id` | 0 | Delete a message, including service messages |
| `edit-message` | `telegram.editMessage()` | `--text` | 6 | Edit text messages sent by the bot |
| `forward-message` | `telegram.forwardMessage()` | `--chat-id` `--from-chat-id` `--message-id` | 1 | Forward messages of any kind |
| `get-chat` | `telegram.getChat()` | `--chat-id` | 0 | Get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.) |
| `get-chat-administrators` | `telegram.getChatAdministrators()` | `--chat-id` | 0 | Get a list of administrators in a chat |
| `get-chat-history` | `telegram.getChatHistory()` | `--chat-id` | 3 | Get chat history messages via the getUpdates polling method, filtered by chat_id |
| `get-chat-member` ·common | `telegram.getChatMember()` | `--chat-id` `--user-id` | 0 | Get a chat member's status/role (including the bot itself) to preflight permissions and troubleshoot 403/empty-history issues |
| `get-chat-members-count` | `telegram.getChatMembersCount()` | `--chat-id` | 0 | Get the number of members in a chat |
| `get-me` | `telegram.getMe()` | — | 0 | Get basic information about the bot using the Bot API getMe method |
| `get-updates` | `telegram.getUpdates()` | — | 4 | Use this method to receive incoming updates using long polling |
| `send-document` | `telegram.sendDocument()` | `--chat-id` `--document` | 7 | Send general files (documents) to a Telegram chat using the Bot API |
| `send-location` | `telegram.sendLocation()` | `--chat-id` `--latitude` `--longitude` | 7 | Send point on the map location to a Telegram chat using the Bot API |
| `send-message` ·common | `telegram.sendMessage()` | `--chat-id` `--text` | 5 | Send a text message to a Telegram chat using the Bot API |
| `send-photo` | `telegram.sendPhoto()` | `--chat-id` `--photo` | 5 | Send photos to a Telegram chat using the Bot API |
| `send-poll` | `telegram.sendPoll()` | `--chat-id` `--options` `--question` | 12 | Send a native poll to a Telegram chat using the Bot API |
| `set-my-commands` | `telegram.setMyCommands()` | `--commands` | 2 | Use this method to change the list of the bot's commands |

## Docs

- [run CLI](https://docs.boxd.sh/cli/run): Call connected integrations from the shell, connect new ones, and run automations.
- [Quickstart](https://docs.boxd.sh/guides/integrations/quickstart): Connect an integration, call it from the shell, and turn a script into an automation.
- [Connections](https://docs.boxd.sh/guides/integrations/connections): Connect an account once, for yourself or for your whole organization.
- [Scripts](https://docs.boxd.sh/guides/automations/scripts): Typed integrations, triggers, schedules and state in a .run.ts file.
- [Jobs](https://docs.boxd.sh/guides/automations/jobs): How a script becomes a background job: states, retries, sleep and wake.
- [Beyond the catalog](https://docs.boxd.sh/guides/automations/beyond-the-catalog): Reach your own APIs, databases and cloud accounts from a script.
