Skip to main content

Infos for ChatGPT

This document explains ChatGPT and other Chatbots how to write Automation Blocks tools, such that they are able to produce xml block script files, which human users can directly load into Automation Blocks for Premiere Pro or Automation Blocks for After Effects.

If you are a Human

If you want to ask ChatGPT to write a particular Automation Blocks script for you, for good results make sure to

  • use a reasoning model like ChatGPT o4-mini-high
  • Start your prompt with:
Please create a script for Automation Blocks for Premiere Pro. 
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:...

General Strategy for Chatbots to create Automation Blocks scripts

Automation Blocks for Adobe Premiere Pro and Adobe After Effects is based on Google Blockly XML files. There is one particular block type, (<block type="pr_execute_code" > in Pr and <block type="ae_execute_code" > in Ae), which can execute arbitrary Adobe ExtendScript code. Therefore, the easiest and most reliable approach to create a script is to first implement the entire logic in Adobe ExtendScript and then wrap it into such an execute code block.

For Premiere Pro, to create a valid Automation Blocks XML file, use this template and just insert the ExtendScript code:

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:
& → &amp;
< → &lt;
> → &gt;
" → &quot;
' → &#39;

2. Turn each line break into &#10; (or leave literal newlines
if your CMS preserves them).

Example:
var binName = "stock footage";
becomes:
var binName = &quot;stock footage&quot;;
...
-->
%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:
• & → &amp;
• < → &lt;
• > → &gt;
• " → &quot;
• ' → &#39;
-->
%YOUR_ESCAPED_CODE%
</field>
</shadow>
</value>
</block>
</xml>

Key encoding steps

  1. Escape XML specials in your ExtendScript:
  • &&amp; (and of course && by &amp;&amp;)
  • <&lt;
  • >&gt;
  • "&quot;
  • '&#39;
  1. 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 contain user interfaces. When the script is loaded into Automation Blocks, the user interface of it is shown in Automation Blocks' inputs panel.

Basic Example

Here is a basic example for Premiere Pro, which creates a user interface consisting of just one single line text field and when the script is executed, it alerts the value, which the user entered in that text field. The text field has the label "text to alert" and the default value "Hello World". When you run the script, it passes the value of the text field to an pr_execute_code block. The value of the input is available in the ExtendScript code of the pr_execute_code block in the global variable userText. The execute code block alerts that value.

<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 After Effects, the same example looks like this:

<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>

Comprehensive Example featuring all available UI Elements

A user interface element is created with a block of type "input_arg".

Here is a comprehensive example for Premiere Pro, which shows all available UI elements:

<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&amp;#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);&amp;#10;alert("sample multi line value is "+
myMultiLineText);&amp;#10;alert("sample int value is
"+myInt);&amp;#10;alert("sample float value is "+myFloat);&amp;#10;alert("sample
checkbox value is "+ (myCheckBox ? "checked":"unchecked"));&amp;#10;alert("in
the dropdown you have chosen the text
"+myDropDown);&amp;#10;&amp;#10;if(myOpenFilePath =="") alert("you didn't pick a
file in the sample open file picker")&amp;#10;else {&amp;#10; var file = new
File(myOpenFilePath);&amp;#10; alert("you picked the file with path
"+myOpenFilePath+ " to be opened and it "+ (file.exists? "exists" : "does not
exist"));&amp;#10;}&amp;#10;&amp;#10;if(mySaveFilePath == "") alert("you didn't
pick a file in the sample save file picker")&amp;#10;else {&amp;#10; var file =
new File(mySaveFilePath);&amp;#10; alert("you want to sav to the file path
"+mySaveFilePath+ " and this file "+ (file.exists? "exists" : "does not
exist"));&amp;#10;}&amp;#10;if(myFolderPath == "") alert("you didn't pick a
folder in the sample folder picker")&amp;#10;else {&amp;#10; var folder = new
Folder(myFolderPath);&amp;#10; alert("you picked the folder with path
"+myFolderPath+ " and this folder "+ (folder.exists? "exists" : "does not
exist"));&amp;#10;&amp;#10;}</field>
</shadow>
</value>
</block>
</xml>

This example creates a user interface with

  • a single line text input
  • a multiline text input
  • an int number picker
  • a float number picker
  • a checkbox
  • a dropdown list containing the three texts "option 1", "option 2", "option 3"
  • a file picker where the user can pick a file path that he intends to be opened.
  • a save file picker where the user can pick a file path where the user intends to save a file to.
  • a folder picker, where the user can pick the path of a folder.

The ExtendScript code then alerts step by step the values of those inputs. From this example, you can learn which user interface elements exist and how to pass their values into the execute code block.

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 "", which describes the number of variables. So if you have entries ADD0,...,ADD5 you need the tag to be "".

More Examples

This script creates two number inputs and then alerts the sum of these numbers:

<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;&amp;#10;alert("the sum is "+sum);</field>
</shadow>
</value>
</block>
</xml>

General Block Attributes

<block> tags have an attribute id, which must be a unique, random string. Top level blocks may also have attributes x and y, which denote the position of the block when rendered on the canvas. But they are not relevant for the program logic, so you can skip those.

General Tips for the Program Logic

log()

You can write log messages to the console panel of Automation Blocks by calling in the ExtendScript code the function $._extAutomationBlocks.all.log("My log message here") . This is very helpful for trouble shooting. If the user reports that a particular script is not working as expected, for trouble shooting it can be very helpful to add detailed log messages to understand what the script is doing step by step.

Be careful when deleting or moving project items, track items etc.

If you move the second item in a bin, the third one may become the new second one. Therefore, to avoid skipping items accidentally, it is a good idea to process items in reverse order when you plan to move or delete them.

More Resources

Use the following documentations to understand the ExtendScript API in full detail: