Bots like on Telegram — migration, inline, payments
MRIYU's Telegram-compatible Bot API: how to move a bot from Telegram, inline mode, buttons, Mini Apps and payments in coupons.
Besides its own Bot API (see Bot API), MRIYU has a Telegram-compatible layer: requests like https://<service address>/bot<TOKEN>/<method> with the same methods and updates as Telegram. A bot written for Telegram usually moves over by changing the API address and the token.
How to move a bot
- Create a bot with
@mriyu_father— how to — and take its token. - In your library, replace the base API address with the address of the MRIYU Bot API service (shown in the developer cabinet, the bot's "Connection" tab):
- python-telegram-bot, aiogram —
base_url/TelegramAPIServer; - node-telegram-bot-api —
baseApiUrl; telegraf and grammY —apiRoot; - plain HTTP requests — just a different host.
- python-telegram-bot, aiogram —
- Updates work as on Telegram:
getUpdateswithoffsetandtimeout, orsetWebhook(theX-Telegram-Bot-Api-Secret-Tokenheader ifsecret_tokenis set). - The person must tap "Start" — until then the bot can't write to them.
What works
| Feature | Methods and updates |
|---|---|
| Messages | sendMessage (HTML, Markdown, MarkdownV2), editMessageText, editMessageCaption, editMessageReplyMarkup, deleteMessage, sendPhoto, sendDocument, sendVideo, sendAudio, sendVoice, sendLocation, sendContact, getFile |
| Buttons | inline_keyboard (callback_data, url, web_app), answerCallbackQuery (text, show_alert window, link), keyboard under the input field, ReplyKeyboardRemove, ForceReply, sendChatAction ("typing…") |
| Groups and channels | getChat, getChatAdministrators, getChatMemberCount, banChatMember, leaveChat, pinChatMessage, exportChatInviteLink, promoteChatMember |
| Mini Apps | web_app button, setChatMenuButton, Telegram.WebApp (initData, MainButton, BackButton, haptics, popups), web_app_data |
| Inline mode | inline_query, answerInlineQuery, chosen_inline_result |
| Payments | sendInvoice, pre_checkout_query, answerPreCheckoutQuery, successful_payment, refundStarPayment |
| Profile | setMyName, setMyDescription, setMyShortDescription, setMyCommands, getMyCommands |
Inline mode
A person types @weather_bot kyiv in any chat, the bot receives inline_query, answers with answerInlineQuery, and the person picks a result from the list.
- Turn it on in the developer cabinet or with
/setinlinein@mriyu_father(the input hint is set there too). - Supported results are
article(titleandinput_message_content.message_text) andphoto(an httpsphoto_url), up to 50, withcache_timeandnext_offset. - The chosen result is sent as an ordinary message from the person with a "via @bot" line; the bot gets
chosen_inline_result. - There are no buttons on inline results and no gif/video results yet.
- The person agrees once that their query goes to the bot.
Payments in coupons
A bot can send an invoice in a private chat. The currency is MRIYU coupons (the site's internal currency, not money); on Telegram that corresponds to Stars.
- The bot calls
sendInvoice:title(up to 32 characters),description,payload,currency—XTRorKUNY,prices(theamounttotal is in coupons).provider_tokenisn't needed. - An invoice card with a "Pay" button appears in the chat.
- The bot receives
pre_checkout_queryand must answer withanswerPreCheckoutQuerywithin 15 seconds; with no answer the payment is cancelled. - After
ok, coupons are taken from the person and go to the bot's owner (minus the site's fee), and the bot getssuccessful_paymentwithtelegram_payment_charge_id. - A payment can be refunded with
refundStarPayment— the person gets the full amount back, and the bot's owner must have enough coupons.
Payments work when monetization is turned on for the site. Administrators can switch bot payments off entirely: then sendInvoice returns a 403 error and unpaid invoices can't be paid. Coupons can't be topped up with money in apps from Google Play — there they can only be spent.
How it differs from Telegram
- Payments are coupons only and only in private chats.
- Mini Apps are available only to bots owned by site administrators; the window opens over https from a foreign domain (not
mriyu.com). - Groups have only the owner, admin and member roles: no persistent bans, per-admin rights, join requests or
chat_memberupdates;restrictChatMemberandsetChatPermissionsaren't supported. - No
sendPoll,sendSticker,sendMediaGroup,forwardMessage,copyMessage,editMessageMedia, or command scopes and languages. - Group and channel IDs in this API are negative, as on Telegram;
file_ids are valid only on MRIYU. - Limits: 30 messages per second per bot and 20 per minute to one person; updates are kept for 24 hours.
See also: Bot API, MRIYU Father, Bots.