Help Center How to connect a Telegram bot

How to connect a Telegram bot

A Telegram bot lets your operators talk to customers in Telegram from the workspace chat.smsbat.com. You create the bot yourself in Telegram with @BotFather, then connect it in the omni.smsbat.com dashboard with its token. In the dashboard you can also build the bot’s own menu (the strategy): messages, buttons and images the bot sends without an operator.

Use this page when you connect a new Telegram bot, change its token or settings, or edit what the bot answers.

Before you start

  • an organization in SMSBAT Omni, see Verify your organization;
  • a Telegram bot and its token. If you have no bot yet, create one in Telegram:
    1. Open a chat with @BotFather and send /newbot.
    2. Send the bot’s display name, then its username. BotFather requires the username to end in “bot”.
    3. BotFather replies with the bot token (a long line of digits and letters). Copy it.

Warning

The token gives full control over the bot. Do not post it in chats or screenshots. If it leaks, issue a new token in @BotFather and update it in the dashboard (see Change the token).

Where to find Telegram bots

In the left menu of omni.smsbat.com open Channels → Telegram → Bots. The Telegram Bots page opens with the list of your bots.

Filters

The Filters button shows or hides the filter bar; Clear filter resets it.

FilterWhat it does
OrganizationShows the bots of one organization.
NameFinds a bot by name.
URIFinds a bot by its username.
StatusShows bots with one status (see Bot statuses).
Bot TypeTechnical or Public.
Client NameVisible to SMSBAT administrators only.

Table columns

ColumnWhat it shows
NameThe bot name in SMSBAT.
URIThe bot’s username.
StatusThe bot status as a coloured label.
TypeTechnical or Public.

Click a row to open the bot page. On a phone each bot is a card with a Details button.

Step 1. Add the bot

  1. On the Telegram Bots page press Add Bot. The Register Bot page opens with the tabs Viber, Telegram and WhatsApp; the Telegram tab is already selected.

  2. Fill in the form:

    FieldWhat to enter
    OrganizationThe organization the bot will belong to. Its chats go to this organization’s operators.
    Bot NameThe bot name as your colleagues will see it in SMSBAT.
    Bot languageStart typing and choose the bot’s main language from the list.
    Bot TypeTechnical or Public. If you are not sure which one to choose, ask your SMSBAT manager.
    TokenPaste the token from @BotFather.

    All fields are required. An empty field is highlighted with Field is required.

  3. Press Register Bot. The message Successfully was created appears and you return to the list.

The registration form has no username field. Add the username afterwards in Bot URI on the bot page (Step 2).

Step 2. Check the details and set the webhook

  1. Click the bot in the table. The bot page opens with the bot name as the title.
  2. Press the menu icon (three lines) on the left to show the bot menu: Details, Downtime, Notifications, Chat settings, API integrations. The Details block is open by default.
  3. Check the fields, add Bot URI if it is empty, and press Update Bot Settings. The message Bot data updated appears.
  4. Press Set Webhook. The message Webhook successfully was seated means Telegram now sends the bot’s messages to SMSBAT.
  5. Send a message to the bot from your phone and make sure it appears in chat.smsbat.com.

Set Webhook is inactive while the bot has no token.

Bot settings

Details

FieldWhat it means
StatusThe bot status in SMSBAT, see Bot statuses.
Is Bot under verificationShows that the bot is under verification. Leave it as it is unless your manager asks you to change it.
ChatChat mode of the bot. Keep it on if operators should talk to customers through this bot.
TypeTechnical or Public.
Bot languageThe main language of the bot.
Bot nameThe name in SMSBAT.
Bot URIThe bot’s username in Telegram.
Bot tokenThe token from @BotFather.
Internal Callback UrlShown when the bot has one. The link button next to it copies the address; it is used when you integrate the bot through the API.

Status, Type and Bot language are required. Save the changes with Update Bot Settings. Edit Bot Strategy opens the menu editor (see Bot strategy).

Change the token

If you issued a new token in @BotFather:

  1. Open the bot and paste the new token in Bot token.
  2. Press Update Bot Settings.
  3. Press Set Webhook again.

Downtime

The Downtime block stores one time value (hours, minutes and seconds) for the bot.

  1. Open Downtime in the bot menu.
  2. Click the field Choose time and set the time.
  3. Press Set new downtime. The message Bot data updated appears.

To remove the value, press Delete downtime and confirm with Confirm.

Automatic closing of idle chats for the whole organization is set on the Downtime tab of chat settings.

Notifications

The Survey email notifications panel holds the e-mail addresses that receive survey notifications from this bot. Click the panel header to expand it.

  • + adds an address: enter Email and press Create.
  • The pencil icon edits an address; the bin icon deletes it after Confirm.

Chat settings

The Chat trigger panel holds the texts that start or end a chat for this bot.

  1. Expand Chat trigger and press +.
  2. In Select type choose Start chat or End chat.
  3. Enter the text in Content and press Create.

The table shows Trigger type and Content. Use the pencil icon to change the text and the bin icon to delete a trigger.

API integrations

The API integrations panel holds the addresses of your own systems that work with the bot.

  1. Expand API integrations and press +.
  2. Fill in Url, optionally Header name and Header value (for example an authorization header your system expects), and choose the source: General or OneC.
  3. Press Create.

Url and the source are required. For the API itself see Chat API.

Bot strategy

The strategy is what the bot does by itself: which messages it sends, with which buttons and images. Open it with Edit Bot Strategy on the Details block. The Telegram Bot Strategy page has three columns.

ColumnWhat it contains
ActionsThe list of the bot’s actions with a Search box and an Add button.
Action EditorThe settings and messages of the selected action. Until you select one, it shows Select element.
Template messagesAll loaded messages of the bot, for a quick overview.

Step 1. Create an action

  1. In Actions press Add. A new action named “New Action 1” (2, 3 …) is created and saved at once.

  2. Click the action. In Action Editor change Action Name to something clear, for example “Main menu”.

  3. Choose the Action Type:

    Action TypeWhat the action does
    SendActionMessagesSends the messages of this action.
    DeleteMessageDeletes the message.
    DeleteAndSendActionMessagesDeletes the message and sends the messages of this action.
    UpdateMessageUpdates the message.
    SendActionMessagesAndResetUserActionSends the messages of this action and resets the user’s current action.

To delete an action, press the small × on its card and confirm with Delete. The deletion is saved at once.

Step 2. Add messages to the action

  1. Under Attached Templates press Add Template Message. An empty message is added to the action.

  2. Fill in the message:

    FieldWhat to enter
    Sequence numberThe position of the message among the action’s messages.
    TextThe message text.
    Keyboard typeReply (buttons under the input field) or Inline (buttons attached to the message). Required before you add buttons. Once the message has buttons, the type is locked; it becomes editable again after you delete all buttons.
    ImagesAdd image attaches a picture. The × on a picture removes it.
  3. The × in the top-right corner of a message removes it.

Step 3. Add buttons

  1. In the message press Add button. If no Keyboard type is chosen, you see Keyboard type is required.

  2. In the Add Button window fill in:

    FieldWhat to enter
    TextThe button caption.
    ActionThe action that runs when the customer taps the button.
    URLOnly for Inline buttons: the web address the button opens.
    Position, Row indexWhere the button stands: its place in the row and the row number.
    Request contactThe button asks the customer to share their phone number.
  3. Press Save. Click a button in the message to edit it; the × on the button deletes it.

Step 4. Save the strategy

Press Save strategy at the bottom of the page. The message Strategy saved confirms it; Strategy save error means something was not saved, so check the fields and save again.

Tip

Adding an action or a message saves the strategy right away, together with your other unsaved changes. Changes to names, texts, buttons and images, and removed messages, are saved only with Save strategy.

Bot statuses

In the list a bot can have one of these statuses: Active, Inactive, Pending Approval, Hold, Closed, Declined, Archived, Moderation or Approved. If the status is not what you expect, contact your manager or support@smsbat.com.

Using the bot in chats

  • Messages customers send to the bot arrive in chat.smsbat.com under the chat type Telegram.
  • An operator can write first to a customer who has already started the bot: Create chat → Source TelegramBot → choose the bot and the user, see How to sign in and create a chat.
  • An after-hours message with buttons for the bot is set in chat settings.
  • Bulk messages through the bot are described in Broadcasts, delivery results in Message statuses.

Common questions

Set Webhook is inactive. The bot has no token. Paste the token in Bot token, press Update Bot Settings, then Set Webhook.

Customers write to the bot, but nothing appears in the chat. Press Set Webhook again. If you issued a new token in @BotFather, update it first. Check also that the Chat switch is on and that the operator’s filters in the workspace do not hide Telegram chats.

Where do I enter the bot’s username? The registration form has no such field. Open the bot after registration and fill in Bot URI.

I don’t see the bot menu (Details, Downtime …) on the bot page. Press the menu icon (three lines) on the left. The × icon hides the menu again.

The customer I want to write to is not in the bot user list. The list contains only people who have already started the bot. Ask the customer to send any message to the bot first.

The Add button in a message shows “Keyboard type is required”. Choose Reply or Inline in Keyboard type first, then add buttons.