Building webhook

Now that you have understood about App Setup Events and External Events, let's get ahead with the app.

  • Webhook endpoint is generated whenenver the app is installed, so defining onAppInstall and onAppUninstall event along with the onAppInstallHandler and onAppUninstallHandler respectively in the manifest.json.
  • To generate the webhook in onAppInstallHandler with generateTargetUrl(). And registering the webhook endpoint on Pipedream via request method .
  • And also when the app is uninstalled, webhook should be deregistered so in onAppUninstallHandler using request method invoke Pipedream API to deregister the webhook endpoint.
  • Now that webhook is registered, we would have to define onExternalEvents in manifest.json and the onExternalEventsHandler handler in server.js that would be triggered whenever the URL from generateTargetUrl().

Simulation

Now to locally test the app, use fdk run command in your app's directory.

fdk run
Starting local testing server at http://*:10001/    
Append 'dev=true' to your current host URL to start testing    
     
e.g:     
  https://domain.freshdesk.com/a/tickets/1?dev=true

Quit the server with Control-C.

To simulate product, app setup, and external events, visit - http://localhost:10001/web/test

Navigate to http://localhost:10001/web/test, choose the events -

  • onAppInstall to test the app installation and webhook registration on Pipedream .
  • onExternalEvent to test the events that would be invoked from the third party as a webhook.
  • onAppUninstall to test the app's uninstallation event to de-register the webhook on Pipedream .