Telegram bot monetisation

Tags: Telegram, Bots, Monetisation

This article is about how to earn on telegram bot by analogy with earning on a website, with the help of advertisements sent automatically.

The adverts pass moderation but there is something like gambling which I’m not happy about, hopefully in the future you can set up filters by category.

I have a few telegram bots:

And until recently, I didn’t know how to make money from them at all.

There are various solutions – newsletters with adverts, clickers and contract advertising, but all of these are complicated and don’t generate much income unless your bot has 100,000 users or more.

Having set myself the task of monetising my designs in some way, I found a simple but convenient solution: GramAds.

If you are an experienced developer, you will understand everything. I will only say that payment is for each view: about 0.12 cents (0.0012$) per unit. Not a lot of money, but so far this is the only platform that I have found that allows you to earn in this way. Withdrawal is available from $15 with a commission of $1.5 to USDT (TRC-20) crypto wallet.

And then comes the more detailed instructions.

Connection instructions

The first step is to log in to the portal.

To do this, we enter the bot (there is a site, but the bot will have to be opened anyway). We click ‘Start’, then in the message on the button ‘Authorise ✅’ (to open through the site), or Telegram Mini App – to open inside telegram through mini apps.

And here we see the platform office:

Here you can buy adverts, or set up a bot to show ads. We will deal with the latter:

The second step is to add a bot

To do that, we’ll need a token.

The token is best never shared with anyone and you do so at your own risk. But you can’t lose your bot by sending the token to someone else, someone who has the token can just send messages on behalf of your bot. In case of misuse you can change the token and the platform’s access to the bot will be lost.

Go to @botfather – type /mybots and select the one you want. Then click API Token – you will get a token and can copy it.

Insert the token into the box on the platform and click ‘Add’

The third step is to insert the code and call for the adverts to be shown

The system is simple: it is forbidden to send adverts to all bot users in a row. It is important to show it exactly when the user has performed a useful action: he has requested something and you have replied to him. That’s when the adverts are called.

A separate method is used for this purpose:


import logging
import aiohttp

# Call this method wherever you want to show an ad,
# for example your bot just made its job and
# it's a great time to show an ad to a user

log = logging.getLogger('adverts')

async def show_advert(user_id: int):
    async with aiohttp.ClientSession() as session:
        async with session.post(
            'https://api.gramads.net/ad/SendPost',
            headers={
                'Authorization': 'Bearer yourkey',
                'Content-Type': 'application/json',
            },
            json={'SendToChatId': user_id},
        ) as response:
            if not response.ok:
                log.error('Gramads: %s' % str(await response.json()))

Inside, instead of yourkey you need to insert the token from the bot settings on the platform (gear icon).

Then execute the code when performing a useful action:

asyncio.run(adds.show_advert(message.chat.id))

Done! Ads will be sent and you will be rewarded!

21.08.2024
Михаил Гок