1

I've created a telegram bot. He has one mission to inform in group about new orders. When the customer create new order, telegram bot sends message with information that new order was created. I use this api: ( Chat id and token are provided as an example)

https://api.telegram.org/bot449123456:AAHSAnSGDm8PW2Z-1ZiwdVDmgv7sM3NMTxg/sendMessage?chat_id=311911234&text=Hi+Everyone

All works fine, but how can I send not a simple text( with + as a whitespace) but a big text with information about order, and order cart? I think I should use another method instead of simple call api...

Now, I am using nest js for backend, and yes, I know about telegraf and other npm packages, but because I use this bot only for send information from site, could I avoid additional packages and create a simple api call with big text? Thanks in advance.

  • Could you please post sample message you want to send? – sina.ce Feb 22 '22 at 13:56
  • I believe you can. https://core.telegram.org/method/messages.sendMessage. To make that `text` query, use [`encodeURI`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/encodeURI) – Micael Levi Feb 22 '22 at 14:18

1 Answers1

0

Thanks for you suggestion @micael-levi. I have found a method

  1. To put my text into variable
  2. To encode this variable with method encodeURIComponent
  3. To Specify in API params that it is a HTML and it should be parsed as a HTML (parse_mode=HTML)