Environment Variable
Environment Variable returns the value of a variable from the environment linked to the flow. Use it when a value depends on where the flow runs, for example the address of a test API and of the production one, and you do not want to type it inside every component.
Because the value is read when the flow runs, the same flow works with any environment you link to it, as long as the variable has the same name in all of them.
When to use it
- The flow calls a system that has a different address in testing and in production.
- Several flows use the same identifier, such as a spreadsheet or a channel, and you want to change it in one place.
- You want to give an agent a configuration value, such as the reply language or the company name, without editing the flow.
- You need a token stored as a secret variable of the environment.
Configuration
| Field | What it does |
|---|---|
| Variable Key (required) | The variable whose value you want to read. The dropdown lists the variables of the environment linked to the flow; press the refresh button if you have just added one. |
The flow needs a linked environment. See Bind an environment to a flow.
Output
The Value output is a text with the variable’s value. If the flow has no environment, or the variable does not exist in the environment it runs with, it returns an empty text.
You can connect it to any field that takes text: the address of an API Request component, an agent’s prompt or a field of another component.
Example
A company has a flow that looks up orders in its ERP. In the Development environment the variable URL_API_PEDIDOS points to the test ERP, and in Production to the real one.
- Add Environment Variable and choose
URL_API_PEDIDOSin Variable Key. - Connect Value to the address field of the component that calls the ERP.
- Test the flow with the Development environment. When you publish it with Production, it will query the real ERP without any other change.
Good practices
- Spell variable keys the same way in all your environments; if one is missing, the component returns an empty text without warning.
- Store tokens and passwords as secret environment variables instead of typing them in components.
Related components
- Python Code and JS Code: they can also read the environment variables from their code.