Skip to main content

functions.data_map

ai.SWAIG.functions.data_map defines how a SWAIG function should process and respond to the user's input data.

NameTypeDefaultDescription
data_mapOptionalobject-An object that contains the data_map Parameters.

data_map Parameters

Processing Order

The components are processed in the following sequence:

  1. expressions - Processes data using pattern matching (includes its own output)
  2. webhooks - Makes external API calls (includes its own output and expressions)
  3. output - Returns a direct response and actions to perform

Similar to a return statement in conventional programming languages, when a valid output is encountered within any component, it immediately terminates function execution. The output provides:

  1. A response object: Contains static text for the AI agent's context
  2. An optional action object: Defines executable actions to be triggered

If no component produces a valid output, the system continues processing in sequence:

  • First attempts expressions
  • If unsuccessful, tries webhooks
  • If still unsuccessful, attempts top-level output
  • If all fail, returns a generic fallback error message
NameTypeDefaultDescription
expressionsRequiredobject[]-An array of objects that have pattern matching logic to process the user's input data. A user can define multiple expressions to match against the user's input data.
webhooksRequiredobject[]-An array of objects that define external API webhooks that can be used to make external API calls.
outputRequiredobject-An object that defines the output of the SWAIG function. Behaves like a return statement in traditional programming.

Examples:

  1. Executing SWML from a SWAIG function