# Customer research

Before a first call, somebody on your team opens the company's website and LinkedIn page and
writes down what they see. sumwerk can do that part: read the website, with Apify also the
LinkedIn company page and up to ten of its people, ask your LLM for a summary with your own
prompt, and write **one note** on the customer's timeline, plus a few attributes you can filter
on. It runs on your keys and your accounts with those providers; sumwerk keeps no keys of its own.

## What you need

- An **owner or developer** of your sumwerk account.
- A key for an **OpenAI-compatible LLM**: OpenAI itself, or anything that answers
  `/chat/completions` at a base URL you can name.
- Optionally an **Apify** key. Without it sumwerk reads the website itself and skips LinkedIn.

## Switching it on

Two places. Account → **Integrations** connects the providers: the LLM key with its model and
base URL, and the Apify key if you have one. Both are checked before they are stored, stored
encrypted, and never shown again. Research is on as soon as an LLM is connected. Account →
**Research** then says what a research does: whether the LinkedIn page and the people are read,
which job titles count, and the prompt. `{website_url}` and `{website_text}` are filled in for
every run.

## Trying it first

Account → Customer research → **Try it**: name a customer, optionally a website to read instead of
the customer's, and run it. The result appears on the tab as it would on the timeline, with the
time it took. Nothing is written to the customer: no note, no attributes, no event. Change the
prompt above and run again until the result is what your team should get; then let the button,
the rules and the API do it for real.

## Starting a research

- **On the customer page**: the button *Research this company*. Everybody on the team may press it.
- **By a rule**: Account → Automations → New automation, for example *when a customer is
  created*, action *Research the company*. Every new lead then gets its note without anybody
  clicking. A second rule can react to *customer research is done*, for example with a task for
  the owner to read the note before the call.
- **Through the API**: `POST /api/v1/customers/<id>/research` starts it (a read-and-write
  token), `GET` the same address answers with the latest run, its status and what was found.

One run at a time per customer: a second request while one is running gets the same run back.

## What comes out

- One note, **Customer research**, rewritten on every run so the timeline never fills up with
  research: website and LinkedIn links, industry, team size, headquarters, founding year,
  specialties, the "about" text, the people found, and the analysis your prompt asked for.
- The attributes `website`, `linkedin_url`, `industry`, `employee_count`, `headquarters`,
  `founded` and `researched_at` on the customer, so the customer list can be narrowed by them.
- An event, *customer research is done* or *customer research failed*, for your rules and for
  Account → Log.

## Where the website comes from

The attribute `website` on the customer, if it is set. Otherwise the domain of the customer's
email address or of one of its people, unless that is a free mail provider like gmail.com. A
customer without either cannot be researched, and the run says so.

## What it costs and what it sends

Every run makes one call to your LLM and, with Apify, up to four actor runs. What is sent to
the LLM is the website's text and your prompt, nothing from sumwerk's own data. The website is
public; the LinkedIn data comes through Apify under your agreement with them. Switching research
off forgets both keys; the notes written so far stay.
