> ## Documentation Index
> Fetch the complete documentation index at: https://flywheel.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Find Event (Agent Tool)

> Search past events so the agent can make decisions from user activity

<iframe src="http://localhost:3000/doc-comp-previews/agent-node-preview?type=find_event" title="Agent Node Preview" width="100%" height="250px" className="border dark:border-[#1C1C20] rounded-xl" />

## How Find Event works

Find Event lets your agent query existing event data during a run. This is useful when the trigger event alone does not contain enough context to decide what action to take. The agent can look up any named event for the current user, apply filter conditions to narrow results, and choose whether to return the newest or oldest match. The returned event object — including its custom properties — becomes part of the agent's working context for downstream tool calls and decisions.

## Configuration

<Columns cols={2}>
  <Card title="Inputs">
    <ParamField path="Prompt" type="string">
      Guidance for when the agent should call this tool.
    </ParamField>

    <ParamField path="Event Name" type="string">
      The event to search for.
    </ParamField>

    <ParamField path="Query Conditions" type="object[]">
      Optional filter conditions to narrow matches.
    </ParamField>

    <ParamField path="Selection Strategy" type="enum" default="newest">
      Which matching event to return. **Options:** `newest`, `oldest`.
    </ParamField>
  </Card>

  <Card>
    <iframe src="http://localhost:3000/doc-comp-previews/agent-config-preview?type=find_event" title="Agent Config Preview" width="100%" height="460px" className="" />
  </Card>
</Columns>

<Card title="Outputs">
  <ParamField path="event" type="object" required>
    The found event data that matches the search criteria.

    <Expandable title="Event Properties">
      <ParamField path="event.event_name" type="string" required>
        The name of the found event.
      </ParamField>

      <ParamField path="event.timestamp" type="string" required>
        ISO 8601 timestamp of when the event occurred.
      </ParamField>

      <ParamField path="event.org_user_id" type="string" required>
        The user associated with the event.
      </ParamField>

      <ParamField path="event.custom_properties" type="object">
        Key-value map of custom data attached to the event at ingestion time.
      </ParamField>

      <ParamField path="event.source" type="string">
        Origin of the event (e.g. SDK, API, integration).
      </ParamField>

      <ParamField path="event.event_id" type="string">
        Unique identifier for the event record.
      </ParamField>
    </Expandable>
  </ParamField>
</Card>

## Use Cases

**Behavior Analysis**

```
Event Name: purchase_completed
Query Conditions: purchase_amount > 100
Selection Strategy: newest
Use: Personalize recommendations based on recent high-value purchases
```

**Feature Usage Tracking**

```
Event Name: feature_activated
Query Conditions: feature_name = "advanced_reporting"
Selection Strategy: newest
Use: Confirm feature adoption before sending upgrade prompts
```

**Onboarding Progress**

```
Event Name: onboarding_step_completed
Query Conditions: step_index >= 3
Selection Strategy: oldest
Use: Determine where a user stalled in the onboarding flow
```

**Support Context Enrichment**

```
Event Name: support_ticket_created
Query Conditions: priority = "high"
Selection Strategy: newest
Use: Give the agent recent support history before composing outreach
```

## Best Practices

**Efficient Queries**

* Use specific event names rather than broad searches to keep lookups fast.
* Apply query conditions to filter irrelevant matches before they reach the agent.
* Prefer `newest` selection when recent behavior matters most; use `oldest` for first-occurrence analysis.

**Context Utilization**

* Combine event data with user properties for richer decision-making.
* Reference custom properties from the returned event in downstream tool prompts.
* Chain Find Event with other tools (e.g. Smart Message, Set Custom Property) so the agent acts on real activity data.

**Data Management**

* Ensure event names follow a consistent naming convention so the agent can reliably locate them.
* Keep custom property schemas stable across event versions to avoid unexpected nulls.
* Use query conditions as guardrails to prevent the agent from acting on stale or irrelevant events.
