Skip to main content

Telegram Mini-App Setup & Guide

Updated over a month ago

The telegram mini app allows your players to register and play from within the telegram app. This increases conversion and enables retargeting.

Configure Telegram Mini-App

To create a telegram miniapp visit telegram BotFather

  • Select the bot you wish to use (we recommend using the same bot you previously supplied and use for registrations on your site)

Under Edit Bot change the following:

  • Bot name

  • About

  • Description - In the bot description, write something that encourages the player to start the bot. Ex: /start to start playing!

  • Description picture

  • Botpic

Under Bot Settings

  • Enable Allow groups (this will allow you to invite the bot to your groups and channels)

  • Domain: Point the domain to your site ex https://yourbrand.com

  • Click configure miniapp, send the mini app URL https://yourcasino.com

  • Click change mode and select Fullscreen

  • You can also configure the splashscreen (optional)

  • Do not enable the menu button option

After all the settings above are configured create a ticket requesting the miniapp to be enabled.

In the ticket include your welcome message:

  • Welcome text

  • Welcome image (16x9 proportion)

  • Button text


Telegram & Customer.io

To collect customer details such as username and target telegram customers with campaigns you need to modify your Customer.io inApp tagmanager script in google tagmanager.

(ensure you change the API-KEY to the one used by your current inApp script)

If you need assistance with this please reach out and we will help you get this set up.

<script>
!function(){
// 1. Customer.io Base Snippet (CDP EU)
var i="cioanalytics", analytics=(window[i]=window[i]||[]);
if(!analytics.initialize){
if(analytics.invoked) window.console && console.error && console.error("Snippet included twice.");
else {
analytics.invoked=!0;
analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];
analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};
for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}
analytics.load=function(writeKey, options){
var t=document.createElement("script");
t.type="text/javascript"; t.async = true;
t.setAttribute('data-global-customerio-analytics-key', i);
t.src = "https://cdp-eu.customer.io/v1/analytics-js/snippet/" + writeKey + "/analytics.min.js";
document.getElementsByTagName("script")[0].parentNode.insertBefore(t,document.getElementsByTagName("script")[0]);
analytics._writeKey = writeKey;
analytics._loadOptions = options;
};
analytics.SNIPPET_VERSION="4.15.3";
analytics.load("API-KEY-HERE", {
integrations: { "Customer.io In-App Plugin": { anonymousInApp: true } }
});
analytics.page();
}
}

// 2. Identification Logic with Dual Fallback

  function doIdentify() {
// Priority 1: GTM Variable
var gtmId = "{{user_id}}";

// Priority 2: Intercom Settings (Fallback)
var intercomId = (window.intercomSettings && window.intercomSettings.user_id) ? window.intercomSettings.user_id : null;

// Select the best available ID
var finalUserId = (gtmId && gtmId !== "undefined" && gtmId !== "") ? gtmId : intercomId;

if (window.cioanalytics && finalUserId) {
var traits = {};

// Pull Telegram data if available (Non-blocking)
var tg = window.Telegram && window.Telegram.WebApp;
if (tg && tg.initDataUnsafe && tg.initDataUnsafe.user) {
var user = tg.initDataUnsafe.user;
traits.telegram_id = user.id;
traits.telegram_username = user.username ? "@" + user.username : "no_username";
traits.telegram_first_name = user.first_name || "";
traits.is_tg_premium = user.is_premium || false;
}

// Merge Intercom attributes if they exist (email/name)
if (window.intercomSettings) {
if (window.intercomSettings.email) traits.email = window.intercomSettings.email;
if (window.intercomSettings.name) traits.name = window.intercomSettings.name;
}

// Identify the user
cioanalytics.identify(finalUserId, traits);
console.log("✅ Customer.io identified via " + (gtmId === finalUserId ? "GTM" : "Intercom") + ":", finalUserId);

} else {
// If neither ID is ready yet, retry in 250ms
setTimeout(doIdentify, 250);
}
}

doIdentify();
}();
</script>

Message telegram bot users through telegram:

You can send messages to the telegram mini-app users from customer.io by filtering users by authentication type or telegram_username exists.

To message the users create a webhook in your campaign:

{
"chat_id": "{{customer.authenticator_identifier}}",
"photo": "https://imageurl.com/telegram_welcome.png",
"caption": "🚀 <b>Welcome to Casino</b>\n\nThe world’s most transparent on-chain casino.\n\n👉 Tap the button below to launch the app!",
"parse_mode": "HTML",
"reply_markup": {
"inline_keyboard": [
[
{
"text": "🎰 Open Mini App",
"web_app": {
"url": "https://casino.com"
}
}
]
]
}
}

In the webhooks sending settings ensure that the behaviour is set to Send automatically:

Did this answer your question?