Skip to content

Instantly share code, notes, and snippets.

@umidjons
Created July 13, 2018 06:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umidjons/0734272c87239f54f594655267baf4fe to your computer and use it in GitHub Desktop.
Save umidjons/0734272c87239f54f594655267baf4fe to your computer and use it in GitHub Desktop.
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