Skip to content

Integrating Ads into Your Telegram Bot

After your block is created and approved, you can start showing ads in your Telegram bot.

Step 1 — API Request

Send a GET request to:
https://api.adsgram.ai/advbot?tgid={TELEGRAM_USER_ID}&blockid={BLOCK_ID}

  • tgid — Telegram user ID
  • blockid — your Ad Block ID (from dashboard)

IMPORTANT

Use only the numeric part of the blockid, without the bot- prefix.

Step 2 — Handling the Response

The API returns:

JSON
{
  "text_html": "<a href='...'>Title</a>\nТекст\nРеклама. 18+",
  "click_url": "https://...",
  "button_name": "Go!",
  "image_url":"https://..."
}

Step 3 — Send the Ad

Use the returned data to build your message:

  • text_html → message text (HTML format)
  • image_url → ad image
  • button_name + click_url → inline button
  • ParseMode = HTML

✅ Example implementation available in previous section.

IMPORTANT

  • text_html contains HTML tags. Always set ParseMode.HTML in your bot framework.
  • Ad messages sent via the bot must not be forwardable.
    You should use Telegram message types that prevent forwarding, such as sendPhoto or sendMessage with the protect_content=True parameter in the Telegram API.

Multilingual Bots

If your bot supports multiple languages, you can specify the desired language in the ad request using the language parameter.

Example request with language:
https://api.adsgram.ai/advbot?blockid=123&tgid=123&language=en

If the language parameter is included, AdsGram will serve ads in the specified language.
If the parameter is missing, the system will fallback to the language detected from the Telegram interface.


✅ Done — your bot can now natively display ads from AdsGram.