How to send markdown text by telegram bot using telegraf library on nodejs?
Send markdown text with telegram bot (telegraf), nodejs
Asked Answered
Hi there, looks like you're new to StackOverflow. Welcome aboard! When asking a question we expect that you provide an example of what you have tried to solve the problem with. Please provide a minimal reproducible example & check out the How to Ask Page for more info on how to create an awesome question. –
Sophister
Welcome to Stack Overflow! Other users marked your question for low quality and need for improvement. I re-worded/formatted your input to make it easier to read/understand. Please review my changes to ensure they reflect your intentions. But I think your question is still not answerable. You should edit your question now, to include your own efforts (see help me is not a question ). Feel free to drop me a comment in case you have further questions or feedback for me. –
Quillon
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)
this one is old old old, not working not –
Mathers
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' });
Can be used in more simplest way:
ctx.replyWithMarkdownV2(message)
, your code will be under the hood. –
Unciform 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)
this one is old old old, not working not –
Mathers
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'})
© 2022 - 2025 — McMap. All rights reserved.