telegram-botnode-telegram-bot-api

Telegram bot sendMessage problem. Parse_mode='HTML' is not working


I want to send a message from Telegram Bot to user with parse_mode 'HTML' . I use node.js with telegram.bot.api. But I've got an error

I've tried to write a code without parse_mode='HTML'. And it is working. But if I only add parse_mode=''(html or markdown) node.js show me: "error: [polling_error] {}"

Wrong code:

   const chatId=msg.chat.id;
   if (msg.text=='test'){
       bot.sendMessage(chatId,'<b>TEST</b>', parse_mode='HTML');
       return;
      }
})

Working code

    const chatId=msg.chat.id;
    if (msg.text=='test'){
        bot.sendMessage(chatId,'<b>TEST</b>');
        return;
       }
})

I cant find any solution and info about parse_mode='HTML' and "error: [polling_error] {}".


Solution

  • Try sending the parse mode as on object;

    bot.sendMessage(chatId, '<b>TEST</b>', {parse_mode: 'HTML'});
    

    Git issue

    More info (Git)