Generate a Code step using AI (Beta)

You can use Code with AI to help you generate JavaScript or Python to use in your Zap. Describe what you'd like to do in your Code step, and AI will generate the code for you. 

Beta

AI-powered Code steps are a beta feature. It's available for use, but still in active development and may change. 

 

Set up your AI-powered Code step

  • In your trigger or action step, above the Code field, click Generate with AI.
  • In the dialog box, enter a prompt that describes your desired code.
  • Click Generate code.
  • Review the generated code.
  • Then you can:
    • Click the back arrow icon , then edit the prompt and click Generate code to try again.
    • Click the back arrow icon , keep the same prompt, then click Generate code to create new code using the same prompt.
    • Click Add code to accept the generated code and add it to your Code step.
    • Click Cancel to manually enter your code.
  • When the dialog box closes, click Continue.
  • In the Test tab, click Test step.
  • Review your test results.

 

How to write your prompt

  • Use plain language in your prompt. 
    • You do not need to use technical language. 
    • Avoid ambiguity–be clear and concise.
  • You can manually edit your AI-generated code at any time.
  • For action steps, you can reference:
    • Input data from your Code step.
    • Data from previous steps to add it as input data in your Code step for you. 
  • If you’re making a request to a specific API, it is recommended to include the name of the API in your prompt.
actionEdit icon Example

Here are some example prompts:

  • Get the current date and time and return it in the format: YYYY-MM-DD HH:MM:SS as an object.
  • Split the full name input into first and last.
  • Make an API request to the Star Wars API (swapi.dev) for details on the character name in the input and return the result.
  • Check if the value provided is prime.
  • Pad the amount given in inputData to the number of decimal places given in inputData.
Was this article helpful?
3 out of 6 found this helpful