Sensever bots: moving from Telegram

SENSEVER

The official Sensever channel: guides and API documentation for Chat, Requests, Flow, Studio, bots and messaging channels.

5 мин чтения

Sensever bots: moving from Telegram

If you have a Telegram bot, you can run it in Sensever almost unchanged: Sensever understands the Telegram Bot API. This article is a step-by-step migration plan and a list of what works differently.

Step 1. Create a bot in Sensever

The bots window plays the role of BotFather: Chats → "Create" → "Bot". As in Telegram, the username ends in _bot; if your Telegram bot's name is free in Sensever, take the same one. Save the b1.… token and the webhook secret.

BotFather

Sensever

/newbot

"Create" → "Bot"

/token, /revoke

"Actions" → "New token"

/setdescription, /setabouttext

"Actions" → "Description" or setMyDescription, setMyShortDescription

/setuserpic

"Actions" → "Avatar"

/setcommands

setMyCommands

/setprivacy

"Actions" → "Privacy in groups"

/setinline

"Actions" → "Inline mode"

/deletebot

"Actions" → "Remove bot"

/setjoingroups

None: a group admin adds the bot to the group

/setinlinefeedback

Not needed: chosen_inline_result always arrives

Step 2. Build the token for your library

Telegram libraries check the token format <number>:<string>. Build it from the bot_id and the part of the token after b1.:

curl -s https://api.sensever.com/v1/chat/bot/me -H "Authorization: Bearer b1.AbCd…"
# {"id":"812",...}  →  token for the library: 812:AbCd…

Step 3. Change the base URL

Library

Setup

aiogram 3

Bot(token, session=AiohttpSession(api=TelegramAPIServer.from_base("https://api.sensever.com")))

python-telegram-bot

Application.builder().token(token).base_url("https://api.sensever.com/bot").base_file_url("https://api.sensever.com/file/bot").build()

grammY

new Bot(token, { client: { apiRoot: "https://api.sensever.com" } })

Telegraf

new Telegraf(token, { telegram: { apiRoot: "https://api.sensever.com" } })

An aiogram 3 example:

from aiogram import Bot, Dispatcher
from aiogram.client.session.aiohttp import AiohttpSession
from aiogram.client.telegram import TelegramAPIServer
from aiogram.filters import CommandStart
from aiogram.types import Message

session = AiohttpSession(api=TelegramAPIServer.from_base("https://api.sensever.com"))
bot = Bot("812:AbCd…", session=session)
dp = Dispatcher()


@dp.message(CommandStart())
async def start(message: Message):
    await message.answer("Hi! I'm running on Sensever.")


@dp.message()
async def echo(message: Message):
    await message.answer(message.text or "Got your file")


dp.run_polling(bot)

Step 4. Check what you use

The adapter supports the core methods: updates and webhook, sending text and files, editing and deleting, polls, reactions, "typing…", inline buttons and the keyboard, commands, descriptions, inline mode and basic group administration. The full list with parameters is in "Bot API: Telegram-compatible adapter". Methods outside the list return 404, and the library throws an exception: find such calls in advance.

Common places you will need to change:

In Telegram

In Sensever

sendMediaGroup

Send files one at a time or with the native API: up to 10 files in one message

forwardMessage, copyMessage

Not available. To send the same file, use its file_id

sendLocation, sendVenue, sendContact, sendSticker, sendDice, sendVideoNote

Not available

editMessageCaption, editMessageMedia

Not available; text and buttons can be changed

pinChatMessage

Not available: neither people nor bots can pin messages yet

getChatMember, getChatAdministrators, getChatMemberCount

Not available

promoteChatMember, setChatTitle, setChatPhoto, invite links

Not available: the owner and human admins manage these

answerWebAppQuery, sendData in a Mini App

Not available: send a message from the server

Payments (sendInvoice, Stars), games, stickers, business mode

Not available

entities in requests and responses

Use parse_mode; incoming text arrives without markup

switch_inline_query, login_url, pay buttons

Not available: only callback_data, url, web_app

Quiz polls, multiple-answer polls, anonymous polls

Not available: only a regular single-answer poll, not anonymous

Commands for chat, chat_member, all_group_chats

Only default and all_private_chats

Step 5. Account for data differences

  • chat.id is the conversation number in Sensever, not in Telegram. Saved chat_id values from Telegram will not work: conversations with people start over.

  • from.id is the person's number in Sensever. You cannot link Telegram and Sensever accounts by id.

  • A group has the type supergroup; there is no group type.

  • message_reaction arrives separately for each change: one reaction in new_reaction or in old_reaction.

  • An empty allowed_updates in Sensever enables all types, including chat_member and message_reaction, which Telegram does not send by default.

  • reply_to_message contains only message_id, chat and date. To read the full original message, use the native API: GET /v1/chat/threads/{chat_id}/messages/{message_id}.

  • Text can be up to 16,384 characters instead of 4096.

  • A Mini App opens in a new browser tab, and the data is signed with the webhook secret, not the token.

Step 6. Launch

  1. Start the bot with the new settings. If the bot uses a webhook, call setWebhook with your URL: updates will arrive in Telegram format with the X-Telegram-Bot-Api-Secret-Token header.

  2. Open a chat with the bot in Sensever and tap "Start".

  3. Check the delivery log in the bot menu and getWebhookInfo.

  4. Share a link to the bot: https://sensever.com/@shop_bot, or with a parameter: https://sensever.com/@shop_bot?start=from_telegram.

What the native API adds

The adapter covers what Telegram has. Sensever features that Telegram lacks or implements differently are available through the native Bot API: up to 10 files in one message, large file uploads, replying to website visitors in project requests with handover to an agent, reading conversation history, and mentioning members. One bot can use both APIs at the same time.

Комментарии

Авторы