Skip to main content
Several Pastures pages include “Diagnose →” links that open the AI drawer with a pre-filled query, giving users one-click access to AI diagnostics for a specific issue.

Pages with Ask AI buttons

How it works

When a user clicks a “Diagnose →” link, the page dispatches a CustomEvent on the window object:
The AI drawer listens for this event. When received, it:
  1. Opens the drawer (if not already open)
  2. Pre-fills the input textarea with detail.query
  3. Automatically submits the query
This means the user sees the drawer open and immediately begin generating a diagnosis — no manual typing required.

Integration pattern

To add a “Diagnose →” button to any Pastures page, dispatch the event with the relevant diagnostic text:
The event-based pattern means any page — including custom pages added by contributors — can integrate with Pastures AI without importing drawer components directly.

Behavior details

  • If the drawer is already open, a new event replaces the current input and submits
  • The pre-filled query appears in the user’s message history as if they typed it
  • Context awareness still applies — if the user is on the Advisories page, page-specific suggestions remain available after the conversation