Telegram tracking

Register a Telegram bot, surface its handle on your site, ingest every incoming message as an attributed lead event.

Telegram tracking is different from the phone / email / form channels - there’s no DOM swap and no SDK call. The visitor clicks through to a Telegram chat with your bot, types a message, and Funnelion.ai ingests the message as a lead event via Telegram’s webhook. The only frontend work is making sure the link the visitor clicks carries a start parameter that ties the chat back to their session.

1. Create the bot on Telegram

  1. Open Telegram and start a chat with @BotFather.
  2. Send /newbot, follow the prompts: pick a display name and a unique username ending in bot (e.g. acme_sales_bot).
  3. BotFather returns an HTTP API token - a long string like 9876543:AAH.... Treat it as a secret; never embed it in client-side code.

2. Register the bot in Funnelion.ai

  1. Open Telegram bots → New in the dashboard.
  2. Paste the BotFather token. Funnelion.ai calls getMe to verify the token and store the bot’s username as the channel address.
  3. Pick a pool (channel kind telegram) - or leave unassigned for a single-bot setup with default routing.
  4. Save. Funnelion.ai registers the webhook with Telegram automatically (setWebhook to dash.funnelion.ai/webhooks/telegram/<secret>), so every incoming message lands as a lead event without further configuration on your side.

Why a pool?

Pools exist for the same reason as on the phone and email channels - multiple bots can be grouped behind one identity in the dashboard, and routing rules let utm-aware traffic claim different bots. For a single-bot site you can ignore the pool and leave the channel unassigned.

3. Link the bot on your site

The link to your bot is a normal anchor. The trick is passing a start parameter that Funnelion.ai uses to attribute the chat to the visitor’s session:

HTML
<a
  href="https://t.me/acme_sales_bot?start={start_token}"
  data-funnelion="Telegram"
>
  Chat with us on Telegram
</a>

{start_token} is filled in at resolve time. Configure a swap zone of kind telegram in the dashboard with the right selector; the snippet rebuilds the link on every page load, swapping in the visitor’s start token. Funnelion.ai uses that token to bind the Telegram chat to the visitor session that clicked through.

Frontend path (JS snippet) - recommended

HTML
<!-- Production (minified, recommended) -->
<script async src="https://dash.funnelion.ai/track.min.js?t=YOUR_SITE_TOKEN"></script>

<!-- Same code, unminified - handy when debugging in DevTools -->
<script async src="https://dash.funnelion.ai/track.js?t=YOUR_SITE_TOKEN"></script>

The snippet binds to elements matching your Telegram swap zone’s selector and rewrites the href on each page load - specifically, it builds https://t.me/<bot>?start=<visitor_start_token>, so the first message the visitor sends to the bot carries the attribution token straight back to Funnelion.ai.

Backend path (PHP SDK)

Manual wiring for now

The PHP ZoneSwapper currently rewrites tel: and mailto: hrefs but not Telegram deep links. If you’re going pure server-side, call resolveOrNull() as usual, then read the Telegram zone and its start_token from $response->swapZones and build the URL yourself - or load the JS snippet on top of the SDK and let it handle the Telegram zone client-side.
PHP
$response = $client->resolveOrNull(/* ... */);
$telegramZone = null;
foreach ($response?->swapZones ?? [] as $zone) {
    if ($zone->channelKind === 'telegram') {
        $telegramZone = $zone;
        break;
    }
}

$deepLink = $telegramZone && $telegramZone->address
    ? 'https://t.me/'.rawurlencode($telegramZone->address)
        .($telegramZone->startToken
            ? '?start='.rawurlencode($telegramZone->startToken)
            : '')
    : 'https://t.me/acme_sales_bot'; // fallback

4. What you get

  • Every incoming Telegram message lands as a lead event of kind telegram, attributed to the visitor session that clicked through.
  • Conversation history is visible in the dashboard alongside the visitor’s UTMs, landing page and other touches.
  • Identity resolution: if the same Telegram user later submits a form with a matching phone or email, Funnelion.ai dedups them into a single Lead.
  • You reply to visitors from inside the dashboard - Funnelion.ai proxies messages through the bot.

Bot username changes

If you ever change the bot’s username on BotFather, the existing t.me/<old> links on your site break - Telegram doesn’t redirect. Re-issue the link with the new username and re-deploy. The Funnelion.ai channel updates automatically the next time `getMe` is called.