Send markdown text with telegram bot (telegraf), nodejs

Viewed 11189

How can send markdown text by telegram bot with using telegraf library on nodejs ?

4 Answers

With telegraf v4.3.0, I got it working using the following code:

const bot = new Telegraf(token);
bot.telegram.sendMessage('my chat id', 'my text', { parse_mode: 'MarkdownV2' });
const token = 'YOUR TOKEN';
const Telegraf = require('telegraf')
const extra = require('telegraf/extra')
const markup = extra.markdown()

const telegram = new Telegraf(token)

telegram.telegram.sendMessage('there chat id', 'your message', markup)

If you are using the context object ctx in imported modules to reply and don't want to import Telegraf, then you can use:

ctx.reply('some _text_', {reply_markup: 'markdown'})
Related