Every integration starts with an event that fires up the process. Cloudhooks offers a wide variety of events that cover all aspects of your Shopify store.
Creating a hook
Creating a hook is simple. You just select a trigger event (webhook), then define the code you want to run in a handler function.
Handler functions are defined like this:
The payload is whatever data is sent by the triggering webhook.
The actions object contains the functions you can call to trigger API requests, HTTP requests, send email, etc.
For example, if we wanted to send an email to ourselves celebrating whenever a new user signs up:
Notice how we return the action call. This is because actions return a promise, and if we use those promises to coordinate several asynchronous things, then by returning a promise that only resolves when our code is finished, we can ensure that the system doesn't quit early.
Each call to an action will result in a charge of $0.01. Some "shortcut" actions might actually cost more than $0.01 if they internally call additional actions in order to complete.