0

I've tried the following options, but I still see the link preview

await BOT.sendMessage(message.chat.id, uiMessage, menuOptions, {disable_web_page_preview: true })
await BOT.sendMessage(message.chat.id, uiMessage, menuOptions, { parse_mode: 'Markdown'})
await BOT.sendMessage(message.chat.id, uiMessage, menuOptions, { parse_mode: 'Markdown', disable_web_page_preview: true })
await BOT.sendMessage(message.chat.id, uiMessage, menuOptions, [{ parse_mode: 'Markdown'}, {disable_web_page_preview: true }])
0stone0
45.5k6 gold badges54 silver badges82 bronze badges
asked Oct 18, 2023 at 10:46

1 Answer 1

1

The disable_web_page_preview is part of the options parameter.

Looking at the sendMessage documentation:

chatId Number|String Unique identifier for the target chat or username of the target channel (in the format @channelusername) 
text String Text of the message to be sent 
[options] Object Additional Telegram query options

So you should extend menuOptions to also include disable_web_page_preview:

await BOT.sendMessage(message.chat.id, uiMessage, {disable_web_page_preview: true })

A litte snippet to test this:

const TelegramBot = require('node-telegram-bot-api');
const token = 'xxxxxxxx:AAEjLUL8Lx67lYEA3B2O7lSVhlCio3SVR9k';
const chatId = 12345678;
const bot = new TelegramBot(token, { polling: false });
bot.sendMessage(chatId, 'Link Test');
bot.sendMessage(chatId, '[Foo Bar](https://github.com/FFmpeg/FFmpeg)', { parse_mode: 'MarkDown', disable_web_page_preview: false });
bot.sendMessage(chatId, '[Foo Bar](https://github.com/FFmpeg/FFmpeg)', { parse_mode: 'MarkDown', disable_web_page_preview: true });

Shows as: enter image description here

answered Oct 18, 2023 at 10:51
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.