I need a way that converts audio messages to voice messages in a telegram bot.
can you please suggest me a way to do that in nodeJS.
If you can suggest me a way that can converts .MP3 files to .OGG files in a simple script.
You can utilise ffmpeg. Simply find a NodeJS wrapper for this command line utility.
After you have that, you can run an ffmpeg command such as ffmpeg -i input.mp3 -c:a libvorbis -q:a 4 output.ogg
to convert your input to your desired output format.
I'd recommend trying https://github.com/fluent-ffmpeg/node-fluent-ffmpeg