AIML Docs

SendObject Element

Element for sending object responses

SendObject Element

Coming soon: This feature is not yet available. Please check back soon.

The <sendObject> element injects an object into the response stream:

<sendObject value={({state}) => ({
    count: state.count,
    timestamp: new Date()
  })} />

Props

PropTypeDefault
value?
object
(the output of the previous element)

Examples

Basic Object

<sendObject value={() => ({
    status: "success",
    code: 200,
    message: "Operation completed"
  })} />

State Data

<sendObject value={({state}) => ({
    user: {
      id: state.userId,
      name: state.userName,
      role: state.userRole
    },
    session: {
      id: state.sessionId,
      startTime: state.sessionStart,
      lastActivity: state.lastActivity
    }
  })} />

Complex Response

<sendObject value={({state, error}) => ({
    status: error ? "error" : "success",
    data: {
      results: state.results,
      metadata: {
        total: state.total,
        page: state.page,
        pageSize: state.pageSize
      }
    },
    error: error ? {
      code: error.code,
      message: error.message,
      details: error.details
    } : null,
    timestamp: new Date().toISOString()
  })} />

Usage Notes

  • Sends structured data
  • Supports nested objects
  • Can include computed values
  • Handles complex data types

On this page