Skip to content

getMyName

Use this method to get the current bot name for the given user language. Returns BotName on success.

Parameters

language_codeStringOptional
A two-letter ISO 639-1 language code or an empty string

Returns

On success, the BotName object is returned.

GramIO Usage

ts
// Get the bot's default display name (no language filter)
const 
result
= await
bot
.
api
.
getMyName
({});
console
.
log
(
result
.
name
);
ts
// Get the display name localised for Russian-speaking users
const 
ruResult
= await
bot
.
api
.
getMyName
({
language_code
: "ru" });
console
.
log
("RU name:",
ruResult
.
name
);
ts
// Read names for several locales in parallel
const [
defaultName
,
enName
,
ruName
] = await
Promise
.
all
([
bot
.
api
.
getMyName
({}),
bot
.
api
.
getMyName
({
language_code
: "en" }),
bot
.
api
.
getMyName
({
language_code
: "ru" }),
]);
console
.
log
("Default:",
defaultName
.
name
);
console
.
log
("EN: ",
enName
.
name
);
console
.
log
("RU: ",
ruName
.
name
);
ts
// Audit name coverage across supported locales
async function 
auditNames
(
locales
: string[]) {
for (const
lang
of
locales
) {
const {
name
} = await
bot
.
api
.
getMyName
({
language_code
:
lang
});
const
status
=
name
? "OK" : "MISSING";
console
.
log
(`[${
lang
}] ${
status
}: ${
name
}`);
} } await
auditNames
(["en", "ru", "de", "fr"]);

Errors

CodeErrorCause
401Unauthorized: invalid token specifiedBot token is wrong or revoked — check the BOT_TOKEN environment variable
429Too Many Requests: retry after NRate limit hit — check retry_after, use the auto-retry plugin

Tips & Gotchas

  • Both parameters are optional — pass an empty object {} for the default. Omitting language_code (or passing an empty string) returns the language-agnostic fallback name shown to users whose language has no dedicated override.
  • The name differs from the username. getMyName returns the human-readable display name (e.g. "My Awesome Bot"), not the @username handle. The @username is always fixed and accessible via getMe.
  • Returns an empty string when no locale-specific name is set. If only a default name exists and you request a specific language, the name field will be "" (the default is not automatically surfaced). Call getMyName({}) separately to read the fallback.
  • Language codes must be ISO 639-1. Valid examples: "en", "ru", "de". An empty string "" reads the language-agnostic default.
  • Locale resolution is one level deep. There is no cascading — if a Russian name is not set and you request language_code: "ru", you receive "" rather than the default name.
  • Use setMyName to update it. Read with getMyName first if you want to diff before writing.

See Also

  • BotName — return type containing the name field
  • setMyName — update the bot's display name for a locale
  • getMyDescription — get the bot's description
  • getMyShortDescription — get the bot's short description shown on the profile page
  • getMe — get the bot's identity and capability flags including @username