Skip to main content
The EventBuilder provides a chainable API for constructing events. Start a builder with client.event(), then chain methods to add data.

Starting a builder

const builder = client.event("movie-bot", { agentId: 1, sessionId: 5001 });
ParameterTypeRequiredDescription
agentTypestringYesAgent classification (e.g., "movie-bot")
configEventBuilderConfigNoOptional agentId and sessionId overrides

Builder methods

action(name, params)

Define an Action event — use this whenever your agent does something (calls an API, books a seat, sends an email).
client.event("movie-bot")
  .action("book_movie_ticket", { movie: "Interstellar", seat: "H12" })

outcome(result)

Attach a success outcome to the previously defined action.
outcome() requires action() earlier in the chain. Calling it without action() will throw an error.
client.event("movie-bot")
  .action("book_movie_ticket", { movie: "Interstellar", seat: "H12" })
  .outcome({ confirmation_id: "CONF-123" })

observation(type, data, options?)

Define an Observation event — use this when the agent receives external data that isn’t a direct message (price updates, sensor readings, API responses).
client.event("movie-bot")
  .observation("ticket_availability", { remaining_seats: 5 })
The data parameter is stored verbatim — the SDK does not validate payload fields.

context(text, type?)

Define a Context event for claim extraction. Use this for raw text content like conversation messages, documents, or transcripts.
client.event("movie-bot")
  .context("I want to book Interstellar for tonight.", "conversation")

state(variables)

Add environmental state variables to the event context.
client.event("movie-bot")
  .action("search_movies", { genre: "sci-fi" })
  .state({ mode: "strict", user_tier: "premium" })

goal(text, priority?, progress?)

Attach an active goal. Goals are how Minns Memory Layer groups events into episodes.
client.event("movie-bot")
  .action("book_movie_ticket", { movie: "Interstellar" })
  .goal("book_movie", 5)         // Priority 1-5
  .goal("upsell_snacks", 2, 0.0) // Second goal, lower priority
Set progress to 1.0 on the final event to mark the episode as complete. This triggers memory formation and strategy extraction.

causedBy(parentId)

Link the event to a parent event, building a causality chain.
client.event("movie-bot")
  .action("confirm_booking", { booking_id: "BK-42" })
  .causedBy("previous-event-id")

build()

Return the raw Event object without submitting it.
const event = client.event("movie-bot")
  .action("search_movies", { genre: "sci-fi" })
  .build();

// Inspect or modify the event before submitting
console.log(JSON.stringify(event, null, 2));

send()

Build and submit the event. Returns the server response.
const response = await client.event("movie-bot")
  .action("book_movie_ticket", { movie: "Interstellar" })
  .outcome({ confirmation_id: "CONF-123" })
  .goal("book_movie", 5, 1.0)
  .send();

enqueue()

Build and queue the event for background processing. Returns a local receipt immediately.
const receipt = await client.event("movie-bot")
  .observation("price_update", { movie: "Interstellar", price: 12.99 })
  .enqueue();

Full example

// Complete booking flow event
const response = await client.event("movie-bot", { agentId: 1, sessionId: 5001 })
  .action("book_movie_ticket", {
    movie: "Interstellar",
    seat: "H12",
    showtime: "2026-02-06T19:30:00Z"
  })
  .outcome({ confirmation_id: "CONF-123", total: 15.99 })
  .state({ user_tier: "premium", location: "downtown" })
  .goal("book_movie", 5, 1.0)
  .causedBy("evt-search-results")
  .send();

console.log(`Created ${response.nodes_created} nodes in ${response.processing_time_ms}ms`);

Next steps