david-lev / pywa

🤖 Build WhatsApp Bots in Python
https://pywa.readthedocs.io
MIT License
221 stars 33 forks source link

Error in pywa library for templates with image headers #15

Closed bcombes closed 11 months ago

bcombes commented 11 months ago

Discussed in https://github.com/david-lev/pywa/discussions/14

Originally posted by **bcombes** October 7, 2023 I'm not sure how best to file a bug report, but I found an error in the pywa send_template library when using image headers. According to the facebook docs, the key for the image location should be `link` and not `url` which results in the error below; > pywa.errors.WhatsAppError: WhatsAppError(message='(#100) Unexpected key "url" on param "template[\'components\'][0][\'parameters\'][0][\'image\']".', details=None, code=100) I've been trying to submit a PR to fix this, but not sure how.
david-lev commented 11 months ago

Hi @bcombes, thanks for your report! I see you right. The key for asset url is 'link' and not 'url'. If you want to submit a PR, here are the places that need the changes:

https://github.com/david-lev/pywa/blob/master/pywa/types/template.py#L905 https://github.com/david-lev/pywa/blob/master/pywa/types/template.py#L919 https://github.com/david-lev/pywa/blob/master/pywa/types/template.py#L933

bcombes commented 11 months ago

Hi david, I would love to and I already fixed on my local, but seems I don't have permissions to create a PR on the project'

image
david-lev commented 11 months ago

Thanks! To open pr you must fork this repo, commit your changes to your fork and then open PR

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork

david-lev commented 11 months ago

I uploaded a new version @bcombes Please update the directory (pip3 install -U pywa)

bcombes commented 11 months ago

Thanks david! great library by the way