First, put the script to a common location e.g. /usr/local/bin/vm-post.py
Then, point your Asterisk mail command to this script to invoke it when a voice mail is received.
For example, in FreePBX:

The script will decode the text message (as configured from Asterisk) and the voice message (stored with wav encoding).
Since Telegram only accepts the .ogg
format as voice message, the script also performs wav -> ogg
conversion with ffmpeg
.
Finally, change the telegram bot token and chat id in the tg_post_voicemail()
function.
To test, dial an extension with voicemail enabled and leave a voice message. You should be able to receive it from your telegram chat window.
If it doesn't work for you, you can inspect the log from /tmp/vm_bot.log
.
The script tries to keep things simple and avoids introducing the telegram bot python package.
Need help with "point your Asterisk mail command to this script to invoke it when a voice mail is received", cant understand how to((