Search code examples
javarestrsszapier

How to have my java application as an endpoint for webhook


I am working on a discord bot that posts rss messages to channels. I currently have this:

  1. New item gets posted in the rss feed
  2. Zapier gets notified by the rss feed
  3. Zapier sends out a webhook to my java application
  4. My application receives the message
  5. Application does some processing and sends it to discord

However, I'm now stuck at step 4. I am guessing I should make my java listen to the webhook url of zappier but I could not find out how to make this endpoint.

I was hoping someone could help me out.

P.S. If my idea is stupid or someone knows another way for getting the rss messages to my application please let me know.


Solution

  • To be honest, I haven't use Zapier yet until now but based on the comments, I believe this answer will help you get to the point and write the app for sure because they are conceptually the same.

    Recently I developed a telegram bot that have the same behavior. It had webhook pointing to a url that I defined and then it pushed all updates as a json to my URL.

    For fetching these kind of data and use them in our app, we should follow these procedures:

    1. Create a web-app with a url endpoint that can receive json object
    2. set your zapier webhook to point exactly to that URL
    3. If you're using java as your web-app, you should have a library like Jackson,GSon to convert your data to a corresponding Java Bean/POJO which you have made.
    4. use that object inside your application

    To create POJO object, you should consider the json structure and based on that you should create Java Bean class for binding. refer to this example for that -> How to convert Java object to / from JSON (Jackson)

    Take note some frameworks like Spring-MVC they have integrated with libraries like Jackson and they do all of the binding work for you automatically.