Skip to content

Enhance WhatsApp Integration to Support Image and Voice Messaging #41

@AyushBhardwaj321

Description

@AyushBhardwaj321

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:

  1. 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.
  2. 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 our send_message payload.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions