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.

For the best results from AI, use PHP, JavaScript, Python, or GO. AI does work for other languages however, you will need to provide significantly more context in your requests.

Show me

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:

Step 4 Move down to the Patchworks AI panel and enter your prompt (be as clear and specific as possible) - for example:

The Patchworks AI panel is displayed as soon as your coding language is selected in the previous step.

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:

Step 7 AI generates a first pass of the script, which is displayed in an overlay:

If your request is ambiguous (for example, you indicate that you require some specific fields to be added but don't stipulate what these are), you may be prompted for clarification:

In this case, enter your response in the comments field and click send reply.

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:

    You can't edit the generated script in the AI 'overlay' window - you need to accept it and then make any required updates in the standard script editor.

    Having accepted a script, it opens in the standard script editor so you can save, edit and test the code as needed.

  • If you want to refine your requirements and ask AI to generate again, update the comments field and click send reply:

    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