Prompting for variables
- Dernière mise à jour2025/09/11
Using Co-Pilot for Automators, developers can specify the value and map a variable with a natural language prompt.
Co-Pilot for Automators Co-Pilot assists development with creating variables in two ways. First, developers can send a single prompt with instructions for the properties of one or multiple variables to create them to specifications. Second, a variable is created and mapped automatically to any action that requires a variable, unless an existing variable is referenced in the prompt. A default naming convention is used for any variables created automatically.
Best practices when prompting for variables
- Properties and a default value for custom variables should be set at the instance of prompting for variable creation. For best results, use a single prompt to set all properties and create the variable.
- By adding and creating your variables before prompting for the scenario, your variables can be referenced as inputs in your prompt. Use this order to enhance efficiency.
-
Prompting to change (update) the value or property of an existing variable results in the corresponding assign action for those updates.
Prompting to create variables
- Create a new variable.
- Properties like the name, type of variable, and how the variable should be used (input,
output, constant) are recognized in your prompt. Existing variables can
then be referenced by another prompt and mapped to an existing action.
Example shows prompts entered one at a time.
-
Create an input string variable named Var1 and assign it the value "Hello, world!"
-
Set the message box to display Var1.
Tip: Alternatively, the first prompt can be entered shorter:Create an input string variable ‘Var1’ = "Hello, world!"
-
- Add an action with a new variable mapped.
- When adding a new action to your automation, you can easily create and simultaneously map
a new variable to the new action with a single prompt. Example:
Add a message box and assign it a new input string variable named Var1 with the value "Hello, world!"
- Create multiple variables in a single prompt.
- When creating multiple variables with a single prompt, use a comma or
full stop punctuation to separate instructions for each variable.
Examples show two prompts resulting in the same output.
-
Create an input string variable named Var1, an output string variable named Var2, and an input and output variable named Var3. Assign Var1 the value "open", Var2 the value "closed", and Var3 the value "pending".
-
Create an input string variable 'Var1' = "open", an output string variable 'Var2' = "closed", and an input and output variable 'Var3' = "pending".
-
- Create and set properties for predefined (system and string) variables.
- Predefined variables (date time, system settings, and string) are often used to add
meta-data into automation, for tracking and calculations. While the
value of these variables is predefined by the user system and machine,
properties for these variables can be assigned and leveraged through
prompting.
The following prompt automatically builds steps to capture the system time, add to it, and return the calculation back to the user in a message box. Co-Pilot automatically creates the variables and maps them for calculation and the returning display.
Example:See more about working with system variables, Variables prédéfinies.Get the current time and then add 5 minutes. In a message box, display the calculated time.
- Automatically convert the data type within the scenario.
- The data type of variables can be automatically converted by Co-Pilot when
generating the scenario. This capability automatically creates the
logical steps needed to transition data from string to numerical data,
make a calculation, and return the data to the user as a string in a
message. This reduces the need for specialized knowledge when developing
automation.
The following example automatically builds steps to collect input from the user, subtract 1 from the input, and display the resulting number. Co-Pilot automatically creates the string variable for the input, converts the value to a number for calculation, then converts the numerical value back to string for the display.
Example:1. Ask the user to enter a number. 2. Reduce that number by 1. 3. Display that number for 5 secs. 4. Repeat 2 and 3, until the number becomes 0 or -1.
- Create variables with unique properties.
- Support is provided for variables such as Table, and Session type that
might have unique properties. Ensure you include the complete set of
properties for these variable types in the prompt. For table type
variables the dimensions and a default cell value can be specified in
the instruction.Examples:
-
Create a terminal session variable named pSessTerminal.
-
Create a 3x4 table variable with default value 0, named pTableVar1.
-
Automatically create variables
Co-Pilot helps developers focus on automation results and the operations of actions by helping with some of the tedious work of variable creation. If a variable does not exist and one is needed for the action described by a prompt, a variable is automatically created and mapped to the action requiring it. When variables are created this way a standard naming convention is applied, determined by the type of variable (pBool, pDict, pStr). When ready, the developer can then manually edit any variables to set the value and any other properties.
Add a Prompt to the path of the folder
.
Credential variables
- Locker name
- Credential name
- Attribute: username, password, Client ID, etc.
Learn more about credential variables in the following topic. See, Informations d'identification et variables d'informations d'identification dans l'Bot editor.
- Further details on the properties and behaviors of variables are available. See, Aperçu des variables
- Variables dependent on Control Room files are supported, such as bot, form, process, and API Tasks. See, Invite à ajouter un fichier de dépôt existant.