whatsapp-business-java-api icon indicating copy to clipboard operation
whatsapp-business-java-api copied to clipboard

How to add Image Example in Header in Template Creation

Open bhavesh53 opened this issue 10 months ago • 4 comments

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

bhavesh53 avatar Aug 22 '23 11:08 bhavesh53

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!

github-actions[bot] avatar Aug 22 '23 11:08 github-actions[bot]

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

Cavassoni avatar Aug 28 '23 23:08 Cavassoni

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"));

bhavesh53 avatar Aug 31 '23 12:08 bhavesh53

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.

Bindambc avatar Sep 05 '23 03:09 Bindambc