> For the complete documentation index, see [llms.txt](https://yokifinance.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yokifinance.gitbook.io/docs/subscription-payments/for-merchant/api-integration/sending-to-telegram-group.md).

# Sending to Telegram group

This page describes how to send messages into Telegram group if merchant wants to implement this functionality as part of [API integration](/docs/subscription-payments/for-merchant/api-integration.md).

**Step 1 – create Telegram group**

You can reuse existing group or create new from scratch (recommended). We recommend to name it appropriately and set up a group picture.

**Step 2 – create a bot and get its token**

DM [@BotFather](https://t.me/BotFather), and create a new bot. You'll get bot token that looks like

```typescript
11111111111:XXXXXXXXXXXXXXXXXXXXXXXXxxxx
```

We recommend to name bot appropriately like "Subscriptions bot" or "Payments bot", whatever you like. We also recommend to set up bot's picture (open bot profile -> Edit) to make it look better in the group.

**Step 3 – add bot into the group**

This is pretty self-explanatory, just add this bot into the group you created on step 1.

**Step 4 – get chat id**

In the browser (or via CURL) open the URL&#x20;

```typescript
https://api.telegram.org/bot<token>/getUpdates
```

where you get latest bot's activity. Visually scan the updates for text like&#x20;

```json
"sender_chat":{"id":-1003057777777 , .... }
```

here "id" is the group id you need (a big negative number).

**Step 5 – send message to group**

This code in TypeScript is self-explanatory, Telegram's [sendMessage](https://core.telegram.org/bots/api#sendmessage) method is used, and lots of options are available. Here is the simplest possible case presented.

```typescript
import axios from "axios";

export const sendTelegramMessage = (botToken: string, chatId: number, msg: string) => {
  return axios.get(
    `https://api.telegram.org/bot${botToken}/sendMessage`,
    {
      params: {
        parse_mode: "HTML",
        chat_id: chatId,
        text: msg,
        disable_web_page_preview: true,
      },
    }
  );
};
```

In this case HTML markup is used, (see <https://core.telegram.org/bots/api#formatting-options>), so you can format the message any way you want.
