Skip to navigation

Data bank and data mapper concepts

View as Markdown

The data bank is the set of values a plugin can use while it runs: slots the user gave, outputs from earlier steps, and facts about the user. A data mapper is the short YAML you write to pick values out of the data bank and build what the next step needs. Read this page first if you’re about to fill in an Input Mapping, Output Mapping, Strategy Mapping, Output Mapper or Body Mapping field.

What’s in the data bank?

Each part of a plugin has its own data bank. A value from one part reaches another only when you map it across. The data bank has two top-level keys, plus a few keys that exist only in one place.

KeyWhat it holdsWhere you can use it
data.<slot_name>A slot value the user gave or the AI agent inferredConversational processes
data.<output_key>The output an activity saved under its Output Key, or a compound action step (an action or an expression such as for) saved under its output_key. Read a field with a dot, for example data.device.asset_uuid.Conversational processes, compound actions
data.<input_arg>An input argument of a compound action or a resolver methodCompound actions, resolver methods
meta_info.user.<attribute>The user who triggered the plugin. See the User Attribute Reference.Conversational processes (except content activities), resolver methods and slot validation policies. HTTP actions and compound actions only when they run for a user, for example when a conversation starts them
meta_info.action_instance_idA unique ID for each HTTP action run. Use it as an idempotency key so retries don’t create duplicates.HTTP actions
responseThe raw result of the action you’re mappingOutput mapping on action activities and resolver methods
valueThe slot value being checked. See Slot Validation Policy.Slot validation policies
itemThe current element while an operator such as MAP(), FILTER() or SORT() loops over a listInside those operators

Using a key outside the places listed causes a reference error. In an HTTP action, input arguments are referenced by name alone, such as title, not data.title.

meta_info.user in compound actions

A compound action has meta_info.user only when it’s started from a conversation. A compound action started by a schedule or a webhook has no conversational user, so resolve the user yourself and map it in.

Don’t give a slot and an output key the same name. Each key in a data bank should be unique, or the reasoning engine can confuse them.

What does a data mapper do?

A data mapper builds a new object. Each key is a field you want in the result, and each value is an expression that reads from the data bank:

title: data.book_title
note: data.reading_note.$TRIM()
requested_by: meta_info.user.email_addr

This fragment builds an object with three fields: two from slots and one from the user’s profile. The $TRIM() call is a DSL function. DSL expressions can run inside any mapper value.

Use a data mapper when you need to:

  • Keep types. Lists stay lists and numbers stay numbers. In a Mustache template they become text, which needs workarounds such as $STRINGIFY_JSON().
  • Reshape data. Rename, merge or conditionally include fields, pull nested values up, or build nested objects for an API.
  • Loop and filter. Turn a list into another list with MAP(), FILTER() or SORT().
  • Keep less. An output mapping replaces the action’s result. Only the fields you map are kept: later steps and the reasoning engine see just those, and, for the last activity in a process, so does the user.

Where do you map data?

The same mapper syntax appears in every one of these fields. What changes is which data bank you read from and where the result goes.

WhereField in Tool StudioReads fromProduces
Action activityInput MappingThe process data bank: slots, earlier outputs, meta_info.userThe action’s input arguments
Action activityOutput Mapping (a dot-walk on response, or Switch to data mapper)responseThe value saved under Output Key
SlotResolver Strategy > View Strategy MappingThe process data bankInputs for each dynamic resolver method
Resolver methodInput MappingThe method’s data bank: its input arguments and any keys Strategy Mapping sets (data.<key>), and meta_info.userThe action’s input arguments
Resolver methodOutput MappingresponseThe candidate values, shaped by Output Cardinality
Compound action stepinput_argsCompound action input arguments, earlier output_key valuesThe step’s action inputs. See the example after this table.
Compound actionReturn step > Output MapperThe compound action data bankWhat the compound action hands back to its caller
HTTP actionBody > Data Mapper (Body Mapping)The HTTP action’s input arguments, meta_infoThe JSON request body

In a compound action, a later step reads an earlier step’s output through its output_key:

steps:
- action:
action_name: get_user_device
output_key: device
input_args:
user_email: meta_info.user.email_addr
- action:
action_name: clean_recycle_bin_on_device
output_key: remote_action_result
input_args:
device_id: data.device.asset_uuid # References output from first action

Each surface’s own page covers its options: Activities, Resolver Strategies, Pass data to dynamic resolvers with Strategy Mapping, Return and Data Mapper in HTTP Actions.

Two rules that catch new builders

A bare value is a data bank reference. status: approved looks for a key named approved; it doesn’t send the text “approved”. Quote constants: status: '''approved''' for text and count: '5' for a number. The quoting table is in String constants in YAML.

An output mapping replaces the result. If you map title: response.title, later steps get only title. Every field you leave out is gone, so map everything the next step or the AI agent needs.

Data mapper, Mustache, DSL or a script?

You need toUse
Insert one value into fixed text, such as a URL path, the Raw JSON body of an HTTP action or a Text content activityMustache: {{ticket_id}}
Build or reshape structured data, keep types, or loop over a listData mapper
Check a condition or compute one value, such as a validation policy or a Switch caseDSL
Run logic that’s too complex for a mappingA script action

Decision frameworks explains when a mapping gets too complex and a script is the better choice.

Test a mapper and look up syntax