Has anyone used ChatGPT to create snippets for Xano?

Options

I've been curious to test out having ChatGPT generate pieces of Javascript that I would then copy into my function stack using the Lambda feature but can't seem to nail down what works and what doesn't. I'll try simple things like Javascript that generates a number 1-10, or one that generates the current date and time and even when I ask it to make it compatible with node.js, I still don't have luck.

I'm curious if anybody has used AI to write custom snippets that are compatible with Xano. If so, any words of advice to a JavaScript noob on how to better write these prompts to ChatGPT?

Comments

  • Brandon Hassler
    Brandon Hassler Member
    edited February 2023
    Options

    Here are a couple of examples of snippets that I made that all returned a "null" in Xano:

    EXAMPLE 1

    const randomNumber = Math.floor(Math.random() * 10) + 1;
    console.log(randomNumber);
    


    EXAMPLE 2

    (This one actually returned something about not being able to find the crypto library)

    const crypto = require('crypto');
    
    
    const password = 'password123';
    const hash = crypto.createHash('sha256').update(password).digest('hex');
    
    
    console.log(hash);
    


    EXAMPLE 3

    const result = 2 + 2;
    console.log(result);
    
  • Chris Coleman
    Chris Coleman Administrator

    ADMIN

    Options

    Hey, Brandon. Add the following line to the end of your code:

    return result;

    to populate the return variable for the Lambda. Except for the second one; we support the NodeJS crypto library, this example is using crypto.js. (I had to specifically ask ChatGPT to not use crypto.js and instead use the NodeJS crypto library)

  • Brandon Hassler
    Options

    Thank you Chris! The return line wasn't working at first, but it's because it was trying to import the "random" module in so I had it rewrite it not using that (and added the return) and it worked.

    I'm still struggling with the crypto one. No matter what I tell ChatGPT, it will keep opening up with that line of:

    const crypto = require('crypto');

    It will even humor me and say "ahh yes, try this code which uses the built-in crypto function of NodeJS rather than crypto.js and it still just returns the same thing. After some playing around I realized that simple removing that single line solved the issues 😂