Yoki Finance
  • Introduction
    • What is Yoki Finance?
    • Our Values
    • $YOKI token
  • Subscription payments
    • Subscription payments gateway
    • For merchant
      • Glossary
      • How to create the subscription plan
      • Payment plan page
      • Money flows and settlement
      • Get subscription statuses
      • API integration
        • Introduction
        • Steps
        • Localhost environment
        • API brief overview
        • Sending to Telegram group
      • Data export
    • Chains and Tokens
  • Dollar-Cost-Averaging
    • Dollar-Cost-Averaging app
    • Overview
    • Architecture
    • Creating the first subscription
    • Chains and Tokens
    • Analytics
    • Fees
    • Integration
  • Social Media
    • Website
    • Twitter
    • Medium
    • Discord
Powered by GitBook
On this page
  1. Subscription payments
  2. For merchant
  3. API integration

Sending to Telegram group

PreviousAPI brief overviewNextData export

Last updated 1 year ago

This page describes how to send messages into Telegram group if merchant wants to implement this functionality as part of .

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 , and create a new bot. You'll get bot token that looks like

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

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

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

"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 method is used, and lots of options are available. Here is the simplest possible case presented.

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 ), so you can format the message any way you want.

API integration
@BotFather
sendMessage
https://core.telegram.org/bots/api#formatting-options