Creating a script with AI
Introduction
The custom script editor includes an integrated AI agent, so you can get real-time assistance creating and updating scripts!
Our AI integration knows about expected keys and value types (payload, variables, meta, etc.), so generated scripts will be in a form that's ready to use in process flows.
Need to know
The maximum memory size for a custom script is 512MB
The maximum size of a custom script is 4GB
Up to 5 AI requests can be made per day for any company profile, free of charge.
A subscription tier bolt-on can be purchased if you'd like to increase this allowance.
You can view the number of AI requests used and remaining from your AI conversation history.
AI prompts can be up to 1500 characters.
Sample payloads for an AI request can be up to 6000 characters.
Using AI to create a script
Follow the steps below:
Step 1
Log in to the Patchworks dashboard and select scripts
from the left-hand navigation bar.
Step 2
Select the create script
button:

Step 3
Add a unique name
and a description
and then choose your preferred coding language:

Script names must be unique - you can't add two scripts with the same name.
Step 4 Move down to the Patchworks AI panel and enter your prompt (be as clear and specific as possible) - for example:

Step 5
If you have a sample payload and would like to provide it for clarity, select the provide an example payload?
checkbox and paste in your payload - for example:

We recommend providing a sample payload whenever possible, as it provides valuable context to the AI agent.
Sample payloads don't have to be perfect (or valid code) - as long as the structure and format are described correctly, the AI agent should have enough to work with. For example, if you don't have a JSON payload available, you might enter something like:
The payload comprises a JSON object containing multiple fields and associated values. There are no arrays.
Step 6
Click the generate
button:

Each time you generate
a script, the AI request allowance associated with your subscription tier is decremented. You can view the number of AI requests used and remaining from your AI conversation history.
Step 7 AI generates a first pass of the script, which is displayed in an overlay:

From here:
If you are satisfied that the script is correct, or that you at least have enough to work with independently, click
accept script
:Having accepted a script, it opens in the standard script editor so you can save, edit and test the code as needed.
Always test your scripts to ensure that the results are as expected.
If you want to refine your requirements and ask AI to generate again, update the
comments
field and clicksend reply
:Each time you refine the generated output with
send reply
, the AI request allowance associated with your subscription tier is decremented. You can view the number of AI requests used and remaining from your AI conversation history.Then, if you are satisfied that the script is correct, or that you at least have enough to work with independently, click
accept script
- otherwise you can refine your requirements again.If you want to close the script and exit back to your original prompt, click
close
.If you feel that the generated response is not appropriate/helpful, click
report
. This marks the conversation for review by Patchworks.
Last updated