Use variables in a flow¶
This page covers giving a flow values that change from run to run — a file URL, a dataset name, an API key. For what variables are and why, see Variables; for their properties and where a run's values come from, the Flows reference.
Define a variable¶
- In the flow builder, open the Variables tab of the Flow elements panel.
- Click New variable.
- Enter a Name — for example
dataset. Names starting withsystem_are reserved. - Optionally add a Description, shown to whoever runs the flow.
- Leave Required on if a run cannot do without a value.
- To limit the values a run may give it, click Add option under Allowed options for each one. The run dialog then offers a list instead of a text field.
- Click Save, then Save the flow.
The system variables, such as system_triggererAccountName and system_triplyToken, are listed
under System variables; they need no defining. A run started by a hook also gets variables
describing the upload; see System variables.
Use a variable in a task¶
- For a whole field: click $ beside the field and pick the variable, or Create a new variable to define one on the spot. This works for the fields in a task's settings and for the account, dataset and graph names of its inputs and outputs.
- Inside text: in an email subject or body, a request's headers or body, or a Stop run
message, write
?datasetwherever the value should go:Imported ?dataset. - In an inline SPARQL query: use a query variable with the same name. In
select * { ?s ?p ?dataset },?datasetis replaced by the flow variable's value, as a string literal. - In a saved query: give its API variables a value under Query variables, choosing the flow variable.
Set a variable from a query¶
- Add a Set variables task (under Data processing) and connect it before the tasks that need the value.
- To query a dataset, connect it as the task's input.
- Under Query, write a SELECT query that selects the variables to set:
select ?latest { … } order by desc(?date). Only its first row is used. - Use
?latestin the later tasks like any variable. The Variables tab lists it under Task output variables.
See Set variables for how the values are converted and when a flow cannot run.
Store a credential as a masked value¶
- Open Masked values in the flow's navigation and click Add masked value.
- Enter a Name —
API_KEY, say — an optional Description, and the Value. - Click Save.
- Use it in a task as
?API_KEY, like any variable. In an Import from web or Send request task, for example, add a headerAuthorizationwith the valueBearer ?API_KEYunder Request headers.
Only people with the Manage flow masked variables permission see and change the value; everyone who may run the flow can use it.
Save a set of values as a preset¶
A flow needs at least one variable first.
- Open Presets in the flow's navigation and click Add Preset.
- Give it a label, fill in the Variables, and click Save.
- To have its values filled in whenever someone runs the flow or adds a schedule, switch on Default preset.
To run a flow with a preset, see Run a flow.