1. This video explains how a workflow remembers things from one run to the next.
Databases

Remember things with databases

Keep what a workflow learns, so the next run can use it.

Refund requestsrefund_requests
OrderCustomerDate
4612Maya Chen14 Sep
4790Jonas Berg30 Oct
4805Lena Ortiz3 Nov
4821Maya ChenToday
  1. Every run starts from one event. When Maya writes in about order 4821, the jobs work from her email.
  2. When the run ends, the workflow keeps no memory of it. The next email starts a run that knows nothing about the last one.
  3. So the workflow cannot tell whether Maya asked for a refund before. For that, it needs a database.

Every run starts from one event

A finished run keeps nothing

Remembering needs a database

RunToday, 09:12
Maya ChenRefund for order 4821
Sort the request
Draft a reply
Succeeded
RunToday, 09:40
Jonas BergWrong colour, order 4790
Sort the request
Draft a reply
Running
Run14 Sep
Maya ChenRefund for order 4612
Sort the request
Draft a reply
Succeeded
Asked for a refund before?
A database
  1. Databases live in the Library. New, then Database, makes an empty one.
  2. A database holds tables. This one, Refund requests, has a row for each request.
  3. Open a table to browse and edit its rows, or use Query to find exactly the ones you need.
  4. Chat can also create tables, and read or change rows for you.

Databases live in the Library

A database holds tables

Browse, edit and query rows

Or ask Chat

LibraryNew
NameType
SupportFolder
Customer requestsWorkflow
Returns policyKnowledge document
Refund requestsDatabase
Schema Query Tables refund_requests
Refund requestsrefund_requests
refund_requests3 rowsDouble-click a cell to edit
Search this table… Filter Add row
customer_emailorder_idreasoncreated_at
maya.chen@example.com4612Scratched tray2026-09-14
jonas.berg@example.com4790Wrong colour2026-10-30
lena.ortiz@example.com4805Arrived late2026-11-03
Chat
Add a refund amount column to refund_requests
  1. In a workflow, two actions use a database. Query database reads rows, and Write to database changes them.
  2. When Maya's email arrives, a Query database job looks for her earlier refund requests.
  3. It finds one, for order 4612 in September, and passes it on in its output event.
  4. Then a Write to database job adds a row for order 4821, so the next run can find it.
  5. The draft for Sam now mentions that Maya asked once before.
  6. Agent and Code Execution jobs reach a database through their Storage Query and Storage Execute tools.

Two actions use a database

Query database reads rows

Write to database adds a row

The draft uses what it found

Agents and code can use it too

Email received
Sort the request: damaged item, delivery question, return or refund.
Find earlier refund requests from this customer.
Add the request to refund_requests.
Draft a reply for Sam that notes earlier requests.
EventDraft ready
Query database
Reads rows
Write to database
Adds, changes or deletes rows
Maya Chen
Refund for order 4821
Query database
SELECT order_id, reason, created_at FROM refund_requests WHERE customer_email = $1
1 row4612 · Scratched tray · 14 Sep
Output eventEarlier requests checked
Write to database
INSERT INTO refund_requests (customer_email, order_id, reason) VALUES ($1, $2, $3)
1 row4821 · Cracked lamp shade · Today
Draft for Sam to check
Hi Maya, I am sorry the lamp shade arrived cracked. I see you also wrote to us about order 4612 in September.
AgentandCode Execution
Storage Queryreads Storage Executewrites
  1. Each saved change to the rows also publishes an event, Rows changed.
  2. Jobs can listen for it. Here, a second workflow tells the support channel about each refund request.

Each change publishes an event

Jobs can listen for it

refund_requests
4790Jonas Berg · Wrong colour
4805Lena Ortiz · Arrived late
4821Maya Chen · Cracked lamp shade
Event type Rows changed
{
"changes": [{
"table": "refund_requests",
"operation": "INSERT",
"record": { "order_id": 4821, … }
}]
}
Rows changed
Tell #support about each refund request.
EventTeam told
A second workflow starts from the event
  1. Each job runs as its own job account, which needs access to the database.
  2. Saving a database job can give it View to read, or Edit to write. Access, under More actions, lists the databases it needs.
  3. In a test run, a write runs and then rolls back, so your tables stay as they were.
  4. Turn on Write in Permissions to keep the rows. Their Rows changed events go out too.

Each job has its own account

Saving gives it access

A test run rolls writes back

Write keeps the rows

Job: Find earlier requestsQuery database
View
Job: Log the requestWrite to database
Edit
Refund requests Needs a grant
Manage access
Log the request runs as its own job account. The access below belongs to that account.
Knowledge documents Databases Integrations Events
Refund requestsEdit
Give access
PermissionsChoose what this run is allowed to do for real.
ReadNothing here reads from your connected integrations.
Write Log the request · Write rows to a managed database and emit row events
Publish EventsEach step publishes an event that other jobs and workflows can listen for.
refund_requests3 rows4 rows
4790Jonas Berg30 Oct
4805Lena Ortiz3 Nov
4821Maya ChenRolled back
4821Maya ChenSaved
Rows changed
  1. With a database, a workflow can remember. Log every refund, count how often each customer writes in, or track orders that still need a reply.
  2. To go deeper, read the Databases page in the docs.

A workflow that remembers

Log every refund
One row for each request, written by a job
Count how often a customer writes in
A query reads the earlier rows
Track orders that still need a reply
Update the row when the reply is sent