(A)wait your actions
All actions return a promise.
Wait until the promise resolves, otherwise your hook won't work as expected.
You can use await because Cloudhooks is ES2016 compatible:
Debug with log entries
If something goes wrong the hook, log entries can help you debug it.
Use console.log() and console.error() to add log and error entries, respectively.
Here is a hook example with logging:
This is the output of the test run:
Use try/catch to handle errors
Actions might fail silently if you don't explicitly handle errors.
Catch errors by using try/catch in your hook code.
This example tries to download from a non-existent website:
Here is the result of the test run: