Question

How does my web-app now trigger my integrations zaps?

  • 18 May 2021
  • 1 reply
  • 92 views

I’m new to coding Zapier integrations so I am asking a very elementary question: how does my web-app initiate my rest-hook trigger? If that doesn’t make sense I’ll explain below the simple project I’ve setup and how my question fits into it.

My API subscribe endpoint (https://mywebapp.com/subscribe) never received anything. I thought that when someone creates a zap, the endpoint https://mywebapp.com/subscribe is called and then I bundle.targetUrl which is the url I then call when I trigger zaps??? Is that correct?

 

How does my web-app now trigger my integrations zaps?

 

const subscribeHook = (z, bundle) => {
  const data = {
    url: bundle.targetUrl,
    style: bundle.inputData.style,
  };

  const options = {
    url: 'https://mywebapp.com/subscribe', 
    method: 'POST',
    body: data,
  };

  return z.request(options).then((response) => response.data);
};

 


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Userlevel 7
Badge +9

The basics of implementing the server side:

  1. Your subscribe endpoint (on your server) will need to receive the subscribe request, generate an id for it, associate it with an appropriate event type of your system, save it to a database (including the targetUrl), and return a response with the id for the subscription.
  2. When the event occurs in your system (on your server), you’ll retrieve the performUrl from your database and POST data to it (“sending the hook”). How you do event handling in your system is dependent on your implementation.
  3. Your endpoint (on your server) needs to listen for unsubscribe requests for a given id, and then delete the subscription from your database.
  4. You’ll also need an endpoint where the Zap editor can GET an array of example objects from the user’s account that match the name/shape of the objects you’ll be sending in your hook messages. This what your `performList` request in your Zapier integration will use.

 

Let’s confirm this is the approach you’re taking to your implementation. And then, if so, let’s start at the beginning - you say you aren’t getting the subscribe message - what do your logs (from the Zapier developer tools) say after you test setting up a Zap with your trigger?