Skip to content

How to connect a Telegram bot to an agent

An O-Key agent is an AI assistant that talks to your clients. You can connect different channels to the same agent, including website chat, WhatsApp, and Telegram. When a client writes to your Telegram bot, the agent replies automatically and the conversation appears in CRM.

Before you start: create a bot in Telegram

Section titled “Before you start: create a bot in Telegram”

You need three values before opening CRM:

  • the bot token;
  • the bot username;
  • your personal Telegram username.

If you already have a Telegram bot, skip to the checklist at the end of this section.

Open Telegram on your phone or computer, search for BotFather, and open the official verified bot.

Click Start or send /start. BotFather will show the available commands.

Send:

/newbot

BotFather will ask for a display name. Enter any clear name, for example:

My O-Key assistant

Then BotFather will ask for a bot username. The username must be unique and must end with _bot or Bot, for example:

MyCRM_AssistantBot

✅ Save this username. You will need it in CRM.

After the bot is created, BotFather sends an HTTP API token. It looks like this example:

1234567890:AAHdqTcvCH1vZJf7LJ1c6s9xXmN0zYxE

Copy the full token and keep it private.

❌ Never share the real token in chats or screenshots. Anyone with the token can control the bot.

Step 5. Find your personal Telegram username

Section titled “Step 5. Find your personal Telegram username”

Open Telegram settings and find Username. If it is empty, create and save one. Use it without @, for example ivan_petrov.

At the end of this step you should have:

  1. the bot token;
  2. the bot username, for example MyCRM_AssistantBot;
  3. your personal Telegram username, for example ivan_petrov.

Open the CRM URL provided to you and sign in.

Agents list

You will see a list of agents. To connect Telegram to a new agent, click Create agent. To connect Telegram to an existing agent, click that agent’s name.

Agent settings

The page shows available channels such as Telegram, website card, and WhatsApp. We will configure Telegram in the next section.

Enter an internal name that is clear to you, for example Telegram support assistant or Telegram sales. Clients do not see this internal name.

A knowledge base is optional at this step. You can add it later, but it is recommended for production use.

This is not needed for Telegram.

Choose what the agent should do: FAQ answers, lead generation, product consulting, support, or another available role. If you are unsure, choose consulting and adjust it later.

✅ Do not save yet if you still need to connect Telegram on the same setup page.

Channel connection options

Telegram channel form

In Channel connections, select Telegram to expand the form.

Paste the token from BotFather. Remove extra spaces before or after it.

Enter the bot username without @. If BotFather gave @MyCRM_AssistantBot, enter MyCRM_AssistantBot.

Enter your personal Telegram username without @, for example ivan_petrov.

Telegram channel notes

The Telegram instruction note is only a reminder. The WhatsApp and website-card warnings do not affect this Telegram connection.

Click Save at the bottom of the page. O-Key checks that the bot exists, the token matches the username, and the owner username is valid. If everything is correct, the agent becomes active.

Find your bot by username, click Start, or send Hello. The bot should reply, even if the answer is a default fallback.

If there is no reply, wait one or two minutes and refresh CRM.

Open the agent again and check Dialogs or Chats. You should see the message you just sent.

ProblemLikely causeWhat to do
The bot does not reply in TelegramWrong tokenCopy the token again from BotFather: /mybots → select bot → API Token.
CRM says the bot username is invalidUsername was entered with @ or wrong capitalizationEnter the exact bot username without @, preserving case.
CRM says owner was not foundYour personal username is wrong or emptyOpen Telegram settings, confirm your username, and enter it without @.
The bot replies incorrectlyKnowledge base or task is not configuredUpdate the agent task and connect a knowledge base.
Saving hangsTemporary connection issueRefresh the page and click Save again.
  1. In Telegram, create a bot through @BotFather and copy the token and username.
  2. Make sure your personal Telegram username exists.
  3. In CRM, create or open an agent.
  4. Fill in the agent name and task.
  5. Open Telegram in channel connections.
  6. Paste the token, bot username, and your username.
  7. Save.
  8. Send a test message to the bot and confirm the dialog appears in CRM.