'How to view, listen to, and download WhatsApp voice messages
I am trying to build a WhatsApp bot to collect voice messages sent in by users on Twilio. They do not need to be transcribed, just received and downloaded.
I can send and view media messages (photos and videos) sent on WhatsApp to my twilio number, but I am unable to view/listen to voice messages.
The code I am using to view such messages and the url they are stored at is: audio_url = str(request.form.get('MediaUrl0'))
Has anyone experienced this before?/have a suggestion on how to fix?! Thanks!
Solution 1:[1]
I just had a play around with this and got it to work. It seems that to download an audio message you need to:
- make an authenticated
GETrequest to theMediaUrl0 - the response will be a 307 redirect, with a new location
- follow the redirect to the new location, or make a new request to the redirect location (this request doesn't seem to need authentication)
The MediaUrl redirects to a URL that looks like: https://mms.twiliocdn.com/${ACCOUNT_SID}/${SOME_ID}.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | philnash |
