Infos for ChatGPT
This guide explains how ChatGPT and other AI chatbots can generate Automation Blocks scripts. These scripts are XML files that users can load directly into Automation Blocks for Premiere Pro or Automation Blocks for After Effects.
If You Are Humanβ
If you're a human looking to get ChatGPT to write a specific Automation Blocks script for you, follow these best practices to achieve high-quality results:
- Use a reasoning model like ChatGPT o4-mini-high.
- Start your prompt with the following template:
Please create a script for Automation Blocks for Premiere Pro as a downloadable xml file.
Follow the details explained at https://mamoworld.com/chatGPT.
Read that entire page carefully and follow every advice given there.
The script should do the following:...
If the result does not work as expected, donβt give up. Instead, explain to ChatGPT exactly whatβs wrong, including:
- What the script was supposed to do
- What actually happened
- Any error messages or unexpected behavior
- What you already tried to fix it
The more precisely you describe the issue, the better ChatGPT can help you resolve it.
General Strategy for Chatbots to Create Automation Blocks Scriptsβ
Automation Blocks for Adobe Premiere Pro and Adobe After Effects is built on Google Blockly XML. The core strategy for generating scripts is to use a special block that can run arbitrary Adobe ExtendScript code:
- For Premiere Pro:
<block type="pr_execute_code">
- For After Effects:
<block type="ae_execute_code">
This means the most reliable and straightforward method is:
- First, write the entire script logic in Adobe ExtendScript.
- Then wrap that code inside the appropriate execute code block.
π‘ If your script should include a user interface (e.g., input fields, checkboxes, or dropdowns), you'll need to combine the execute block with additional input_arg blocks. For details, see the Creating User Interfaces section below.
Template for Premiere Proβ
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="pr_execute_code" id="%UNIQUE_ID%">
<mutation items="0" resultType="none"/>
<field name="RESULT_TYPE">none</field>
<value name="CODE">
<shadow type="text_multiline">
<field name="TEXT">
<!--
1. Replace %YOUR_ESCAPED_CODE% with your ExtendScript,
but first XML-escape every special character:
& β &
< β <
> β >
" β "
' β '
2. Turn each line break into (or leave literal newlines
if your CMS preserves them).
Example:
var binName = "stock footage";
becomes:
var binName = "stock footage";
...
-->
%YOUR_ESCAPED_CODE%
</field>
</shadow>
</value>
</block>
</xml>
For After Effects, use this template
Template for After Effectsβ
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="ae_execute_code" id="%UNIQUE_ID%">
<mutation items="0" resultType="none"/>
<field name="RESULT_TYPE">none</field>
<value name="CODE">
<shadow type="text_multiline">
<field name="TEXT">
<!--
Same rules as above:
β’ & β &
β’ < β <
β’ > β >
β’ " β "
β’ ' β '
-->
%YOUR_ESCAPED_CODE%
</field>
</shadow>
</value>
</block>
</xml>
Key encoding stepsβ
- Escape XML specials in your ExtendScript:
&
β&
(and of course&&
by&&
)<
β<
>
β>
"
β"
'
β'
- Paste the resulting single string into the
β¦ placeholder.
With this in place, any valid ExtendScript you write will be correctly wrapped, escaped and ready for Automation Blocks to parse next time.
Creating User Interfacesβ
Automation Blocks scripts can include custom user interfaces. When the script is loaded, the interface is displayed in the Inputs Panel of Automation Blocks, allowing users to interact with the script via text fields, checkboxes, dropdowns, and more.
Basic Exampleβ
The following example shows how to create a very simple UI for Premiere Pro: a single-line text field labeled βtext to alertβ with a default value of βHello Worldβ. When the script runs, it passes the value from the input into the pr_execute_code
block and alerts it using ExtendScript.
Premiere Pro Versionβ
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="pr_execute_code" id="%iY3K8}7bn%l.Zc]]6Zp">
<mutation items="1" resultType="none"></mutation>
<field name="FIELD_VAR_NAME_0">userText</field>
<field name="FIELD_VAR_TYPE_0">other</field>
<field name="RESULT_TYPE">none</field>
<value name="ADD0">
<block type="input_arg" id="(5;552lWsig;%)81`7l)">
<mutation inputType="TEXT_SINGLELINE"></mutation>
<field name="INPUT_TYPE">TEXT_SINGLELINE</field>
<field name="INPUT_LABEL">text to alert</field>
<field name="DEFAULT FIELD">Hello World</field>
</block>
</value>
<value name="CODE">
<shadow type="text_multiline" id="ER6sdOaHs09=6shK54:m">
<field name="TEXT">alert(userText)</field>
</shadow>
</value>
</block>
</xml>
In this example:
A text input labeled "text to alert" is defined using an
input_arg
block.Its value is passed to the global variable
userText
.The
pr_execute_code block
usesalert(userText)
to display it.
After Effects Versionβ
The same UI setup works in After Effects by using the ae_execute_code
block instead:
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="ae_execute_code" id="*(K2*X#o%hhJ0#X=iI|v">
<mutation items="1" resultType="none"></mutation>
<field name="FIELD_VAR_NAME_0">userText</field>
<field name="FIELD_VAR_TYPE_0">other</field>
<field name="RESULT_TYPE">none</field>
<value name="ADD0">
<block type="input_arg" id="zABhfFxR/eVIzn6~i%mW">
<mutation inputType="TEXT_SINGLELINE"></mutation>
<field name="INPUT_TYPE">TEXT_SINGLELINE</field>
<field name="INPUT_LABEL">text to alert</field>
<field name="DEFAULT FIELD">Hello World</field>
</block>
</value>
<value name="CODE">
<shadow type="text_multiline" id="aYiy?/U)k8G:02-Ix7(1">
<field name="TEXT">alert(userText)</field>
</shadow>
</value>
</block>
</xml>
In both cases, the value of the input field is available in the ExtendScript code via the global variable userText.
Comprehensive Example Featuring All Available UI Elementsβ
To create more advanced user interfaces, you can add multiple input_arg
blocks to your script. Each input defines one UI control, such as text fields, checkboxes, dropdowns, or file/folder pickers.
The following example for Premiere Pro includes all available UI elements. The corresponding values are passed into the pr_execute_code
block as global variables.
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="pr_execute_code" id="%iY3K8}7bn%l.Zc]]6Zp" x="17" y="37">
<mutation items="9" resultType="none"></mutation>
<field name="FIELD_VAR_NAME_0">mySingleLineText</field>
<field name="FIELD_VAR_TYPE_0">other</field>
<field name="FIELD_VAR_NAME_1">myMultiLineText</field>
<field name="FIELD_VAR_TYPE_1">other</field>
<field name="FIELD_VAR_NAME_2">myInt</field>
<field name="FIELD_VAR_TYPE_2">other</field>
<field name="FIELD_VAR_NAME_3">myFloat</field>
<field name="FIELD_VAR_TYPE_3">other</field>
<field name="FIELD_VAR_NAME_4">myCheckBox</field>
<field name="FIELD_VAR_TYPE_4">other</field>
<field name="FIELD_VAR_NAME_5">myDropDown</field>
<field name="FIELD_VAR_TYPE_5">other</field>
<field name="FIELD_VAR_NAME_6">myOpenFilePath</field>
<field name="FIELD_VAR_TYPE_6">other</field>
<field name="FIELD_VAR_NAME_7">mySaveFilePath</field>
<field name="FIELD_VAR_TYPE_7">other</field>
<field name="FIELD_VAR_NAME_8">myFolderPath</field>
<field name="FIELD_VAR_TYPE_8">other</field>
<field name="RESULT_TYPE">none</field>
<value name="ADD0">
<block type="input_arg" id="(5;552lWsig;%)81`7l)">
<mutation inputType="TEXT_SINGLELINE"></mutation>
<field name="INPUT_TYPE">TEXT_SINGLELINE</field>
<field name="INPUT_LABEL">sample single line</field>
<field name="DEFAULT FIELD">Hello World</field>
</block>
</value>
<value name="ADD1">
<block type="input_arg" id="JJ[;v0]Y5=ZEi1x^ZAx1">
<mutation inputType="TEXT_MULTILINE"></mutation>
<field name="INPUT_TYPE">TEXT_MULTILINE</field>
<field name="INPUT_LABEL">sample multi line</field>
<field name="DEFAULT FIELD">line 1&#10;line 2</field>
</block>
</value>
<value name="ADD2">
<block type="input_arg" id="$g#6:9MaCLyjfc;flJlO">
<mutation inputType="NUMBER_INT"></mutation>
<field name="INPUT_TYPE">NUMBER_INT</field>
<field name="INPUT_LABEL">sample int</field>
<field name="DEFAULT FIELD">0</field>
</block>
</value>
<value name="ADD3">
<block type="input_arg" id="krdEOpOs#|LA%{NO[Ker">
<mutation inputType="NUMBER_FLOAT"></mutation>
<field name="INPUT_TYPE">NUMBER_FLOAT</field>
<field name="INPUT_LABEL">sample float</field>
<field name="DEFAULT FIELD">0</field>
</block>
</value>
<value name="ADD4">
<block type="input_arg" id="k|#)5eQvX7-Ic]20@e4+">
<mutation inputType="CHECKBOX"></mutation>
<field name="INPUT_TYPE">CHECKBOX</field>
<field name="INPUT_LABEL">sample checkbox</field>
<field name="DEFAULT FIELD">TRUE</field>
</block>
</value>
<value name="ADD5">
<block type="input_arg" id="nToJwv5vHbl5A1:zW;tQ">
<mutation inputType="DROPDOWN"></mutation>
<field name="INPUT_TYPE">DROPDOWN</field>
<field name="INPUT_LABEL">sample dropdown</field>
<field name="DEFAULT FIELD">option 1|option 2|option 3</field>
</block>
</value>
<value name="ADD6">
<block type="input_arg" id="=SOky3W[L*^Tg7cU-)|w" inline="false">
<mutation inputType="OPEN_FILE"></mutation>
<field name="INPUT_TYPE">OPEN_FILE</field>
<field name="INPUT_LABEL">sample open file</field>
<field name="DEFAULT FIELD"></field>
<field name="NO_FILE_BEHAVIOR">CONTINUE</field>
<field name="FILE_DOES_NOT_EXIST_BEHAVIOR">CONTINUE</field>
</block>
</value>
<value name="ADD7">
<block type="input_arg" id="B+Ae9,62M)o_-{UyFD,Z" inline="false">
<mutation inputType="SAVE_FILE"></mutation>
<field name="INPUT_TYPE">SAVE_FILE</field>
<field name="INPUT_LABEL">sample save file</field>
<field name="DEFAULT FIELD"></field>
<field name="NO_FILE_BEHAVIOR">STOP</field>
<field name="PARENT_FOLDER_NOT_EXISTS_BEHAVIOR">STOP</field>
<field name="FILE_EXISTS_BEHAVIOR">CONFIRM_DELETE</field>
</block>
</value>
<value name="ADD8">
<block type="input_arg" id="Z6dYS8b!0aWomPU,j7%;" inline="false">
<mutation inputType="CHOOSE_FOLDER"></mutation>
<field name="INPUT_TYPE">CHOOSE_FOLDER</field>
<field name="INPUT_LABEL">sample folder picker</field>
<field name="DEFAULT FIELD"></field>
<field name="NO_FILE_BEHAVIOR">CONTINUE</field>
<field name="FILE_DOES_NOT_EXIST_BEHAVIOR">CONTINUE</field>
</block>
</value>
<value name="CODE">
<shadow type="text_multiline" id="ER6sdOaHs09=6shK54:m">
<field name="TEXT">alert("sample single line value is " +
mySingleLineText);&#10;alert("sample multi line value is "+
myMultiLineText);&#10;alert("sample int value is
"+myInt);&#10;alert("sample float value is "+myFloat);&#10;alert("sample
checkbox value is "+ (myCheckBox ? "checked":"unchecked"));&#10;alert("in
the dropdown you have chosen the text
"+myDropDown);&#10;&#10;if(myOpenFilePath =="") alert("you didn't pick a
file in the sample open file picker")&#10;else {&#10; var file = new
File(myOpenFilePath);&#10; alert("you picked the file with path
"+myOpenFilePath+ " to be opened and it "+ (file.exists? "exists" : "does not
exist"));&#10;}&#10;&#10;if(mySaveFilePath == "") alert("you didn't
pick a file in the sample save file picker")&#10;else {&#10; var file =
new File(mySaveFilePath);&#10; alert("you want to sav to the file path
"+mySaveFilePath+ " and this file "+ (file.exists? "exists" : "does not
exist"));&#10;}&#10;if(myFolderPath == "") alert("you didn't pick a
folder in the sample folder picker")&#10;else {&#10; var folder = new
Folder(myFolderPath);&#10; alert("you picked the folder with path
"+myFolderPath+ " and this folder "+ (folder.exists? "exists" : "does not
exist"));&#10;&#10;}</field>
</shadow>
</value>
</block>
</xml>
What This Example Doesβ
This example generates a UI containing:
- A single-line text field
- A multiline text field
- Integer number input
- Float number input
- A checkbox
- A dropdown with options:
"option 1"
,"option 2"
,"option 3"
- A file picker to select a file to open
- A file picker to select a file path for saving
- A folder picker
Each UI value is passed into a global variable and used inside the ExtendScript to display alerts with the input values.
This example is helpful if you want to:
- Understand how to define different input types
- Learn how to bind UI input values to ExtendScript variables
- See the structure of a more complex UI setup
Passing UI Element Values into the Execute Code Blockβ
Execute Code blocks may contain tags like <value name="ADD0"><block type="input_arg">DETAILS OF INPUT HERE</block</value>
. Use "ADD0" for the first input, "ADD1" for the second one, etc. If you have a <value name="ADD0">
in your execute code block, for example, you must also have <field name="FIELD_VAR_NAME_0">SOME VARIABLE NAME HERE</field>
and <field name="FIELD_VAR_TYPE_0">other</field>
. Before the ExtendScript code is executed, Automation Blocks then creates a global variable of the given name and assigns the value of the block contained in ADD0 to it. With the "FIELD_VAR_TYPE" you can specify that the result of the block code should be converted to a particular object before binding it to the global variable. But usually you can keep this as "other", which means no conversion.
Also, the execute code block must contain a mutation tag like "
Passing UI Element Values into the Execute Code Blockβ
To pass user input values into your ExtendScript code, each input_arg
block must be properly connected to the execute_code
block using three key components:
Value Tag
Each input must be included in a<value name="ADDn">
tag (wheren
is the input index, starting from 0):<value name="ADD0">
<block type="input_arg">...</block>
</value>Field Variable Mapping
You must define a corresponding variable for each input in the block using:
<field name="FIELD_VAR_NAME_0">yourVariableName</field>
<field name="FIELD_VAR_TYPE_0">other</field>
This tells Automation Blocks to create a global variable (e.g., `yourVariableName`) and assign it the value from the `ADD0` input block.
FIELD_VAR_NAME_0
matchesADD0
FIELD_VAR_TYPE_0
is typically set to"other"
(no type conversion)
- Mutation Tag
The<mutation>
tag declares how many inputs/variables are connected. For example, if you useADD0
,ADD1
, andADD2
, you must set:
<mutation items="3" resultType="none"></mutation>
π‘ All three componentsβ
<value name="ADDn">
,FIELD_VAR_NAME_n
, andmutation items="..."
βmust be aligned. If any part is missing or the counts don't match, the script may fail or behave unpredictably.
More Examplesβ
Hereβs a simple example that demonstrates how to collect two integer inputs from the user and alert their sum:
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="pr_execute_code" id="?6ou@P!7pk2.X3C!A|nK" x="-412" y="293">
<mutation items="2" resultType="none"></mutation>
<field name="FIELD_VAR_NAME_0">num1</field>
<field name="FIELD_VAR_TYPE_0">other</field>
<field name="FIELD_VAR_NAME_1">num2</field>
<field name="FIELD_VAR_TYPE_1">other</field>
<field name="RESULT_TYPE">none</field>
<value name="ADD0">
<shadow type="text" id="kA$mZBxg)(4WbxlI/8ph">
<field name="TEXT">variable value</field>
</shadow>
<block type="input_arg" id="}}5~D!hkf4/E?:b.=?Fi">
<mutation inputType="NUMBER_INT"></mutation>
<field name="INPUT_TYPE">NUMBER_INT</field>
<field name="INPUT_LABEL">first number</field>
<field name="DEFAULT FIELD">0</field>
</block>
</value>
<value name="ADD1">
<block type="input_arg" id="]KgWl(VXhGM0iugtlJWA">
<mutation inputType="NUMBER_INT"></mutation>
<field name="INPUT_TYPE">NUMBER_INT</field>
<field name="INPUT_LABEL">second number</field>
<field name="DEFAULT FIELD">0</field>
</block>
</value>
<value name="CODE">
<shadow type="text_multiline" id="=|xGua9(i-iN^f#%3phN">
<field name="TEXT">var sum =
num1+num2;&#10;alert("the sum is "+sum);</field>
</shadow>
</value>
</block>
</xml>
In this script:
- Two number inputs are created using
input_arg
blocks with labels "first number" and "second number". - Their values are passed into the global variables
num1
andnum2
. - The ExtendScript code calculates their sum and displays it with
alert("the sum is " + sum)
.
General Block Attributesβ
All <block>
tags must include a unique id
attribute β typically a random string.
Top-level blocks may also include optional x
and y
attributes to define their position on the canvas. These coordinates are purely visual and have no effect on the program logic.
Tips for Writing Script Logicβ
Use log()
for Debuggingβ
To output messages to the Automation Blocks console panel, use this function inside your ExtendScript code:
$._extAutomationBlocks.all.log("My log message here");
This is especially useful for debugging and troubleshooting when users report unexpected script behavior. Logging intermediate steps makes it easier to trace what's going on.
Avoid Skipping Items When Modifying Collectionsβ
If you're moving or deleting items in a collection (e.g., clips in a bin or on a track), iterate in reverse order. This helps avoid accidentally skipping elements. For example:
- If you move the second item in a bin, the third one becomes the new second.
- If you loop forward, this could cause elements to be skipped.
File Input and Output: Always Provide a UI if No Method Is Specifiedβ
When the user asks for a script that reads from or writes to a file or folder β but does not specify how the file should be selected β the chatbot should create a user interface for it using the input_arg
blocks.
Why This Mattersβ
Hardcoding file paths is:
- Not portable across different systems
- Often not what the user intends
- Prone to errors and user frustration
Instead, always assume that the user wants to be prompted to pick a file or folder.
How to Do Itβ
Use the appropriate input type in an input_arg
block:
Task | Recommended Input Type |
---|---|
Select a file to open | OPEN_FILE |
Select a file to save to | SAVE_FILE |
Select a folder | CHOOSE_FOLDER |
For example, to let the user pick a file to read, use:
<block type="input_arg" id="=SOky3W[L*^Tg7cU-)|w" inline="false">
<mutation inputType="OPEN_FILE"></mutation>
<field name="INPUT_TYPE">OPEN_FILE</field>
<field name="INPUT_LABEL">sample open file</field>
<field name="DEFAULT FIELD"></field>
<field name="NO_FILE_BEHAVIOR">CONTINUE</field>
<field name="FILE_DOES_NOT_EXIST_BEHAVIOR">CONTINUE</field>
</block>
You must also make sure that:
- The input is passed as a global variable to the
execute_code
block - The script logic handles cases where the user did not select a file (e.g., variable is empty)
Example Use Caseβ
If a user says:
"Create a script that exports a list of clip names to a file"
β¦but does not mention a file path or method for choosing the destination, the chatbot should automatically create a Save File Picker UI using inputType="SAVE_FILE"
.
β Always prioritize flexibility and usability β if a path isn't specified, prompt the user with a UI.
No Top-Level return
Statements in ExtendScript Codeβ
When writing ExtendScript for an execute_code
block in Automation Blocks, do not use return
at the top level of your code.
Why?β
Automation Blocks uses JavaScript's eval()
function to execute the ExtendScript code. In JavaScript, eval()
does not allow return
statements at the top level β doing so will throw a syntax error.
What to Do Insteadβ
If you need to exit early from a script (e.g., because a file couldnβt be opened), wrap your logic in a function or use conditional blocks.
β Invalid Example (will cause a syntax error):β
if (!outputFile.open("w")) {
alert("Cannot open file: " + filePath);
return;
}
β Valid Alternative:β
if (!outputFile.open("w")) {
alert("Cannot open file: " + filePath);
} else {
// Continue with the rest of the logic here
}
β Tip: If your script is large and needs structured flow control, consider wrapping the entire logic in a function and calling it explicitly.
Output Format: Don't Show XML β Provide a Download Linkβ
Output Formatβ
When generating scripts or other code for Automation Blocks, the assistant must:
- Write the code into a
.xml
file. - Provide a direct download link to that file (e.g.
sandbox:/mnt/data/<filename>.xml
). - Do not paste the raw XML inline in the chat.
When ChatGPT (or any chatbot) creates an Automation Blocks script, it should not display the raw XML code to the end user.
Instead, it should:
- Save the XML as a downloadable file, ideally named based on the script's purpose (e.g.,
moveStockFootage.xml
). - Provide a download link to that file.
This is important because:
- Raw XML is hard to read and error-prone to copy-paste.
- Automation Blocks expects
.xml
files to be imported or placed in specific locations.
How Users Should Use the XML Fileβ
After downloading the file, users have two options to use it:
Option 1: Load the File Manuallyβ
- Open Automation Blocks in Premiere Pro or After Effects.
- Click the Load button in the Automation Blocks panel.
- Select the downloaded
.xml
file.
Option 2: Add the File to the User Libraryβ
- Move the
.xml
file into your Automation Blocks User Library folder. - Restart Automation Blocks to make the script appear in the library.
To learn where your User Library is located, see:
π Where is the User Library?
β οΈ After adding files to the User Library manually, Automation Blocks must be restarted to detect the new files.
More Resourcesβ
To learn more about the ExtendScript API for Premiere Pro and After Effects, refer to these resources: