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

  1. In the flow builder, open the Variables tab of the Flow elements panel.
  2. Click New variable.
  3. Enter a Name — for example dataset. Names starting with system_ are reserved.
  4. Optionally add a Description, shown to whoever runs the flow.
  5. Leave Required on if a run cannot do without a value.
  6. 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.
  7. 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 ?dataset wherever the value should go: Imported ?dataset.
  • In an inline SPARQL query: use a query variable with the same name. In select * { ?s ?p ?dataset }, ?dataset is 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

  1. Add a Set variables task (under Data processing) and connect it before the tasks that need the value.
  2. To query a dataset, connect it as the task's input.
  3. Under Query, write a SELECT query that selects the variables to set: select ?latest { … } order by desc(?date). Only its first row is used.
  4. Use ?latest in 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

  1. Open Masked values in the flow's navigation and click Add masked value.
  2. Enter a Name — API_KEY, say — an optional Description, and the Value.
  3. Click Save.
  4. Use it in a task as ?API_KEY, like any variable. In an Import from web or Send request task, for example, add a header Authorization with the value Bearer ?API_KEY under 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.

  1. Open Presets in the flow's navigation and click Add Preset.
  2. Give it a label, fill in the Variables, and click Save.
  3. 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.