▪️Activity: Telegram Bot

This document provides a detailed guide to creating and configuring a Telegram Bot, enabling you to build Journey flows and use the chat features described in the communications guide effectively.

To start using the Telegram bot as a communication channel, you will need to complete the following steps:

  1. Create a Telegram bot for your brand(s) using the Telegram application.

  2. Configure the bot's settings on the Smartico side.

  3. Invite users to the Telegram bot so their Telegram profile is linked to their Smartico profile.

  4. Create telegram messages as resources in Smartico BackOffice.

  5. Start using Realtime and Scheduled campaigns to communicate with your users.

Create a Telegram Bot

  1. Open the Telegram application on your laptop or mobile device.

  2. Please search for a bot called BotFather and start a chat with it.

  3. Send the command /newbot to create a new bot.

  4. Set a name for your bot (e.g., My Casino Bot).

  5. Choose a unique username for your bot that ends with “bot” (e.g., MyCasinoBot). Important: Remember this username, as you will need it for the Smartico setup.

  6. Once the bot is created, BotFather will provide an API token. Important: Save this token, as it grants access to Telegram’s HTTP API.

Configure the Bot in Smartico

  1. Log in to Smartico Back Office and navigate to Label → Instant Messages.

  2. Create a new gateway and select Telegram as the type.

  3. Define an internal name for the gateway, then select the appropriate brand for your bot.

  4. Fill in the required parameters:

  • Name of the Bot: Use the username from Step 5 in the format @MyCasinoBot (include the “@” symbol. Without it, the bot link generation may fail).

  • Telegram Bot token: Enter the token received in Step 6. Keep this token secure and never share it publicly.

  • Secret for User ID Hashing: Enter a random string to secure the process of linking the Telegram user profile with the casino user profile. An alphanumeric string of 10 symbols is secure enough.

  • Auth Link: Provide a link to your casino’s front-end. This is used to connect the Telegram user profile with the casino user profile. Example: https://mycasino.com. Pay attention that it should be HTTPS.

By following these steps, you will successfully create and integrate your Telegram bot with Smartico.

Enable Mini App for your Telegram Bot (optional)

These optional steps let you activate the Mini App feature, allowing your bot to open a link directly inside Telegram’s Mini App instead of a standard web browser.

Mini App vs Regular Bot:

  • Regular bot: Opens chat interface, user clicks buttons

  • Mini App: Opens a web view inside Telegram (better UX for complex interactions)

  • You can have both - Telegram Bot and Mini App; these options are not mutually exclusive.

When to use Mini App:

  • When you want users to browse your site within Telegram

  • When you need rich interactive content

  • When you want a seamless authentication flow

How to set up Mini-App

  1. Open your bot

  2. Tap the three-dot menu (top right corner) and select Manage Bot

  3. Select Change Bot Settings

  4. You'll be redirected to Bot Father (the Telegram bot used to create your bot). An automatic reply will give you different configurational options.

  5. Select Bot Settings

  6. Select Configure Mini App

  7. Select Enable Mini App

  8. Submit the URL for your website - this is what the Mini App will load. To launch the Mini App for users, use the following link format: https://t.me/your_bot_username?startapp * "your_bot_username must exactly match the name of your bot without @

Invite users to the Bot channel

Once your setup is complete, the user can subscribe to the chatbot by authenticating via a deep link to Telegram, "dp:telegram". For example, you can set the deep link to a mission "Join our Telegram" to encourage the user to subscribe. Upon clicking, the user will be redirected to the Telegram app, a new chat window will open automatically, and the authentication process will complete.

You can use the deep link "dp:telegram" in any other context, for example, in the popups, or you can also execute it from the front-end code of the website.

The user flows to the bot channel

  1. The player clicks an element that contains the deep-link dp:telegram.

  2. Smartico generates a unique token and constructs a URL leading to the Telegram bot/channel, embedding the token.

  3. The player opens the link in the Telegram app and clicks the Join button to subscribe to the channel.

  4. Telegram reports the "join" action back to Smartico.

  5. Smartico links the player’s profile with their Telegram account using the token.

  6. The core_telegram_chat_id and core_telegram_user_name Fields in the player profile are updated with the user's Telegram chat ID and username or first name from Telegram.

  7. Smartico triggers the internal event core_telegram_auth, which can be leveraged to send a welcome message or trigger onboarding automation.

Flow 2: Initiated from Telegram Channel

  1. A user discovers the Telegram bot/channel and clicks the Join button.

  2. Telegram notifies Smartico that the user has joined.

  3. Smartico generates a unique token and creates a link to the brand’s website, using the Auth Link configured in the Telegram channel settings, the link is sent to the Telegram bot channel.

  4. The user opens the link in a browser and is redirected to the brand’s site.

  5. After successful authentication, Smartico receives the token data from the website.

  6. Smartico matches the Telegram user with the corresponding player profile.

  7. The core_telegram_chat_id and core_telegram_user_name fields in the player profile are updated with the user's Telegram chat ID and username or first name from Telegram.

  8. Smartico triggers the core_telegram_auth internal event, enabling welcome messages or other follow-up flows.

Translations

  • Bot uses telegram_welcome translation key for welcome message

  • Bot uses telegram_auth_button translation key for auth button text

  • These can be customized in Smartico translation settings

  • Language is detected from user's Telegram profile language setting

Telegram Activity

The Telegram activity is used for sending a communication to the end users via Telegram and it is considered to be an offline communication since it doesn't require the user to be online. This type of communication can be sent only from Campaigns - Real-time and Scheduled.

Inside the flow builder the Telegram activity is located in the communication section.

The telegram activity has the following setup options:

  1. Provider - choosing the Telegram provider that will be used for sending the communication. You can also choose the Automatic Selection (multi-brand setup).

    1. Automatic Selection (multi-brand setup) - used to automatically select the first gateway that meets the conditions. By default, the first condition is Brand, but you can add more user properties. This gives you more flexibility when you want to filter a specific segment of users to use a different gateway, for example.

  2. Allowed Communication hours - used to define how the flow should behave if the time of the sending is in the ‘Do not Disturb’ period of the user.

  3. Telegram message - used to add the asset that will be sent to players, where you can define the message content. Before sending any communication via Telegram, the corresponding asset must be created. You can also add multiple message variations for A/B testing, allowing you to test different versions and optimize engagement. When adding a second variation, you can specify the percentage of the audience that will receive each version, ensuring controlled message distribution.

Visibility in user profile

From the profile page you can check if the user has subscribed to the Telegram chat bot and if so you see the chat ID (core_telegram_chat_id), you will also see Telegram user name (core_telegram_user_name), which is populated from the profile of user in Telegram.

CRM User profile, telegram chat ID and telegram user name

Segmentation

You can create segmentation for all subscribed users by setting the Telegram chat ID to not equal 0 (this finds the users that have Telegram channel enabled).

Telegram specific events

There are 2 events that are specific for the telegram that you can use to start real-time campaigns, complete missions, execution automation rules to progress in the campaign flows.

  1. When user subscribes to Telegram bot, Smartico will trigger event "Core: telegram auth completed". You can use this event to send a welcome message to the personal channel with user.

  2. When user is blocking/unsubscribing from Telegram bot, Smartico will trigger "Core: telegram unsubscribed" event.

Example of campaign that is started when user is joining telegram bot

FAQ

Q: I have set up a campaign to send messages, but they are not being delivered

A: Check the following configurations

  • You are targeting users who are subscribed to the Telegram bot. Your segment conditions should check for "Telegram chat id" <> 0

  • You have "Instant messages" enabled in the label settings

  • Your DnD period is set correctly for "Instant messages."

Q: How can I do a new line in the Telegram message? Tried <br> and <p>, but they are not supported

A: Telegram has a limited set of support HTML tags. To achieve a new line you can put an empty <pre></pre> pair of tags

Q: How are delivery/impressions/clicks tracked in reporting for Telegram messages?

A: Telegram as a platform does not provide information on whether the message was delivered or seen by the user, though on the Smartico side, we have only information like

  • Created - first fact, indicating that communication is created by activity in the campaign

  • Send - the fact that communication was sent by Telegram bot (although it doesn't indicate if it was successfully sent)

  • Failed - failed to deliver the message

  • Click - user clicked on the link to the button in the message

Q: What happens if the user blocks and then unblocks the bot?

A: When unblocked, the user needs to click /start again. The core_telegram_auth The event will fire again, updating the chat ID.

Q: Can I send images in Telegram messages?

A: Yes, select "Image & Text/HTML" as content type when creating the message asset. Image URL must be a publicly accessible HTTPS URL.

Q: What's the maximum message length?

A: Text-only messages: 4096 characters. Messages with media caption: 1024 characters.

Q: Can you explain the events that are sent when a user joins/leaves the Telegram bot?

core_telegram_auth - happens when the user joins the bot

core_telegram_unsubscribed - when the user leaves the bot

Q: Which HTML tags are supported?

A: Telegram supports limited HTML:

<b>, <strong>, <i>, <em>, <u>, <ins>, <s>, <strike>, <del>, <a>, <code>, <pre>, <blockquote>

Last updated

Was this helpful?