> For the complete documentation index, see [llms.txt](https://fozan.gitbook.io/multibot-telegram/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fozan.gitbook.io/multibot-telegram/methods/getbotbyid.md).

# getBotById

### Method `getBotById`

**Usage:**

```javascript
const bot = multiBotInstance.getBotById(id);
```

**Parameters:**

* `id` (`number`): The unique ID of the bot you want to retrieve.

**Returns:**

* `{TelegramBot|undefined}`: Returns the Telegram bot instance if found, or `undefined` if no bot with the specified ID exists.

**Example:**

```javascript
const bot = multiBotInstance.getBotById(1234567890);
if (bot) {
    bot.sendMessage(chatId, 'Hello!');
} else {
    console.log('Bot not found.');
}
```

**Notes:**

* This method is only available for configurations where `type` is "multi". If the type is "one", this method will not function as intended.
* Ensure that the bot ID is valid and that the bot has been initialized.
* The method relies on the global manager's state, so make sure bots are properly loaded and managed.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://fozan.gitbook.io/multibot-telegram/methods/getbotbyid.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
