Telegram

How to Get User Info from a Telegram Bot: What You Can Access in 2026

ByYousof Zalipour·Updated Nov 17, 2026·19 min read
How to Get User Info from a Telegram Bot: What You Can Access in 2026

To get user info from a Telegram bot, read the User object Telegram attaches to every incoming update inside the from_user field. That object gives you the account numeric ID, first name and, when available, last name, username, language code and Telegram Premium status right away.

Anything beyond those basics, such as a phone number, a bio, a location or a profile photo, requires either a separate method like getChat or getUserProfilePhotos, or a direct tap from the user. This guide covers every field you can read, working Python code for each method and the privacy limits you need to build around in 2026.

What User Info Can a Telegram Bot Access

Telegram passed one billion monthly active users in March 2025, so a single bot can meet people from many countries, languages and privacy habits. That scale is the reason Telegram hands bots only a narrow slice of profile data by default. Everything a bot learns about a person falls into one of two groups: data Telegram sends automatically with every message, and data the person has to hand over on purpose.

The automatic part is the User object. These are its fields:

FieldWhat it containsAlways present?Typical use
idUnique numeric identifier of the accountYesPrimary key in your database
is_botWhether the account is a botYesFiltering out other bots
first_nameThe first name on the profileYesGreetings and display
last_nameThe last name on the profileNoFull display name
usernameThe public @usernameNoMentions, never as a key
language_codeLanguage tag of the user’s app, such as en or deNoLocalizing replies
is_premiumMarks a Telegram Premium accountOnly sent when trueSegmenting your audience

Two details trip people up. Last name and username are optional, so your code has to cope with their absence. And is_premium simply does not appear for regular accounts, so a missing value means false. You may also spot added_to_attachment_menu on the User object when someone installs your bot into their attachment menu, along with capability flags in the official docs such as can_join_groups or has_main_web_app. Telegram returns those capability flags only when your bot calls getMe on itself, never for regular human visitors.

What a Telegram Bot Cannot See

A bot cannot read a person’s phone number unless they share it, and it has no access to their email address, contact list, last seen time or messages from other chats. It also cannot look up people who have never interacted with it. Telegram designed the Bot API this way on purpose, and planning around these limits early when you develop a Telegram bot saves you from rebuilding later.

Standard bot updates also hide the person’s IP address and physical location. Because every message passes through Telegram’s servers before reaching your webhook or polling loop, your server talks only to Telegram. You see an IP address only when someone opens your Mini App or clicks an external web link, and you receive GPS coordinates only when they tap a location sharing button in a private chat.

TELEGRAM BOT API ARCHITECTURE
Three Layers of Telegram Bot User Data in 2026

How Telegram separates automatic profile fields from extra requests and explicit user approval

LAYER 1AUTOMATIC
Incoming Update
message.from_user
Numeric ID: Always sent, store as 64 bit bigint
Profile Names: First name guaranteed, last name optional
Username: Optional handle, unsafe as primary key
Locale and Tier: App language_code and is_premium
LAYER 2EXTRA CALL
Profile Lookups
getChat & getUserProfilePhotos
Avatar List: Up to 100 photos across multiple sizes
Bio and Birthdate: Returned inside ChatFullInfo if public
Personal Channel: Linked public channel on profile
Business Info: Work hours, intro and location fields
Blocked by Design: Email Address Contact List Last Seen Time Messages in Other Chats Chat IP Address
Overview of automatic, fetched and user approved fields available through the Telegram Bot API.

Which Method Returns Which Data

DataMethod or sourceWhat it requires
ID, name, username, language, Premium flagfrom_user on an incoming updateThe person messaged or tapped something in your bot
Profile photosgetUserProfilePhotosThe user ID
Bio, birthdate and other profile extrasgetChatA user who has interacted with your bot
Phone numberContact button with request_contactThe person taps the button and agrees
A user chosen from the person’s own chatsRequest users buttonThe person picks someone in the native picker
Membership status in a groupgetChatMemberThe bot is in the group and you know the user ID
Mini App visitorinitData from the Mini AppServer side signature check

How a Telegram Bot Receives User Info

Every action a person takes toward your bot, such as sending a message, tapping a button or opening a link, reaches your bot as an update. Your bot receives updates in one of two ways: long polling, where your code keeps asking Telegram for new updates, or a webhook, where Telegram posts each update to a URL you control. Polling is simpler for development and small bots, while a webhook suits production servers. Either way the update carries the same user data. This guide assumes you have already created a bot with BotFather and have its bot token ready.

How to Get User Info from a Telegram Bot Using Python

I used aiogram 3 for the examples because it is asynchronous, actively maintained and easy to read. Many older tutorials were written for synchronous libraries, and code copied from them often fails on current versions. Install the library first:

bash

pip install aiogram

This bot replies to /start with everything the User object contains:

python

import asyncio
from aiogram import Bot, Dispatcher
from aiogram.filters import CommandStart
from aiogram.types import Message

bot = Bot(token="YOUR_BOT_TOKEN")
dp = Dispatcher()


@dp.message(CommandStart())
async def handle_start(message: Message):
    user = message.from_user
    if user is None:
        return
    username = f"@{user.username}" if user.username else "not set"
    lines = [
        f"User ID: {user.id}",
        f"First name: {user.first_name}",
        f"Last name: {user.last_name or 'not set'}",
        f"Username: {username}",
        f"Language code: {user.language_code or 'unknown'}",
        f"Premium: {bool(user.is_premium)}",
    ]
    await message.answer("\n".join(lines))


async def main():
    await dp.start_polling(bot)


if __name__ == "__main__":
    asyncio.run(main())

The key line is message.from_user. It holds the sender of the message. The guard for None matters because some update types, such as posts in a channel, have no personal sender at all.

Watch out for inline keyboard buttons as well, because they cause a classic bug. Inside a CallbackQuery handler, callback.message.from_user points to your own bot as the author of the message holding the button. Always read callback.from_user instead so you capture the person who actually tapped it:

from aiogram.types import CallbackQuery

@dp.callback_query()
async def handle_button(callback: CallbackQuery):
user = callback.from_user
await callback.answer(f”Tapped by {user.first_name} ({user.id})”)

LIVE UPDATE SIMULATION
What Telegram Sends vs What Your Python Bot Replies
UI
User Inspector Bot
bot
/start
User ID: 6194028512
First name: Clara
Last name: not set
Username: @claradev
Language code: en
Premium: True
Raw Payload Inside message.from_user
{
  “id”: 6194028512,
  “is_bot”: false,
  “first_name”: “Clara”,
  “username”: “claradev”,
  “language_code”: “en”,
  “is_premium”: true
}
Key takeaway: Because Clara has no last name on her profile, Telegram omits last_name from the JSON completely instead of sending an empty string, and your Python fallback prints not set safely.
Side by side view of the incoming User object and the formatted aiogram 3 reply.

Handle a Missing Username or Last Name

Three habits keep your data clean:

  1. Use the numeric ID as the identifier in your database, never the username.
  2. Treat username and last name as optional display data.
  3. Refresh the stored values each time the person writes again, because names and usernames change.

A small helper keeps greetings tidy when parts of the name are missing:

python

def display_name(user):
    parts = [user.first_name, user.last_name]
    return " ".join(part for part in parts if part) or "there"

Do the Same with the Raw Bot API

If you work in another language or want to see what libraries do underneath, call the Telegram API directly over HTTP. This request asks for the profile of a user who has already talked to your bot:

python

import requests

TOKEN = "YOUR_BOT_TOKEN"
USER_ID = 123456789

url = f"https://api.telegram.org/bot{TOKEN}/getChat"
response = requests.get(url, params={"chat_id": USER_ID}, timeout=10)
print(response.json())

The response contains the fields the user has filled in. If Telegram answers with a “chat not found” error, that person has never started your bot, or the ID is wrong.

How to Get a User ID and Username in a Telegram Bot

In a private chat the chat ID and the user ID are the same number, but in a group the chat ID belongs to the group. Always read the person from from_user.id rather than from the chat. User IDs can be larger than 32 bits, in fact they can use up to 52 significant bits, so store them in a 64 bit integer column such as bigint. A smaller type will eventually corrupt your data.

As Lukas Lindqvist, a backend messaging architect who manages high volume Telegram bots, puts it: “Two mistakes break growing bots faster than anything else. First, storing user IDs in a standard 32 bit integer column fails the moment an account ID crosses 2,147,483,647, which covers almost every newer Telegram user today. Second, calling getChat or getUserProfilePhotos live on every message burns right through Telegram’s 30 requests per second global rate limit and triggers HTTP 429 blocks. Read from_user off the update for free, cache extra profile fields in Redis or Postgres and refresh them once a day at most.”

Usernames behave differently. People can change them, remove them or lose them to someone else, which makes them poor identifiers. They are fine for mentioning someone in a reply.

The question that comes up most often is how to turn a username into an ID. The Bot API does not resolve a personal username into a user ID, so you capture the ID at the moment the person interacts with your bot. Two reliable ways to do that:

  • A start link. Share a link such as https://t.me/YourBotName?start=spring_campaign. When someone opens it and presses Start, your bot receives their ID together with the text after start=, which can be up to 64 characters long. That tag also tells you which campaign or channel the person came from.
  • A user picker button. A keyboard button of the request users type opens Telegram’s own picker. The person chooses an account and your bot receives the chosen ID, with no guessing involved.

You might see scripts online using Telethon or Pyrogram to look up a username directly. That difference comes down to Telegram Bot API vs MTProto, since those libraries connect through the client protocol rather than standard HTTP bot endpoints. Running automated lookups on a personal account triggers strict flood waits and often gets the account banned, so production bots stick to start links and the native picker instead.

Get More User Data: Profile Photo, Bio, Phone Number and User Picker

Once your bot captures a person’s numeric ID, you can pull richer details beyond basic names and language tags. Profile photos and bios come from extra Bot API calls using that ID, while options such as phone numbers and contact picks require the person to tap a dedicated keyboard button. Because user privacy settings control most of these fields, your handlers should always expect empty results.

Profile Photo with getUserProfilePhotos

This method returns a list of the person’s profile photos, in several sizes each. You can request between 1 and 100 photos per call.

python

from aiogram.filters import Command


@dp.message(Command("photo"))
async def send_profile_photo(message: Message):
    photos = await bot.get_user_profile_photos(message.from_user.id, limit=1)
    if photos.total_count == 0:
        await message.answer("No profile photo found.")
        return
    sizes = photos.photos[0]
    largest = max(sizes, key=lambda size: size.width)
    await message.answer_photo(largest.file_id)

An empty result is normal. Some people have no photo, and others restrict who can see it.

Bio and Birthdate with getChat

For a private chat, getChat returns extra profile details such as the bio, a birthdate, a linked personal channel and an emoji status. Each of these appears only when the user has set it, and what you see can depend on the person’s privacy settings and on your library version.

python

@dp.message(Command("about"))
async def show_bio(message: Message):
    chat = await bot.get_chat(message.from_user.id)
    await message.answer(f"Bio: {chat.bio or 'no bio set'}")

Treat this data as a bonus rather than something your bot depends on. In current Bot API releases and aiogram 3, getChat returns a ChatFullInfo object rather than a basic Chat record. Alongside bio and birthdate, ChatFullInfo can expose has_private_forwards and, for Telegram Business accounts, fields like business_intro, business_location and business_opening_hours. Avoid calling getChat on every incoming message, because extra HTTP requests slow replies down and trigger HTTP 429 rate limit errors during traffic spikes. Fetch it once during onboarding, store what you need and refresh it only occasionally.

Phone Number with a Contact Button

A bot gets a phone number only when the person taps a button that shares their contact. Ask for it only when a feature really needs it.

python

from aiogram import F
from aiogram.types import KeyboardButton, ReplyKeyboardMarkup


@dp.message(Command("share"))
async def ask_for_phone(message: Message):
    keyboard = ReplyKeyboardMarkup(
        keyboard=[[KeyboardButton(text="Share my phone number", request_contact=True)]],
        resize_keyboard=True,
        one_time_keyboard=True,
    )
    await message.answer("Tap the button below to share your number.", reply_markup=keyboard)


@dp.message(F.contact)
async def save_contact(message: Message):
    contact = message.contact
    if contact.user_id != message.from_user.id:
        await message.answer("Please share your own contact, not someone else's.")
        return
    await message.answer("Thanks, I received your number.")

The comparison of contact.user_id with the sender’s ID is easy to forget. Without it, a person can forward someone else’s contact card and your bot would store a number that belongs to a different human.

User Picker with KeyboardButtonRequestUsers

When your bot needs details about a second account, such as gifting a plan to a friend or assigning a role, use KeyboardButtonRequestUsers. Telegram opens a native contact selector, and once the person confirms their choice, your bot receives a UsersShared update. Current Bot API versions let you request the chosen account’s name, username and profile photo right inside the payload, even if that second person has never interacted with your bot.

from aiogram.types import KeyboardButtonRequestUsers

@dp.message(Command(“pick”))
async def ask_for_user(message: Message):
picker = KeyboardButtonRequestUsers(
request_id=1,
user_is_bot=False,
max_quantity=1,
request_name=True,
request_username=True,
request_photo=True,
)
keyboard = ReplyKeyboardMarkup(
keyboard=[[KeyboardButton(text=”Select a friend”, request_users=picker)]],
resize_keyboard=True,
one_time_keyboard=True,
)
await message.answer(“Choose a user from the list.”, reply_markup=keyboard)

@dp.message(F.users_shared)
async def handle_picked_user(message: Message):
picked = message.users_shared.users[0]
name = picked.first_name or “Unknown”
await message.answer(f”Selected ID: {picked.user_id} ({name})”)

Location with a Location Button

Delivery bots, local directories and store finders often need coordinates. In a private chat, a keyboard button with request_location sends the device’s current latitude and longitude once the user confirms the prompt. Telegram restricts this button to private chats, so it will not work inside groups.

@dp.message(Command(“nearby”))
async def ask_for_location(message: Message):
keyboard = ReplyKeyboardMarkup(
keyboard=[[KeyboardButton(text=”Share my location”, request_location=True)]],
resize_keyboard=True,
one_time_keyboard=True,
)
await message.answer(“Share your location to see nearby options.”, reply_markup=keyboard)

@dp.message(F.location)
async def save_location(message: Message):
loc = message.location
await message.answer(f”Coordinates received: {loc.latitude}, {loc.longitude}”)

How to Get User Info from a Telegram Bot in Groups and Channels

Groups work differently from private chats because your bot does not see everything by default. A new bot runs with privacy mode on, which means it receives commands, mentions and replies to its own messages, but not ordinary conversation. You can turn privacy mode off in BotFather or make the bot an administrator, and then it sees every message along with its sender.

To check a specific person, call getChatMember with the group ID and the user ID:

python

@dp.message(Command("status"))
async def member_status(message: Message):
    member = await bot.get_chat_member(chat_id=message.chat.id, user_id=message.from_user.id)
    await message.answer(f"Your status here: {member.status}")

The status tells you whether the person is a creator, administrator, member, restricted, left or kicked.

If your bot is an administrator, you can include chat_member in the allowed updates and your bot will be told about joins, departures and role changes together with user data. Groups and channels that require approval add one more useful event: the join request. The update contains the requester’s details and a user_chat_id, and your bot can message that person through it for a short window (five minutes at the time of writing), even though they never started a conversation with the bot. This is a good moment for a short welcome or a rules reminder.

Watch for one quirk in groups that use anonymous administrators or linked channel discussions. When an admin posts anonymously, Telegram hides their personal profile and fills message.from_user with a placeholder service account while placing the group or channel identity inside message.sender_chat. Check message.sender_chat first in moderation handlers so your bot does not log or mute a placeholder ID.

Channels need a separate note. Posts in a channel come from the channel itself, so there is no personal sender, and the Bot API gives you the number of members but not the list. A bot cannot pull the subscriber list of a channel, whatever some tools promise.

How to Get User Info from a Telegram Mini App

When someone opens your Mini App, the page receives initData, a signed string that includes the user’s ID, name, username, language code and a timestamp. The JavaScript object called initDataUnsafe shows the same values already parsed, and the name is honest, because anyone can fake those values in a normal browser. Never base a decision on them.

Send the raw initData string to your server and verify the signature with your bot token before you trust a single field:

python

import hashlib
import hmac
import time
from urllib.parse import parse_qsl


def is_valid_init_data(init_data, bot_token):
    pairs = dict(parse_qsl(init_data, keep_blank_values=True))
    received_hash = pairs.pop("hash", "")
    if time.time() > int(pairs.get("auth_date", "0")) + 86400:
        return False
    check_string = "\n".join(f"{key}={pairs[key]}" for key in sorted(pairs))
    secret = hmac.new(b"WebAppData", bot_token.encode(), hashlib.sha256).digest()
    expected = hmac.new(secret, check_string.encode(), hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, received_hash)

The function rejects data older than a day, which stops someone from replaying a captured string. When you connect a Telegram bot to a website, the Telegram Login Widget serves the same purpose and relies on a similar signed payload. Beyond the standard bot fields, the verified user JSON inside initData also provides photo_url for rendering avatars directly in your interface and allows_write_to_pm, which tells you whether your bot has permission to message that visitor privately. Recent Bot API updates also include an Ed25519 cryptographic signature field alongside hash, allowing external backend services to validate initData against Telegram’s public key without holding your secret bot token.

DEVELOPER CHEAT SHEET
Which Field Holds the Real User Across Telegram Surfaces
1Private Chat
message.from_user.id

Equals chat.id in one to one chats. Best place to capture start link attribution tags.

2Inline Button Tap
callback.from_user.id

Skip callback.message.from_user because that field points to your own bot account.

3Group Chat
from_user or sender_chat

Disable Privacy Mode in BotFather first, and check sender_chat for anonymous admins.

4Mini App
Verified raw initData

Validate the HMAC or Ed25519 signature on your backend before trusting browser data.

Reference guide for reading verified user identifiers across private messages, callbacks, groups and Mini Apps.

Common Problems When You Get Telegram User Info

ProblemLikely causeFix
Username is NoneThe person has not set a public usernameUse the ID and first name instead
Last name is NoneThe field is optionalBuild the display name from the parts that exist
“chat not found” from getChatThe person never started your bot, or the ID is wrongWait for them to message the bot or send them a start link
“bot can’t initiate conversation with a user”Your bot tried to write firstLet the person start the chat
“bot was blocked by the user”The person blocked the botMark them inactive and stop sending
Import errors from copied codeThe tutorial targets an older library versionFollow the documentation of the version you installed
Corrupted or rejected IDs in your databaseA 32 bit columnSwitch to bigint
Group messages never arrivePrivacy mode is onTurn it off in BotFather or make the bot an administrator

How to Store Telegram User Data Responsibly

If any of your users live in the European Union, the GDPR applies to you wherever you are based, and Telegram data counts as personal data. Regulators can fine the most serious breaches up to 20 million euros or 4 percent of worldwide annual turnover, whichever is higher. This is general information, not legal advice, but a few habits cover most of the risk:

  • Collect only what a feature needs. A greeting in the right language needs language_code, not a phone number.
  • Tell people what you store and why, for example in a /privacy command and in the bot description.
  • Ask for consent before requesting sensitive items such as a phone number, and keep a record of it.
  • Set a retention period and delete a person’s data when they ask. The GDPR calls this the right to erasure.
  • Keep your bot token out of logs, repositories and screenshots, because whoever holds it can read everything your bot receives.

Real Use Cases for Telegram User Info

Use caseData you needHow you get it
Personal welcome messagefirst_namefrom_user on /start
Replies in the visitor’s languagelanguage_codefrom_user
Support deskid, username if present, message textfrom_user, with the ID as the ticket owner
Campaign attributionStart parameter and IDA start link per campaign
Lead form with a phone numberPhone numberContact button with clear consent
Group moderationid and statusgetChatMember and chat_member updates
Mini App sign inVerified user objectServer side initData check

Many people who ask this question have a commercial reason. They want to know who their audience is before spending money on growing it. Language codes show which markets actually engage, and start links show which campaign brought each bot visitor in. Teams that track Telegram subscribers with UTM links apply the same attribution logic to judge whether growth spending on a channel or a bot is paying off.

FAQ: How to Get User Info from a Telegram Bot

Can a Telegram bot get a user’s phone number?

Not automatically. A bot receives a phone number only when the person taps a contact button and agrees to share it. Check that the contact belongs to the sender before you store it.

Can a bot get a user ID from a username?

The Bot API does not turn a personal username into a user ID. Capture the ID when the person starts your bot, opens a start link or picks an account with the user picker button, and store it from then on.

Can a bot get info about someone who never messaged it?

Not in any useful way. A bot learns about a person when they message it, tap its button, open a link to it, join a group or channel where it is an administrator or send a join request. Without one of those events your bot has no identifier to look anyone up with.

Can a bot see a user’s bio and profile photo?

Often yes, when the user has set them. The photo comes from getUserProfilePhotos and the bio from getChat. Both can be empty, and privacy settings can limit what your bot sees.

Does the user know what a bot collects?

Telegram shows people the bot’s name and description, not a list of the fields it reads, so honesty has to come from you. Explain what you store and why, and give people a way to have it deleted.

Is it legal to store Telegram user data?

It can be, as long as you follow the rules that apply to you. In the European Union that means a clear purpose, minimal data, consent where needed and deletion on request. If you handle sensitive data or operate at scale, ask a lawyer who knows your market.

Can a Telegram bot see my IP address?

Not when you simply chat with it or tap chat buttons, because all messages route through Telegram’s servers. A bot operator can see your IP address only if you open a Mini App or click an external link that loads a web page on their server.

Can a Telegram bot track a user’s location?

Only with explicit permission in a private chat. The person has to tap a location button and confirm the prompt on their device, or manually send a location pin to the bot.

Final Thoughts on How to Get User Info from a Telegram Bot

Learning how to get user info from a Telegram bot comes down to knowing three layers: the automatic User object on every update, the extra methods such as getChat and getUserProfilePhotos, and the data people share on purpose through buttons and Mini Apps. Build on the numeric ID, treat everything else as optional, ask for sensitive details only when a feature truly needs them and verify Mini App data on your server. If you also want to grow a channel or bot audience and would like to talk it through, you can reach our team on Telegram at @membertelsupport.

Yousof Zalipour — Founder & Telegram Systems Architect at MemberTel
Yousof Zalipour

Founder & CEO of MemberTel (est. October 2019 in Dubai, UAE; directing engineering and operations from Istanbul, Turkey). Leads Telegram engagement architecture, pacing protocols, AI moderation bots, and quantitative channel auditing systems.


RECOMMENDED PRODUCTS

Yousof Zalipour — Founder & CEO at MemberTel

✓ MemberTel Research & Editorial Desk

Published:

• Category:

,

• Editorial & Research Policy

Reader Comments & Technical Discussion (0)

Editorial Moderation Active • Community Q&A

No reader comments have been published on this guide yet. Have a question about Telegram channel growth, pricing, or retention benchmarks? Share your question below and our editorial engineering desk will reply here.

Leave a Reply

Your email address will not be published. Required fields are marked *

Join the Technical Discussion

Have a question about Telegram retention ratios, bot setup, or channel growth? Ask below—every comment is reviewed by our editorial desk to keep discussions spam-free.