Bindambc / whatsapp-business-java-api

Whatsapp business api SDK, written in java. This SDK implements the Official Whatsapp Cloud API and WhatsApp Business Management API. These allows you to: manage your WhatsApp Business Account assets, such as message templates and phone numbers; send messages to your contacts, such as simple text messages, messages with buttons...
https://bindambc.github.io/whatsapp-business-java-api/
MIT License
137 stars 69 forks source link

How to add Image Example in Header in Template Creation #115

Open bhavesh53 opened 10 months ago

bhavesh53 commented 10 months ago

Hello want to know how to add Example Image in Template Creation. i found below example but I don't understand which data need to pass in addHeaderHandleExamples argument .

https://github.com/Bindambc/whatsapp-business-java-api/blob/95580cfebc9de0610d7f7c9730192bc4f228fcf1/src/test/java/com/whatsapp/api/examples/CreateMessageTemplate6Example.java#L35C1-L35C1

github-actions[bot] commented 10 months ago

Hello and welcome! We're glad to see that you've opened your first issue. We appreciate your contribution and would love to hear more about the problem you're experiencing. Our team is actively monitoring this repository and we will do our best to respond to your issue as soon as possible. Thank you for using our project and we look forward to working with you!

Cavassoni commented 10 months ago

Hello. The mentioned example is sending a media ID generated from the Resumable Upload API It's a longer process for uploading files.

An alternative would be to send the media identification "url." To make it easier, follow the UploadMediaExample and RetrieveMediaUrlExample samples, which will return the "url" you can use in the addHeaderHandleExamples

bhavesh53 commented 10 months ago

Hello @Cavassoni i tried but when ever i upload with below code . but its rejected instantly .

   var template = new MessageTemplate();

        template.setName("template_310823")
                .setCategory(Category.MARKETING)
                .setLanguage(LanguageType.EN)
                .addComponent(new HeaderComponent().setFormat(HeaderFormat.IMAGE)
                        .setExample(new Example().addHeaderHandleExamples()
                                .addHeaderHandleExamples("https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=9xxx89620xxxxxxx&ext=1693xxxxxx&hash=ATtrDAQxxxxxxxxxx")))
                .addComponent(new BodyComponent()//
                        .setText("this is example body"));
Bindambc commented 10 months ago

Hello @bhavesh53, we don't have support for the Resumable Upload API yet. This is the API that returns the "id" used in the examples. We'll be adding this functionality soon.

There's an example of how this API works in a Postman collection, which can be accessed at this link.