> For the complete documentation index, see [llms.txt](https://kravets.gitbook.io/enkanetwork/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kravets.gitbook.io/enkanetwork/examples/telegram-bot.md).

# Telegram bot

{% hint style="info" %}
[**Puregram**](https://github.com/nitreojs/puregram) **- powerful and modern telegram bot api sdk for node.js and typescript 😁**
{% endhint %}

{% code overflow="wrap" %}

```typescript
import { Telegram } from "puregram";
import { HearManager } from "@puregram/hear";
import { EnkaNetwork } from "enkanetwork";

const bot = new Telegram({
    token: "SOME_SECRET_TOKEN",
});
const hearManager = new HearManager();
const enka = new EnkaNetwork();
const UID_REGEXP = /([1,2,5-9])\d{8}/;

bot.updates.on("message", hearManager.middleware);

// if message.text contains UID
hearManager.hear(UID_REGEXP, async (context) => {
    const user = await enka.fetchUser(context.text); // we will not invent the choice of language

    return context.send(
        `${user.player.nickname}'s characters list:\n\n` +
            user.characters
                .map(
                    (character) =>
                        `${character.name} (${character.rarity} ⭐) - ${character.level} level`
                )
                .join("\n")
    );
});

// else
bot.updates.on("message", (context) =>
    context.send(
        `Hi, ${context.from.firstName}! Write your uid from the Genshin Impact correctly`
    )
);

bot.updates.startPolling().then(() => console.log("[BOT] Bot was started"));

```

{% endcode %}

<figure><img src="/files/SitphPwdCoiVFAEFOPmY" alt=""><figcaption></figcaption></figure>
