Prompting for loops
- Zuletzt aktualisiert2025/07/08
Co-Pilot for Automators (Co-Pilot) supports loop logic in natural language prompts and can recognize the type of iterator based on the action.
Developers can capitalize on Co-Pilot to accelerate the development process using a natural language prompt. When building an automation scenario that needs loop logic, developers can simply describe the scenario to quickly generate and sequence the necessary actions and iterator type. With the required actions and iterator established in the canvas, developers can focus on specializing the automation with values of variables and configurations.
Instructions of your prompt
When sending a prompt through Co-Pilot, you directly engage the orchestrator where instructions are recognized by actions available in the Bot editor. Co-Pilot then populates and sequences those actions into a structure on the canvas for further development. When writing instruction for prompts to build loops, the generated structure includes the sequenced actions you describe and automatically sets the iterator type and items for the automation to loop through, relative to the actions. The remaining work becomes much easier with the structure visibly available to review and edit where remaining details are needed.
Loop logic is recognized by the instructions and parameters described in a prompt
when an iterator exists for an action. The type of loop is generated respective to
the properties of the items (ex. for each file in a folder
,
while a program is open
).
Verify results
After the loop is generated via prompt, verify the configurations in the action settings to ensure accuracy of the resulting automation. For example, if the iterator type is files in a folder, the folder path is a property you enter in your prompt and should verify in the action settings.
File iterator
When looping through files, Co-Pilot inherently understands file attributes and plan and reason for the goal described in the user prompt. Notice the following example includes the path for the file, name of the file, and the extension.
For example: For each folder and file in C:\Users\Name\Documents, if any
excel file is found, then check for the worksheet ‘Main’. If available, then
save it as a PDF in the same folder.
A dictionary variable is automatically created to store transient data of loop action, while running.
- Name
- Date
- Extension
- Exist or does not exist
Example: For each file in the folder C:\Users\Name\Documents, show the file
extension in a message box.
Properties for this iterator can be reviewed. See, Iteratorbezogene Bedingungen.
Email iterator
When prompting to loop through emails, best results use an established Control Room connection with your email server. Notice the following example includes the saved email connection and the condition for attachments.
- Uses the Outlook package to build the automation with a preconfigured
connection.
Move all emails in 'OutlookConnection' to the 'Finance' folder if attachments have more than 3 files.
- Uses the email package to build the automation, leaving you to configure
your email server.
Move all emails in to the 'Finance' folder if attachments have more than 3 files.
Like the file iterator, a dictionary variable is used to store data while the loop is running. Here you can leverage many properties coming from the meta-data of emails with Co-Pilot inherently understanding email attributes.
|
|
Example: For each email in 'OutlookConnection' show the sender in a message
box.
See, Verwendung des Iterators „Für jede E-Mail im Postfach“.
Best practices
- Add variables before sending prompt.
- Any variables required in the instructions should be added to the
automation file before sending the prompt. Variables existing in the
file are recognized in the prompt by proper naming convention
(
$var1$
), and mapped accordingly in the automation. Variables that do not exist in the file and are required for the automation described by your prompt are generated by default. These default variables need verification and configuration to set the values, after the prompt has been entered. - Include complete automation scenario in prompt, where possible.
- When you are ready to enter your prompt, describe your whole automation scenario in a single prompt. If the scenario is too long or complex, divide the scenario into sections of operations. Then enter a prompt for each operation to your automation flow by section.
Get started
Use the following example to build your automation using prompts. See, Beispiel für eine Eingabeaufforderung zu Schleifenlogik