> ## Documentation Index
> Fetch the complete documentation index at: https://docs.postqueen.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Telegram setup

> Register the Telegram application and give PostQueen its keys

On your own instance you create the bot yourself and put its token in your environment.

<Steps>
  <Step title="Create a Telegram Bot">
    1. Open Telegram and message [@BotFather](https://t.me/botfather).
    2. Click Start
    3. Click Menu
       * Click "Create a new bot"
       * Enter a name for your bot (e.g., `MyPostQueenBot`).

    <Frame>
      <img src="https://mintcdn.com/forceplay/zoNabLaA7ky5oWlO/images/providers/telegram/telegram-name-bot.png?fit=max&auto=format&n=zoNabLaA7ky5oWlO&q=85&s=5256ceda32a10a637e273c271927d7c6" alt="Name Bot" width="719" height="1242" data-path="images/providers/telegram/telegram-name-bot.png" />
    </Frame>

    * Choose a unique username ending with "bot" (e.g., `MyPostQueenBot_bot`).

    <Frame>
      <img src="https://mintcdn.com/forceplay/zoNabLaA7ky5oWlO/images/providers/telegram/telegram-unique-username.png?fit=max&auto=format&n=zoNabLaA7ky5oWlO&q=85&s=4bd47c2983eee319ac4f09d6ee68d02e" alt="Unique Bot Name" width="719" height="1245" data-path="images/providers/telegram/telegram-unique-username.png" />
    </Frame>

    Once your bot is created, **BotFather** will give you an **API Token**. Keep it safe. You will need it later.

    <Frame>
      <img src="https://mintcdn.com/forceplay/zoNabLaA7ky5oWlO/images/providers/telegram/telegram-bot-token.png?fit=max&auto=format&n=zoNabLaA7ky5oWlO&q=85&s=d639a3f5a344791eb05729bbbfb9b126" alt="Bot Token" width="719" height="1239" data-path="images/providers/telegram/telegram-bot-token.png" />
    </Frame>
  </Step>

  <Step title="Configure Bot Group Permissions (optional but recommended)">
    1. Click on "Menu"
    2. Click on "Edit your bots"
    3. Select your bot
    4. Click on "Bot Settings"

    <Frame>
      <img src="https://mintcdn.com/forceplay/zoNabLaA7ky5oWlO/images/providers/telegram/telegram-bot-settings.png?fit=max&auto=format&n=zoNabLaA7ky5oWlO&q=85&s=2738ed0a691875be0f11550694b644c4" alt="Bot Settings" width="719" height="1242" data-path="images/providers/telegram/telegram-bot-settings.png" />
    </Frame>

    5. Click on "Group Privacy"

    <Frame>
      <img src="https://mintcdn.com/forceplay/zoNabLaA7ky5oWlO/images/providers/telegram/telegram-group-privacy.png?fit=max&auto=format&n=zoNabLaA7ky5oWlO&q=85&s=13cc0414457a2980de883a88e5a3f6e2" alt="Group Privacy" width="719" height="1242" data-path="images/providers/telegram/telegram-group-privacy.png" />
    </Frame>

    6. If "Privacy mode" is enabled, turn it off (it is enabled by default)
  </Step>

  <Step title="Add Your Bot to Telegram Groups or Channels">
    1. Navigate to your group/channel
    2. Add your bot to your group/channel
    3. The bot requires these permissions to work with PostQueen:
       * access to messages, so the bot can read messages sent in the group/channel
       * Send Text Messages, so the bot can send messages
       * Send Media, so the bot can send media

    <Info>
      While not strictly required, making your bot an `admin` is **recommended**. It will give the bot all the permissions needed and make the setup easier and faster.
    </Info>
  </Step>

  <Step title="Add Bot Token to Your Application">
    In your `.env` file, add the **Telegram Bot Name** (Without the @) and the **Telegram Bot API Token** that you received from **BotFather** in Step 1:

    ```env theme={"system"}
    TELEGRAM_BOT_NAME="MyPostQueenBot_bot"
    TELEGRAM_TOKEN="MyPostQueenBot token"
    ```

    You should be able to connect your group/channel to PostQueen now!
  </Step>

  <Step title="Restart and add the Telegram channel">
    <Snippet file="restart-and-add-channel.mdx" />
  </Step>
</Steps>

<Warning>
  PostQueen talks to Telegram using long-polling (`getUpdates`). Telegram allows only **one** connected process per bot token at a time. If you run PostQueen against the same `TELEGRAM_TOKEN` from two places (e.g. self-hosted plus cloud, or two self-hosted instances), each instance will continuously kick the other off and you will see `409 Conflict: terminated by other getUpdates` errors in the logs.

  Use one bot token per PostQueen deployment. If you need Telegram on multiple environments, create a separate bot for each.
</Warning>

## Next steps

<CardGroup cols={2}>
  <Card title="What she can post to Telegram" icon="https://mintcdn.com/forceplay/3MbWAJB4xKJ_Rxe0/images/channels/telegram.svg?fit=max&auto=format&n=3MbWAJB4xKJ_Rxe0&q=85&s=96bf57f29a3b7ed852d8eefe14ec4eac" href="/providers/telegram" width="64" height="64" data-path="images/channels/telegram.svg">
    Limits, post types and settings
  </Card>

  <Card title="Configuration reference" icon="list" href="/configuration/reference">
    Every variable she reads
  </Card>

  <Card title="Connect errors" icon="plug-circle-xmark" href="/troubleshooting/oauth-connect">
    Invalid state, invalid\_grant and the rest
  </Card>

  <Card title="Another channel" icon="plug" href="/providers/overview">
    Every network, and what each one asks for
  </Card>
</CardGroup>
