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:
- Open a chat with @BotFather and send
/newbot. - Send the bot’s display name, then its username. BotFather requires the username to end in “bot”.
- BotFather replies with the bot token (a long line of digits and letters). Copy it.
- Open a chat with @BotFather and send
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.
| Filter | What it does |
|---|---|
| Organization | Shows the bots of one organization. |
| Name | Finds a bot by name. |
| URI | Finds a bot by its username. |
| Status | Shows bots with one status (see Bot statuses). |
| Bot Type | Technical or Public. |
| Client Name | Visible to SMSBAT administrators only. |
Table columns
| Column | What it shows |
|---|---|
| Name | The bot name in SMSBAT. |
| URI | The bot’s username. |
| Status | The bot status as a coloured label. |
| Type | Technical 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
-
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.
-
Fill in the form:
Field What to enter Organization The organization the bot will belong to. Its chats go to this organization’s operators. Bot Name The bot name as your colleagues will see it in SMSBAT. Bot language Start typing and choose the bot’s main language from the list. Bot Type Technical or Public. If you are not sure which one to choose, ask your SMSBAT manager. Token Paste the token from @BotFather. All fields are required. An empty field is highlighted with Field is required.
-
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
- Click the bot in the table. The bot page opens with the bot name as the title.
- 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.
- Check the fields, add Bot URI if it is empty, and press Update Bot Settings. The message Bot data updated appears.
- Press Set Webhook. The message Webhook successfully was seated means Telegram now sends the bot’s messages to SMSBAT.
- 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
| Field | What it means |
|---|---|
| Status | The bot status in SMSBAT, see Bot statuses. |
| Is Bot under verification | Shows that the bot is under verification. Leave it as it is unless your manager asks you to change it. |
| Chat | Chat mode of the bot. Keep it on if operators should talk to customers through this bot. |
| Type | Technical or Public. |
| Bot language | The main language of the bot. |
| Bot name | The name in SMSBAT. |
| Bot URI | The bot’s username in Telegram. |
| Bot token | The token from @BotFather. |
| Internal Callback Url | Shown 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:
- Open the bot and paste the new token in Bot token.
- Press Update Bot Settings.
- Press Set Webhook again.
Downtime
The Downtime block stores one time value (hours, minutes and seconds) for the bot.
- Open Downtime in the bot menu.
- Click the field Choose time and set the time.
- 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.
- Expand Chat trigger and press +.
- In Select type choose Start chat or End chat.
- 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.
- Expand API integrations and press +.
- Fill in Url, optionally Header name and Header value (for example an authorization header your system expects), and choose the source: General or OneC.
- 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.
| Column | What it contains |
|---|---|
| Actions | The list of the bot’s actions with a Search box and an Add button. |
| Action Editor | The settings and messages of the selected action. Until you select one, it shows Select element. |
| Template messages | All loaded messages of the bot, for a quick overview. |
Step 1. Create an action
-
In Actions press Add. A new action named “New Action 1” (2, 3 …) is created and saved at once.
-
Click the action. In Action Editor change Action Name to something clear, for example “Main menu”.
-
Choose the Action Type:
Action Type What the action does SendActionMessages Sends the messages of this action. DeleteMessage Deletes the message. DeleteAndSendActionMessages Deletes the message and sends the messages of this action. UpdateMessage Updates the message. SendActionMessagesAndResetUserAction Sends 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
-
Under Attached Templates press Add Template Message. An empty message is added to the action.
-
Fill in the message:
Field What to enter Sequence number The position of the message among the action’s messages. Text The message text. Keyboard type Reply (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. Images Add image attaches a picture. The × on a picture removes it. -
The × in the top-right corner of a message removes it.
Step 3. Add buttons
-
In the message press Add button. If no Keyboard type is chosen, you see Keyboard type is required.
-
In the Add Button window fill in:
Field What to enter Text The button caption. Action The action that runs when the customer taps the button. URL Only for Inline buttons: the web address the button opens. Position, Row index Where the button stands: its place in the row and the row number. Request contact The button asks the customer to share their phone number. -
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.