Tutorial: Market price lookup

A focused walkthrough of the database node — read a row with a filter and render its columns straight into the reply.

What you'll build

A short-code where a farmer types a crop name and instantly gets today's market price, read from a table you manage. This is the Farmer Market Prices template, explained step by step.

Prerequisites

In Database create a prices table with name, price and unit columns and add a few rows.

1 · Ask for the crop

After start, an input node captures the crop name into a variable used by the database filter.

input (crop) · data
{ "prompt": "Enter a crop name (e.g. maize):", "variable": "crop" }

2 · Read the price

Add a database node set to read. The filter matches the row by name; each column of the matched row becomes a variable, and saveAs stores the whole row as JSON.

database (lookup) · data
{
  "operation": "read",
  "collection": "prices",
  "filter": { "name": "{{crop}}" },
  "saveAs": "priceRow"
}
Returned columnBecomes
price{{price}}
unit{{unit}}
whole row (JSON){{priceRow}}
Leave filter empty to read the most recent row, or add more keys to narrow the match. The same node does write, update and delete too.

3 · Reply with the price

Finish with an end node that interpolates the columns the read produced.

end · data
{ "message": "Today's price for {{crop}}: GHS {{price}} per {{unit}}." }

Test it

In the simulator the database read echoes your real table data. Type a crop you seeded and confirm the price renders. To go further, add a condition node to branch on the result — see Flows & the Studio.