# Enriching Contacts, Companies & Deals

Karmaflow.ai can auto-fill custom fields on a record from your own
data plus optional web search — no third-party enrichment account
required. This article walks through the AI-research field
workflow end to end.

## How AI-research fields work

An **AI-research field** is a custom attribute you define once
(per entity type) and the platform fills automatically on demand.
The pipeline:

1. Pull the record's own card (name, email, company, tags, recent
   notes/activities).
2. Retrieve matching context from the per-tenant **vector store**
   (your calls, chats, emails, SMS, notes, activities), optionally
   from **web search**, optionally from **contact memories**.
3. Send the prompt plus the retrieved context to Gemini.
4. Persist the answer onto the record's `customFields`, along
   with the list of sources the model actually used.

The sources are stored alongside the value so every enrichment
is auditable — anyone reading the field can see exactly what
context produced it.

## Defining an AI-research field

1. Open **CRM → Setup → Custom Fields** (`/settings/custom-fields`).
2. Pick the entity tab — **Contacts**, **Leads**, **Companies**,
   or **Deals**.
3. Click **+ New field**.
4. Set the **Friendly name** (e.g. "Industry"). The slug auto-
   fills from the name; override only if you need a specific
   `dbName`.
5. Change **Field kind** to **AI-research (auto-filled)**. An
   **AI research configuration** section appears below.
6. Fill in:
   - **Prompt** — the question for the LLM. Be specific. Examples:
     - *"What industry is this company in? Reply with one short
       phrase like 'B2B SaaS' or 'Healthcare provider'."*
     - *"Summarise this contact's role at their company in one
       sentence."*
     - *"List the top three product features they've discussed,
       comma-separated."*
   - **System prompt** *(optional)* — tone / format instructions
     that apply to every fill. Example: *"You are a sales-research
     assistant. Cite your sources. If you don't have enough
     information, reply 'unknown' instead of guessing."*
   - **Sources** — which retrieval channels to use:
     - **Vector store (own data)** — notes, activities, calls,
       chats, emails, SMS attached to the record.
     - **Web search** — public web results, summarised by the LLM.
     - **Contact memories** — persistent memory entries written
       by AI agents over time.
   - **Refresh interval (days)** — `0` for on-demand only;
     anything higher schedules an automatic refresh.
   - **Model** — defaults to `gemini-2.0-flash-001`. Leave this
     alone unless your workspace has a specific model preference.
7. Click **Save**.

The field now appears in the **Custom Fields** card on every
record of that entity type, with an **AI** chip next to its label
and an **Enrich** button on the right.

## Enriching a record

Open any contact, company, or deal. In the **Custom Fields**
card on the right column:

- The first time you see an AI-research field on a record, the
  value box says *"Not yet filled"* and the button reads
  **Enrich**.
- Click **Enrich**. The button spins for a few seconds while the
  LLM runs.
- The value appears in the box. A small **N src · view** link
  appears next to the button — click it to open a popover that
  shows:
  - When the value was generated and which model ran.
  - Each source the model pulled in, with its metadata
    (call ID, channel, timestamp, etc.).
- Need to re-run? The button is now labelled **Refresh**. Click
  it any time to regenerate the value with the same prompt and
  sources. The new sources replace the old in the popover.

## Editing AI-research fields after the fact

AI-research fields are read-only in the Custom Fields card —
they only update via the **Refresh** button. If you want to
override a value manually, the cleanest path is to:

1. Edit the field definition in **Settings → Custom Fields** and
   change the **Field kind** back to **Manual**.
2. Save. The existing value stays on every record.
3. Edit the value inline on each detail page as needed.
4. Optionally flip the field back to **AI-research** later — the
   manually-entered values remain unless someone clicks
   **Refresh**.

## Bulk enrichment

The bulk-edit dialog on the spreadsheet view doesn't yet drive
the AI pipeline — for now, enrichment happens one record at a
time via the **Enrich** button. The scheduled refresh
(`refreshIntervalDays`) handles bulk catch-up over time without
manual clicking.

## Practical recipes

A few prompts that work well in production:

- **Company → Industry**: *"What industry is this company in?
  Reply with one short phrase."* Sources: web + vector store.
- **Company → Recent news**: *"In one sentence, what's the most
  recent notable news about this company from the last 90 days?
  If none, reply 'no recent news'."* Sources: web only.
- **Contact → Role summary**: *"Summarise this contact's role
  and seniority in one sentence based on conversations on file."*
  Sources: vector store + memory.
- **Deal → Risk flag**: *"Based on the call transcripts and notes
  attached to this deal, list any concerns the buyer has
  expressed about pricing, timing, or alternatives. Reply 'none
  detected' if there's no signal."* Sources: vector store.
- **Contact → Compliance flag**: *"Has this contact ever asked
  about HIPAA, SOC 2, GDPR, or another compliance topic? Reply
  with the specific term they mentioned, or 'no'."* Sources:
  vector store.

## When AI-research won't help (and what to use instead)

- **Real-time data** (current price, today's weather, this
  morning's news) — refresh interval applies; the value reflects
  the last time the field was filled.
- **Cross-record aggregates** ("how many deals does this contact
  have open?") — use a CRM dashboard widget instead.
- **Public B2B data** (LinkedIn role, company headcount, funding
  round) — the LLM can fetch some of this via web search, though
  a dedicated data provider is usually denser.
- **Hard facts you already capture** (email, phone) — leave
  those as manual fields. AI-research is for the *judgement
  calls* that humans usually make from context.

## Where it shows up next

When you bring an AI-research field into a saved view as a
column, list pages display the AI chip next to its column header
so the user knows the value was auto-filled. The value still
shows the most recent fill — no automatic refresh on page load
to keep cost predictable.

<!-- SCREENSHOT: ai-research-field-editor.png — Settings page with the AI configuration panel open -->
<!-- SCREENSHOT: ai-research-enrich-button.png — Custom Fields card with an Enrich button and the sources popover -->
