Data
Key-value state
A store that survives the run, so a cursor, a dedupe set or a counter is still there next time.
Most automations need to remember something between runs: the last row they processed, the messages they have already answered, how many times something happened today. Every workflow has a key-value store for exactly that, already there, nothing to set up.
Scopes
| Scope | Shared by |
|---|---|
| Workflow | every run of one workflow, and everybody who works on it |
| Account | every workflow on the account, for what belongs to more than one |
The steps
| Step | What it does |
|---|---|
| Get | Read the value under a key. A key that is not there is an answer, not an error: you get found: false and a fallback you choose. |
| Set | Store a value under a key, optionally forgotten after a time you choose. |
| Delete | Remove a key. |
| List | The keys that are stored, optionally under a prefix and with their values, ready to loop over. |
| Increment | Add to a number, for counters. |
| Seen before? | Whether a value has been seen before, and remember it if not. The one-step answer to "never handle the same thing twice". |
From code
A step that runs code, the Code step or your own, reaches the same store through context.state:
const seen = (await context.state.get("seen")) ?? []
if (!seen.includes(input.id)) {
await context.state.set("seen", [...seen, input.id])
}Reading and fixing it by hand
State is written from inside runs, where nothing can be inspected while it happens. So the store has a panel: open Data in the dashboard, or the store panel on the canvas, to read what a run left behind, change it by hand, and run again.
Patterns
Was this page helpful?