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.
@Balrokmg Your log shows the script is invoked, but unable to send the message - possibly due to incorrect bot token and/or chat id. Try to validate them with a vanilla python script.
IMO the email system is irreverent here, because the script is forwarding SMS via telegram, not via email.