# Connect a Telegram bot

Create a bot in @BotFather, paste the token into Happ, and the agent starts answering customers in Telegram.

> Full REST + WebSocket API reference: https://api.happ.tools/reference

## What you need [#what-you-need]

* A Telegram account.
* A Happ agent that will answer in the bot. No agent yet? [Create one from a template](/guides/create-agent).

<Steps>
  <Step>
    ### Create a bot in @BotFather [#create-a-bot-in-botfather]

    Open [@BotFather](https://t.me/BotFather), send `/newbot`, set the bot name and username. BotFather sends a **token** like `123456789:AA...`.
  </Step>

  <Step>
    ### Connect the bot in Happ [#connect-the-bot-in-happ]

    Open **Integrations**, find **Telegram Bot** and click the card. Paste the token and confirm. The bot appears in **My integrations**.
  </Step>

  <Step>
    ### Assign the agent [#assign-the-agent]

    Open the agent, **Integrations** tab, and bind the bot to it. Without this step the bot receives messages but does not reply.
  </Step>

  <Step>
    ### Check it [#check-it]

    Write to the bot from your personal Telegram. The conversation shows up in **Chats** and the agent replies within seconds.
  </Step>
</Steps>

<Callout type="warn" title="The token is access to the bot">
  Never paste the token into chats or publish it. If it leaks, issue a new one in @BotFather with `/revoke` and reconnect the bot.
</Callout>

## Troubleshooting [#troubleshooting]

| Symptom                             | What to do                                                            |
| ----------------------------------- | --------------------------------------------------------------------- |
| The bot does not reply              | Check the bot is bound to an agent and **AI mode** is on in the chat. |
| Error while connecting              | Copy the token again in full, without leading or trailing spaces.     |
| It replies in groups but should not | Disable group access in @BotFather: `/setjoingroups`.                 |

## Next [#next]

* [Inbox](/guides/inbox): how a manager takes over a conversation.
* [Telegram](/docs/integrations/messengers/telegram): connect a personal account instead of a bot.
