Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebHookExample #83

Closed
eos1d3 opened this issue Apr 17, 2023 · 7 comments
Closed

WebHookExample #83

eos1d3 opened this issue Apr 17, 2023 · 7 comments
Labels
question Further information is requested

Comments

@eos1d3
Copy link

eos1d3 commented Apr 17, 2023

Hi,

I am studying how to use this library. The only thing I am confused is how to use WebHook. From WebHookExample, it does not setup Token or URL. Does this library need another web server running to receive WebHook events? And how to link the server to this library?

I also do not find any user callback to get WebHook event, nor any WebHook subscription in this library.

Need further clarifications for this. Thanks!

@github-actions
Copy link

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!

@pcomp96
Copy link
Contributor

pcomp96 commented Apr 17, 2023

Hello @eos1d3,

From WebHookExample, it does not setup Token or URL.

You should implement the webhook APIs.
This library provides an interface for the event received on the webhook from WhatsApp.

You must implement 2 endpoint without authorization

  1. GET - To verify the webhook with WA
  2. POST - To receive the event when WA send it.

This is an example of verify endpoint:

@GET
@Path("/webhook")
public Response verify(@NotNull @QueryParam("hub.mode") String mode,
                     @NotNull @QueryParam("hub.challenge") String challenge,
                     @NotNull @QueryParam("hub.verify_token") String verifyToken);

This is an example of processEvent endpoint:

@POST
@Path("/webhook")
public Response processEvent(@NotNull String payload);

The examples are written with Quarkus and Java 11.

  1. The token must be verified from you in business logic.
  2. The URL must be in HTTPS and set it into https://developers.facebook.com/apps/{YOUR_APP_ID}/whatsapp-business/wa-settings/?business_id={YOUR_BUSINESS_ID}
  3. See this guide to set the webhook..
    https://developers.facebook.com/docs/whatsapp/cloud-api/get-started#configure-webhooks
  4. To test fastly I recommend you using Glitch or Heroku.

Hope this may be helpful!

@eos1d3
Copy link
Author

eos1d3 commented Apr 17, 2023

Thanks a lot. I will try later with a real test.

@Bindambc
Copy link
Owner

Hello,

Thanks @pcomp96 for your contribution.

@eos1d3, as @pcomp96 mentioned, you need to implement the endpoints for the webhook.

You can use this library to deserialize an event received on the webhook:

public void processEvent(@NotNull String payload);
       WebHookEvent event = WebHook.constructEvent(payload)

@Bindambc Bindambc added the question Further information is requested label Apr 19, 2023
@gustavobrian
Copy link

Hi, thanks for your work... I need full sample the webhook ?

@Bindambc Bindambc closed this as completed May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants
@Bindambc @gustavobrian @eos1d3 @pcomp96 and others