← View all announcements
New release
New release
New release
Jan 4, 2024

Ask Cloudhooks GPT to draft hooks

Wouldn’t it be cool if you could ask Cloudhooks to draft hooks for you? You could explain what you need in plain English, and the javascript code of the hook would magically appear.

We’re delighted to announce Cloudhooks GPT, the chatbot that can help you write hooks. Cloudhooks GPT is an OpenAI GPT and it’s available with a ChatGPT Plus subscription.

You just explain what kind of hook you need, and Cloudhooks GPT generates javascript code which can be further refined either manually or by Cloudhooks GPT.

As an example, let’s draft a hook that is run in response to the “An order is paid” event. It takes an order payload, and tags the customer and the order if the order value is greater than $100 otherwise just logs to the console.

Here is the prompt:

Here is the resulting hook code:

module.exports = async function(payload, actions, context) {
    try {
        const totalAmount = payload.total_price || 0;

        if (totalAmount >= 100) {
            // Tagging the order as 'big-order'
            await actions.shopify.tagOrder(payload.id, 'big-order');

            // Tagging the customer as 'big-spender'
            await actions.shopify.tagCustomer(payload.customer.id, 'big-spender');
        } else {
            console.log('Small order');
    } catch (error) {
        console.error('Error in processing the order:', error);

Boom! This hook code works out of the box. You can make further refinements to the code using prompts, it works like magic.

Please note that Cloudhooks GPT is for drafting your hook, it’s not a replacement for javascript programming skills. You should verify, revise, and improve the generated code.

Cloudhooks GPT sometimes hallucinates, which may result in javascript code with invalid syntax, actions not supported by Cloudhooks, or the hook accessing payload properties which don’t exist.

For more information on Cloudhooks GPT, please refer to our Cloudhooks GPT prompting guide.