Messenger and bot ads: sponsored messages for your bot
Your Telegram, Discord or WhatsApp bot asks the ad server for an ad and gets a ready-to-post message back: text, image, a button and a tracked link.
You decide when your bot posts; the zone limits how often a chat gets one. More on bot ads.
A bot posts a sponsored message
Pick a topic. The bot sends the topic to the ad server, gets one sponsored message back and posts it with its button, the way a real Telegram bot would. Ads whose keywords match the topic win; the button goes through the ad server's click link (here: our demo landing page).
The request and the answer
This is the call the bot made for your last topic, and the JSON it got back. The bot posts text with a button button_text → url, and calls impression_url once the message is sent.
Pick a topic above.
{ }Example bot code
The zone's code tab gives you this, ready to adapt: python-telegram-bot for Telegram and discord.js for Discord. Each chat gets at most the zone's ads per chat per hour; past that the answer is empty with a retry_after.
# Python, python-telegram-bot: post a sponsored message in a chat
import requests
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
async def post_ad(bot, chat_id, topic=""):
r = requests.get("https://g2.gsrv.dev/botad.go", params={"spaceid": 12512778, "chat": chat_id, "q": topic}, timeout=5).json()
for ad in r.get("ads", []):
button = InlineKeyboardMarkup([[InlineKeyboardButton(ad["button_text"], url=ad["url"])]])
text = r["label"] + "\n" + ad["text"]
if ad.get("image"):
await bot.send_photo(chat_id, ad["image"], caption=text, reply_markup=button)
else:
await bot.send_message(chat_id, text, reply_markup=button)
requests.get(ad["impression_url"], timeout=5) # counts the impression
// Node, discord.js: the same for a Discord channel
const { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } = require('discord.js');
async function postAd(channel, topic = '') {
const u = new URL('https://g2.gsrv.dev/botad.go');
u.search = new URLSearchParams({ spaceid: '12512778', chat: channel.id, q: topic });
const r = await (await fetch(u)).json();
for (const ad of r.ads || []) {
const embed = new EmbedBuilder().setTitle(ad.title).setDescription(ad.description || ' ').setFooter({ text: r.label });
if (ad.image) embed.setImage(ad.image);
const row = new ActionRowBuilder().addComponents(new ButtonBuilder().setLabel(ad.button_text).setURL(ad.url).setStyle(ButtonStyle.Link));
await channel.send({ embeds: [embed], components: [row] });
fetch(ad.impression_url); // counts the impression
}
}
Run these formats on your own network
Every format on this page is part of the GoAdserver ad server. Talk to us about your platform.
Contact us