Blog

How to monetize a Telegram bot without sharing the token

To monetize a Telegram bot without sharing the token on HiViews, you prove the bot is yours with a short code in its About text, get an API key, and the bot itself requests a ready ad post and sends it to the user. The BotFather token stays with you. From day one you are paid for impressions whose sending Telegram confirmed and for ad clicks.

Updated:

How to monetize a Telegram bot without sharing the token: the idea

HiViews has two integration modes. With a token, the network sends the ad on the bot’s behalf: one API call on your side. Without a token, your own code does the sending: the bot asks the network whether there is an ad for this person, receives a ready post and sends it itself.

Whether sharing a token is risky, and what an ad network can do with it, is a separate topic covered in Is it safe to share your Telegram bot token with an ad network? This article is the practical part: how to connect the bot, what to check in the code and what you are paid for.

What you need:

  • a bot that real people use;
  • access to that bot in @BotFather, to edit its About text;
  • the ability to add one function and two calls to the bot’s code.

Telegram bot ads without a token: five steps to connect

  1. Add the bot in the dashboard

    In the web dashboard, open the bot connection page and choose “Without a token”.

  2. Prove the bot is yours

    The dashboard shows a short code. Put it into the bot’s About text: @BotFather → Edit Bot → Edit About. That code is how HiViews knows you control the bot.

  3. Get the API key

    Once ownership is confirmed you get an API key. The bot passes moderation like any other bot on the network. In its settings you can choose which formats to sell and refuse certain ad categories.

  4. Paste the ready function

    The docs have ready code for Python (aiogram), Node.js (Telegraf) and PHP. The function requests a post and sends it with the right method — photo, video, GIF or plain text. All that is left is to insert your key.

  5. Call it in two places

    In the /start handler with StartPlace: true, before the bot’s own greeting. And after the bot has delivered its result to the user, with StartPlace: false.

The general rules for bot owners are in the guide for bot owners.

The ad request: what the bot sends and what it gets

There is one request: POST https://hiviews.net/api/partner/ad with an Authorization header that carries the API key.

FieldWhat to send
UserIdThe user’s Telegram ID. Required
UserFirstNameThe user’s first name — it is used in posts that address the person by name
UsernameThe user’s @username, if there is one
LanguageThe user’s Telegram interface language
StartPlacetrue on /start, false after the result is delivered

The answer is always JSON. If there is an ad, you get "ok": true and an ad object: text, buttons and, where present, a photo, video or GIF. Send it to the user as is. If nothing fits, you get "ok": false and the bot simply carries on. A delete_after field, when present, means the post should be deleted after that many seconds.

An empty answer is normal, not an error. The network protects users: one person sees at most one ad per hour and six per day across all bots, and a welcome ad in a given bot no more than once a day.

How Telegram confirms that the post was sent

Without a token the network cannot see whether the bot really sent the post. So Telegram itself confirms it: the text of the post starts with an invisible link, and when the bot actually sends the message, Telegram requests that link. That is how HiViews knows the post went out to the user.

Three rules follow, and payment does not work without them:

  • Keep link previews on. Do not set disable_web_page_preview: with previews off Telegram never requests the link, and the sending stays unconfirmed.
  • Do not change the text. Do not strip links, rewrite the post or add anything of your own to it.
  • Leave the buttons alone. Button links go through hiviews.net — that is how clicks are counted. A click on a changed link is not paid.

The main rule of the no-token mode: send the post exactly as you received it. A post whose sending Telegram did not confirm is not paid: neither the impression nor the clicks on it.

With a token and without: what is different

AspectWithout a tokenWith a token
Who sends the adYour botHiViews
How ownership is provedA code in the bot’s About textThe BotFather token
IntegrationA ready function: request the post and send itOne API call
What is paid from day oneEvery confirmed impression, and clicksEvery impression, and clicks
Paid impressionsAt once, for confirmed impressions; at a lower rateAt once: $4.80 per 1,000 welcome and $2.40 per 1,000 regular impressions
Which campaigns the bot getsEvery campaign, from day oneEvery campaign
What confirms an impressionTelegram requests the hidden link in the textThe network sends the post itself

You can switch modes at any time: paste the token on the bot’s page in the dashboard. There is no new moderation, the API key stays the same and the code does not change — the same request keeps working, and impressions start being paid at the full rate. Other ways to earn with a bot are in How to monetize a Telegram bot.

Common integration mistakes

  • Requesting the regular ad before the result. First give the person what they came for — the file, the answer, the video — and only then request the ad. That keeps the post as the last message in the chat; otherwise the result pushes it out of sight at once.
  • Changing the post. Your own text on top, trimmed lines, replaced buttons or links — and the sending is not confirmed and the post is not paid.
  • Disabling link previews. They are often switched off globally in the bot’s or the library’s defaults. For the ad message, previews must be on.
  • Sending StartPlace incorrectly. true belongs only in the /start handler. false goes after the bot has delivered its result. The same value in every call is a mistake.
  • Requests with no user action. Request an ad in response to something the person really did, not on a timer and not as a broadcast. Faking parameters is against the rules.
  • Letting the ad break the bot. Set a timeout on the request and catch errors, as the ready code does: if the network does not answer, the bot must keep working.

FAQ

Can I earn from my bot without sharing its token?

Yes. You prove ownership with a code in the bot’s About text, get an API key, and the bot requests and sends the ads itself. The BotFather token is not needed.

What is paid in the no-token mode?

Each impression whose sending Telegram confirmed, and clicks: on fixed-price click campaigns and on external ads. The bot gets every campaign of the network from the start. The rate per impression is lower than with a token.

Why must link previews stay on?

The text of the post starts with an invisible link, and Telegram requests it at the moment the message is sent. That confirms the post really went out to the user. Without previews there is no confirmation, and that post is not paid.

What happens if I add the token later?

You paste the token on the bot’s page in the dashboard. There is no new moderation, the API key stays the same, the code does not change, and impressions are paid at the full rate right away.

Which languages have ready code?

Python (aiogram), Node.js (Telegraf) and PHP — in the docs section on connecting without a token.

or in the Telegram bot @HiViewsBot