getMyName
Returns: BotNameOfficial docs ↗
Use this method to get the current bot name for the given user language. Returns BotName on success.
Parameters
language_codeStringOptionalA 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
| Code | Error | Cause |
|---|---|---|
| 401 | Unauthorized: invalid token specified | Bot token is wrong or revoked — check the BOT_TOKEN environment variable |
| 429 | Too Many Requests: retry after N | Rate limit hit — check retry_after, use the auto-retry plugin |
Tips & Gotchas
- Both parameters are optional — pass an empty object
{}for the default. Omittinglanguage_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.
getMyNamereturns the human-readable display name (e.g. "My Awesome Bot"), not the@usernamehandle. The@usernameis always fixed and accessible viagetMe. - Returns an empty string when no locale-specific name is set. If only a default name exists and you request a specific language, the
namefield will be""(the default is not automatically surfaced). CallgetMyName({})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
setMyNameto update it. Read withgetMyNamefirst if you want to diff before writing.
See Also
- BotName — return type containing the
namefield - 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