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

# AI Chat

> Natural language data chat, slash commands, local database actions, and session management in the LeadMagic CLI

The AI chat is the primary interface of the LeadMagic CLI. Describe the outcome you want and the CLI can load files, inspect columns, clean records, call LeadMagic enrichment tools, query the local database, and export the results.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lm chat
```

Running `lm` with no arguments also starts chat — it's the default command.

## How It Works

When you type a message, the AI:

1. **Interprets your intent** — understands whether you want cleaning, enrichment, research, SQL, export, or troubleshooting
2. **Selects tools** — picks the right file, database, LeadMagic, recipe, schedule, or outbound action
3. **Executes the workflow** — runs steps in order, asks before spending credits, and stores results locally
4. **Streams progress** — shows tool calls, progress, and results as the work runs

## Example Conversations

<AccordionGroup>
  <Accordion title="Load and enrich a CSV" icon="file-csv">
    ```
    You: Load contacts.csv and show me a summary
    AI:  Loaded 1,247 rows with columns: name, email, company, title...

    You: Find work emails for contacts that are missing them
    AI:  Found 342 contacts without emails. I'll use the email finder...
         [Processing: ████████░░ 85/342 — 1 credit each]
         Found 298 emails. 44 contacts had insufficient data.

    You: Export the results
    AI:  Saved to .leadmagic/export/20260306-email-finder/contacts_enriched.csv
    ```
  </Accordion>

  <Accordion title="Validate an email list" icon="envelope-circle-check">
    ```
    You: Validate all emails in campaign-list.csv
    AI:  Loaded 5,000 emails from column "email"...
         [Validating: ████████████ 5000/5000 — 0.25 credits each]
         Results: 4,102 valid, 612 invalid, 286 unknown

    You: Remove the invalid ones and export
    AI:  Removed 612 invalid emails. Exported 4,388 contacts to
         .leadmagic/export/20260306-validation/campaign-list_validated.csv
    ```
  </Accordion>

  <Accordion title="Research a company" icon="building">
    ```
    You: What can you tell me about example.com?
    AI:  Company: Example Robotics, Inc.
         Industry: Financial Technology
         Employees: 8,000+
         HQ: San Francisco, CA
         ...

    You: What's their tech stack?
    AI:  Looking up company technographics...
         React, Node.js, Ruby, Go, AWS, PostgreSQL...

    You: Who are their main competitors?
    AI:  Searching for competitor companies...
         Adyen, Square, PayPal, Braintree, Checkout.com...
    ```
  </Accordion>

  <Accordion title="Turn a file into a repeatable workflow" icon="clock">
    ```
    You: I get this same leads.csv every Monday. Make a repeatable cleanup and enrichment flow.
    AI:  I can turn this into a recipe: normalize names, validate emails,
         find missing work emails, and export eligible contacts.

    You: Estimate the cost on this file before running it.
    AI:  Estimated 1,247 rows. Validation + email discovery will cost up to...

    You: Schedule it every weekday at 9am.
    AI:  Created schedule. Start the scheduler with lm schedule daemon.
    ```
  </Accordion>

  <Accordion title="Use local analytics" icon="database">
    ```
    You: Which companies in my table have the most valid contacts?
    AI:  Running SQL against the local database...
         SELECT company, COUNT(*) ...

    You: Show only accounts with funding data and at least 3 contacts.
    AI:  Here are the matching accounts. I can export this segment or push it.
    ```
  </Accordion>
</AccordionGroup>

## Slash Commands

Type `/` followed by a command name for quick actions. Type `/help` to see all available commands.

<Tabs>
  <Tab title="Files" icon="folder">
    | Command   | Description                      |
    | --------- | -------------------------------- |
    | `/browse` | Browse files in a directory      |
    | `/find`   | Find CSV or XLSX files           |
    | `/files`  | Show files in current directory  |
    | `/output` | Set output directory for exports |
    | `/clean`  | Open cleaning operation picker   |
    | `/merge`  | Merge CSV or Excel files         |
  </Tab>

  <Tab title="Info" icon="circle-info">
    | Command      | Description                                        |
    | ------------ | -------------------------------------------------- |
    | `/commands`  | List all slash commands (compact reference)        |
    | `/help`      | Show comprehensive command reference with examples |
    | `/status`    | Show system status                                 |
    | `/whoami`    | Show logged-in user info                           |
    | `/credits`   | Check LeadMagic credits                            |
    | `/pricing`   | Show LeadMagic API pricing                         |
    | `/shortcuts` | Show keyboard shortcuts                            |
  </Tab>

  <Tab title="Config" icon="sliders">
    | Command   | Description                                               |
    | --------- | --------------------------------------------------------- |
    | `/config` | Display current configuration                             |
    | `/theme`  | Get or set theme (dracula, tokyo-night, nord, catppuccin) |
    | `/scroll` | Get or set scroll speed (1–10)                            |
    | `/auth`   | Show authentication status for enrichment tools           |
    | `/model`  | Show AI routing status                                    |
  </Tab>

  <Tab title="Chat" icon="comments">
    | Command     | Description                                        |
    | ----------- | -------------------------------------------------- |
    | `/sessions` | List and switch sessions                           |
    | `/editor`   | Open `$EDITOR` to compose a message                |
    | `/export`   | Export session as Markdown to `.leadmagic/export/` |
    | `/thinking` | Toggle visibility of model reasoning blocks        |
    | `/expand`   | Toggle expand/collapse of reasoning blocks         |
    | `/clear`    | Clear chat history                                 |
  </Tab>

  <Tab title="System" icon="gear">
    | Command     | Description                                     |
    | ----------- | ----------------------------------------------- |
    | `/exit`     | Exit the application                            |
    | `/table`    | Show the current data as a table                |
    | `/columns`  | Toggle visible columns in the last table result |
    | `/compact`  | Toggle compact mode                             |
    | `/optimize` | Optimize database performance                   |
  </Tab>

  <Tab title="Enrichment" icon="wand-magic-sparkles">
    Quick enrichment commands for single records:

    | Command             | Description                                   |
    | ------------------- | --------------------------------------------- |
    | `/validate`         | Validate a single email address               |
    | `/find-email`       | Find email address for a contact              |
    | `/find-mobile`      | Find mobile phone number for a contact        |
    | `/role-finder`      | Find people by role at a company              |
    | `/employees`        | Find employees at a company                   |
    | `/email-to-profile` | Find a LinkedIn profile from an email address |
    | `/personal-email`   | Find personal emails from a LinkedIn profile  |
    | `/enrich-company`   | Enrich company data by domain or name         |
    | `/clear-context`    | Clear enrichment context                      |
  </Tab>

  <Tab title="Automation & Integrations" icon="bolt">
    | Command       | Description                                   |
    | ------------- | --------------------------------------------- |
    | `/recipe`     | List available enrichment recipes             |
    | `/watch`      | Show watch mode status or start/stop help     |
    | `/schedule`   | List schedules or show scheduling help        |
    | `/job-change` | Job change detection and monitoring           |
    | `/instantly`  | Instantly campaign management and push        |
    | `/emailbison` | EmailBison campaign management and push       |
    | `/smartlead`  | Example Robotics campaign management and push |
  </Tab>
</Tabs>

## Local Context

The chat has access to your local LeadMagic workspace:

* Imported CSV and Excel tables
* Query results and visible table columns
* Chat sessions and exported transcripts
* Recipe definitions and schedule history
* Outbound push history
* Account status, credits, and pricing

Use `@` to reference a file and `/table` or `/columns` to inspect the current data view.

## AI Routing

The CLI routes AI requests through the LeadMagic AI Gateway. Check routing status with:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lm status
lm config show
```

Inside chat, use:

```
/model
```

This shows the current AI routing status.

## Session Management

Chat sessions are automatically saved and can be resumed later.

| Action         | How         |
| -------------- | ----------- |
| List sessions  | `/sessions` |
| Start fresh    | `/clear`    |
| Export history | `/export`   |

Sessions are stored in the local database and persist across CLI restarts.

## Keyboard Shortcuts

| Shortcut | Action                         |
| -------- | ------------------------------ |
| `Enter`  | Send message / execute command |
| `↑ / ↓`  | Recall previous commands       |
| `Tab`    | Autocomplete commands          |
| `Escape` | Clear input                    |
| `Ctrl+C` | Exit application               |
| `Ctrl+L` | Clear screen                   |
| `Ctrl+K` | Open command palette           |
| `/`      | Start a slash command          |
| `@`      | Reference a file               |

## Next Steps

<CardGroup cols={2}>
  <Card title="Command Reference" icon="book" href="/docs/cli/commands">
    All commands for non-chat workflows.
  </Card>

  <Card title="Configuration" icon="sliders" href="/docs/cli/configuration">
    Database, model, and theme settings.
  </Card>
</CardGroup>
