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

# Ask AI (Professor High) Flow

> The complete Ask AI user flow — from opening a chat through tool invocation, visual card rendering, and conversation history management.

## Overview

Ask AI is the conversational interface to Professor High — strain research, cannabis science, and terpene education. This flow documents how users interact with Professor High from opening a chat to getting personalized responses.

<Note>
  As of May 2026, the chat architecture was rebuilt on a new foundation. Personal data tools (stash access, favorites, orders, strain search, dispensary scanning) documented in this flow are currently dormant and being re-wired. They will return in a future update. Text-based cannabis Q\&A is fully functional.
</Note>

## Chat Interaction Flow

```mermaid theme={null}
sequenceDiagram
    participant U as User
    participant App as High IQ
    participant API as AI Backend
    participant Tools as 13 AI Tools
    participant DB as Convex

    U->>App: Open Ask AI
    App->>U: Show chat with suggested queries

    U->>App: Type question
    App->>API: Send message + conversation context

    API->>API: Analyze intent
    API->>Tools: Select and invoke tools

    loop Tool Execution (autonomous)
        Tools->>DB: Fetch user data (if personal query)
        DB-->>Tools: User stash/favorites/orders/etc.
        Tools-->>API: Tool results
    end

    API->>API: Generate response with tool context
    API-->>App: Stream response + tool result cards

    App->>U: Display text + visual cards
    App->>DB: Auto-save conversation
```

## Tool Selection Decision Tree

```mermaid theme={null}
graph TD
    A[User Question] --> B{Intent Classification}

    B -->|Personal Data| C{Which Data?}
    C -->|Stash| C1[My Stash Tool]
    C -->|Favorites| C2[My Favorites Tool]
    C -->|Orders/Spending| C3[My Orders Tool]
    C -->|Stats| C4[My Stats Tool]
    C -->|Preferences| C5[My Preferences Tool]
    C -->|Collection/Rankings| C6[My Collection Tool]

    B -->|Strain Research| D{Type of Research}
    D -->|Search by Name| D1[Search Strains Tool]
    D -->|Specific Strain| D2[Strain Details Tool]
    D -->|Find Similar| D3[Similar Strains Tool]

    B -->|Action Request| E{What Action?}
    E -->|Favorite/Unfavorite| E1[Toggle Favorite Tool]
    E -->|Scan Menu| E2[Scan Menu Tool]
    E -->|Get Recommendations| E3[Recommendations Tool]

    B -->|General Knowledge| F[Web Search Tool]

    B -->|Multi-Intent| G[Multiple Tools Chained]
    G --> G1[Example: What should I smoke?]
    G --> G2[Uses: My Stash + My Preferences + Recommendations]
```

## Query Types and Tool Chains

```mermaid theme={null}
graph TD
    A[What's in my stash?] --> B[My Stash Tool]
    B --> C[Stash Data Card]

    D[Compare OG Kush and Blue Dream] --> E[Strain Details x2]
    E --> F[Side-by-Side Strain Cards]

    G[What should I smoke tonight?] --> H[Chain: My Stash → My Preferences → Recommendations]
    H --> I[Personalized Suggestion with Reasoning]

    J[Add Girl Scout Cookies to favorites] --> K[Toggle Favorite Tool]
    K --> L[Confirmation + Updated Favorites]

    M[What's available at my dispensary?] --> N[Scan Menu Tool]
    N --> O[Background Scan Started Card]

    P[How much have I spent?] --> Q[My Orders Tool]
    Q --> R[Spending Summary Card]
```

## Visual Card Types

```mermaid theme={null}
graph TD
    A[Tool Results] --> B{Card Type}

    B --> C[Stash Item Cards]
    C --> C1[Strain name + quantity + type]

    B --> D[Favorite Cards]
    D --> D1[Strain name + type badge]

    B --> E[Order Cards]
    E --> E1[Date + dispensary + total]

    B --> F[Stats Summary Card]
    F --> F1[Metrics grid]

    B --> G[Strain Result Cards]
    G --> G1[Name + effects + terpenes preview]

    B --> H[Strain Detail Card]
    H --> H1[Full profile preview]

    B --> I[Web Search Cards]
    I --> I1[Favicon + title + domain + link]

    B --> J[Scan Progress Card]
    J --> J1[Live progress indicator]

    B --> K[Collection Cards]
    K --> K1[Ranking position + ELO score]

    B --> L[Preference Cards]
    L --> L1[Preferred effects + methods]
```

## Conversation History Flow

```mermaid theme={null}
graph TD
    A[Chat Session] --> B[Auto-Save on AI Response]
    A --> C[Auto-Save on Screen Leave]

    B --> D[Saved to Cloud]
    C --> D

    D --> E[User Returns to Ask AI]
    E --> F{Resume or New?}

    F -->|Resume| G[Tap History Button]
    G --> H[List of Past Conversations]
    H --> H1[Preview Text]
    H --> H2[Message Count]
    H --> H3[Date/Time]
    H --> I[Tap to Resume]
    I --> J[Full Context Restored]

    F -->|New Chat| K[Tap New Chat]
    K --> L[Fresh Conversation]
    L --> L1[Previous chats preserved]
```

## Suggested Queries Flow

```mermaid theme={null}
graph TD
    A[Open Ask AI] --> B{User Has Data?}

    B -->|Has Stash Data| C[Personal Suggestions]
    C --> C1[What's in my stash?]
    C --> C2[What should I smoke tonight?]
    C --> C3[Tell me about my favorites]

    B -->|Has Orders| D[Analytics Suggestions]
    D --> D1[How much have I spent?]
    D --> D2[What are my top strains?]

    B -->|New User| E[Discovery Suggestions]
    E --> E1[Tell me about Blue Dream]
    E --> E2[What terpenes help with sleep?]
    E --> E3[Find me a relaxing indica]

    C --> F[Tap Suggestion]
    D --> F
    E --> F
    F --> G[Auto-populates Input]
    G --> H[Send Message]
```

## Edge Cases

| Scenario                             | Behavior                                                      |
| ------------------------------------ | ------------------------------------------------------------- |
| User asks non-cannabis question      | Polite redirect to cannabis-related topics                    |
| Tool returns empty data              | "I don't have any \[data type] for you yet" message           |
| Multiple tools needed simultaneously | Chained execution, all results displayed                      |
| Network error during response        | Error message with retry option                               |
| Very long AI response                | Scrollable, streaming display                                 |
| User sends while AI is responding    | Queued, processed after current response                      |
| Conversation exceeds context limit   | Older messages summarized automatically                       |
| Tool times out                       | Graceful fallback with partial response                       |
| User asks to modify data             | Only Toggle Favorite is supported, others explained           |
| Sensitive medical question           | Disclaimer: educational only, consult healthcare professional |

## Related Flows

<CardGroup cols={2}>
  <Card title="Strain Discovery" icon="magnifying-glass" href="/help/user-flows/strain-discovery">
    AI-driven strain research and discovery.
  </Card>

  <Card title="Shopping Agent" icon="cart-shopping" href="/help/user-flows/shopping-agent">
    Menu scanning triggered from Ask AI.
  </Card>

  <Card title="Collection & Rankings" icon="trophy" href="/help/user-flows/collection-rankings">
    AI accessing collection and ranking data.
  </Card>

  <Card title="Stats & Analytics" icon="chart-pie" href="/help/user-flows/stats-analytics">
    AI surfacing analytics insights.
  </Card>
</CardGroup>
