> For the complete documentation index, see [llms.txt](https://docs.aigent.run/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aigent.run/ai-agent-terminal/social-agents/telegram-api-key-walkthrough.md).

# Telegram API Key Walkthrough

Simple Step-by-Step Guide

## Step 1: Create Your Telegram Bot

* Open Telegram and start a chat with **BotFather**.
* Type the command `/newbot` to create a new bot.
* Follow the prompts to:
  * Set a name for your bot.
  * Set a unique username (must end in `bot`).
* Once done, you’ll receive a **bot token** (e.g., `123456789:ABCdefGhIjKlmNoPQRstuVWXyz`).

More detailed tutorial here - [core.telegram.org/bots/tutorial](https://core.telegram.org/bots/tutorial)

Keep this token secure. You’ll use it later on aigent.run.

<figure><img src="https://3259930965-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGRQgnypqdA4ATf0QCsY1%2Fuploads%2Fjad6iy0k1Tzp6EvTjJd5%2Fimage.png?alt=media&amp;token=58e336f6-dac5-44d4-bc3f-d49fd001513f" alt=""><figcaption></figcaption></figure>

## Step 2: Add Bot Token to aigent.run

* Visit [aigent.run](https://aigent.run) and go to the **Configuration** tab.
* Paste your **bot token** into the **Bot Token** field.
* Click **Save**.
* Use the **Test Credentials** button to check that the bot is connected correctly.

<figure><img src="https://3259930965-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGRQgnypqdA4ATf0QCsY1%2Fuploads%2FQcDntvdiJ6dKUs4DVl17%2Fimage.png?alt=media&amp;token=99d70a17-b39e-4360-9433-396067361305" alt=""><figcaption></figcaption></figure>

## Step 3: Add the Bot to a Telegram Group

* Create a new Telegram group or use one where you're already an admin.
* Add your newly created bot to the group.
* Once added, tap the group name → **Manage Group** → **Administrators**.
* Promote your bot to **Administrator** status.

<figure><img src="https://3259930965-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGRQgnypqdA4ATf0QCsY1%2Fuploads%2F4rcIfzK2tz00uhb2UqSg%2Fimage.png?alt=media&amp;token=9e2932de-ba5b-4311-bbf4-6cd2085ba393" alt=""><figcaption></figcaption></figure>

## Step 4: Get the Group Chat ID

To get the chat ID you have to follow these steps:

* Add @myidbot to the group you want to enable the agent in, and make it an Admin.
* Contact the [@myidbot](https://t.me/myidbot) bot and send the `/getid` command to get your personal chat ID, or invite it into a group and use the `/getgroupid` command to get the group chat ID.
* To get the Thread ID, the easiest way is this: Post a message to that topic, then right-click on it and select `Copy Message Link`. Paste it on a notepad and notice that it has the following structure `https://t.me/c/XXXXXXXXXX/YY/ZZ`. The Thread ID is `YY` (integer).

<figure><img src="https://3259930965-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGRQgnypqdA4ATf0QCsY1%2Fuploads%2FWSZaUrguaJsKqSI2cv33%2Fimage.png?alt=media&amp;token=e81431f2-e391-4913-bf44-bdf3a5a2f1a2" alt=""><figcaption></figcaption></figure>

## Step 5: Add the Chat ID to aigent.run

1. Go back to the **Configuration** tab on aigent.run.
2. Paste the **Chat ID** into the appropriate field.
3. Click **Send Test Message**.

If everything is set up correctly, you’ll receive a message in your Telegram group saying:

"This is a test message from your AIgent."

<figure><img src="https://3259930965-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGRQgnypqdA4ATf0QCsY1%2Fuploads%2FUcgoVyJFeLtqaNYiQQrj%2Fimage.png?alt=media&amp;token=1fc14d0c-d4fe-453b-bbbc-2058d9107b14" alt=""><figcaption></figcaption></figure>

That’s it! Your Telegram bot is now ready to send messages through aigent.run.
