Creating your first hook
Video tutorial
How to create your first hook
To create your first Cloudhooks hook: pick a trigger event, write a JavaScript function, test it with sample payloads, then activate it. A hook is a CommonJS module that runs when its trigger fires — a Shopify event (like a new order) or an external API call — using actions to update Shopify or call other systems.
Here's how to create your first one:
-
Press the "Create hook" button on the dashboard.
-
Select a trigger event on the "Trigger" tab. This could be a Shopify store event (like a new order) or an external API call. You can modify this trigger later if needed.
-
Write the code on the "Hook" tab:
- Your code will run in a CommonJS module format
- You'll have access to the trigger payload, actions, and context
- Use actions to interact with Shopify, send emails, or make HTTP requests
- Follow our best practices for optimal performance
-
Test your hook thoroughly:
- Use the testing environment to safely verify your code
- Review the run logs for any issues
- Iterate between coding and testing until everything works as expected
-
When ready, activate your hook on the "Settings" tab to make it live.
Your hook will now automatically run whenever its trigger event occurs. You can monitor its performance through the detailed run logs, which track successful executions, failures, and all actions performed.
Remember: You can always deactivate your hook for maintenance or modifications without affecting your store's operations.