Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Send an Excel file into Telegram group using node-telegram-bot-api

Send an Excel file into Telegram group using node-telegram-bot-api

import * as TelegramBot from 'node-telegram-bot-api';
import * as fs from 'fs';

const TOKEN = '<your_token_got_from_gotfather>';
const GROUP_ID = '<your_group_id>';
const FILE = './data.xlsx';

const bot = new TelegramBot(TOKEN);

bot.sendDocument(
    GROUP_ID,
    fs.readFileSync(FILE),
    {
        caption: 'Daily Report'
    },
    {
        filename: 'data.xlsx',
        contentType: 'application/application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    })
    .then(() => {
        console.log('File has been sent');
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment