-
Notifications
You must be signed in to change notification settings - Fork 802
Description
Hello!
First, thank you for creating and maintaining this very useful python-whatsapp-bot
project.
Currently, the repository is set up to take text from a user and respond back with text, which works great. I am trying to figure out how I can extend this functionality to handle images and voice notes as well.
My core question is: How can we adapt the current logic to process an incoming image or voice note and then respond back, potentially with media, voice or text?
Based on my reading of the official WhatsApp Cloud API documentation for media, I have some initial thoughts on the workflow, but I would love your expert guidance.
My Understanding of the Process:
-
For Receiving Media:
- It seems that when a user sends an image or voice note, the webhook payload won't contain the file itself, but a
Media ID
. - We would need to use this ID to fetch a media URL from the WhatsApp servers.
- Then, we'd download the file from that URL for processing.
- It seems that when a user sends an image or voice note, the webhook payload won't contain the file itself, but a
-
For Sending Media:
- To send an image or voice note back, we would first need to upload our media to the WhatsApp servers to get a
Media ID
. - Then, we would use that
Media ID
in oursend_message
payload.
- To send an image or voice note back, we would first need to upload our media to the WhatsApp servers to get a
Given this, I assume the process_whatsapp_message
function would be the main place to add this new logic.
Could you provide any guidance on this? Specifically:
- Does this seem like the correct approach for this project's architecture?
- Are there any specific parts of the code, aside from
process_whatsapp_message
, that you would recommend I look at closely? - Are there any potential pitfalls I should be aware of?
Any advice or direction you could offer would be incredibly helpful. Thank you for your time.