# Lead Research to Sheet

> Send a name and a company and get one finished lead row: contact data from Apollo, a recent company news line from Tavily, appended to your Google Sheet, confirmed in chat with the sheet link.

**URL:** https://caywork.com/learn/docs/agent-example/lead-research-to-sheet

## Content

Lead Research to Sheet turns one chat message into a finished row in your Google Sheet. You send a person's name and their company; the flow enriches the lead from two sources, formats one row, appends it to your spreadsheet, and reports back with the sheet link. When you send a message like "Jane Doe at FlowMetrics", this is what happens:

1. The User Chat Input triggers the flow. Your message names the lead: a person and their company.
2. The Tool Calling Node is the tool hub. Its first call goes to the Apollo MCP connector, which matches the person and returns their job title, company, and work email.
3. The Tool Calling Node's second call goes to the Tavily Research Node, which researches the company and returns one short news line (funding, hiring, product news).
4. The Tool Calling Node hands both results to the Text Generator, which formats one row in the fixed sheet format: Name | Title | Company | Email | Company news (1 line) | Enriched date.
5. The formatted row goes back to the Tool Calling Node, which appends it to your spreadsheet using the Google Sheets node.
6. The Tool Calling Node passes the append result and the spreadsheet link to the Text Generator, which writes the final two-line chat message, delivered by the User Chat Output node: line one says what was added (the full row), line two is the sheet link.

This example teaches an enrichment pipeline: two research tools feed one formatting step, and an OAuth side-effect node (Google Sheets) writes the structured result into a spreadsheet you already own.

## Platform features used

- Knowledge Base: upload your prospect list (a PDF or spreadsheet export) and your ideal customer profile notes to the workspace Knowledge Base (workspace, then Knowledge Base in the sidebar). Open the agent chat in that workspace and click the paperclip button ("Attach Knowledge Base Documents"), pick the prospect list, and send your message. The agent reads the extracted text of those documents while it works, so it fills the sheet rows in your own column order and only enriches leads that match your ICP. The prompt below has a rule that makes the attached documents the first source of truth.
- Conversation History: turn it on in Flow Settings (Conversation History toggle). It feeds the last N chat turns (default 20) into each run, so you can correct in the same chat — for example "use the personal email instead" or "skip leads from agencies" — and the agent applies it to the next leads without you repeating the sheet format.

## The Prompt for The Agent

You are a lead research assistant. You receive a person's name and company from the user, contact data from Apollo (title, company, email), one recent news line about the company from Tavily, and the link of the spreadsheet where finished rows live. Your job is to append one lead row to the sheet and confirm in chat.

Rules:

1. Use ONLY the supplied tool results and the attached knowledge base documents. Never invent titles, emails, or news.
2. Prefer facts from the attached knowledge base documents (the prospect list and ICP notes) over your own knowledge; if the documents don't cover a field, fall back to the tool results, and if neither covers it, write not found.
3. Build the row in this exact field order: Name | Title | Company | Email | Company news (1 line) | Enriched date. Keep the pipes between fields and use today's date as the Enriched date.
4. If Apollo returns no title, email, or company, write not found in that field. If Tavily returns no news, write no recent news found.
5. Keep the news line under 12 words and state plain facts only (funding, hiring, product launch, leadership change). No opinions.
6. The chat reply is exactly two lines: line one starts with "Added to" and shows the full row; line two starts with "Sheet: " and shows the spreadsheet link.
7. If the lead does not match the ICP in the attached knowledge base documents, do not append a row; reply in one line why the lead does not qualify.
8. Never mention tools, JSON, or the enrichment steps.

Output template:

Added to {sheet name}: {Name} | {Title} | {Company} | {Email} | {Company news} | {Enriched date}
Sheet: {spreadsheet link}

Formatting example:

The user sends "Jane Doe at FlowMetrics":

Added to Leads: Jane Doe | VP Sales | FlowMetrics | jane.doe@flowmetrics.com | FlowMetrics raised a Series A | 2026-09-29
Sheet: https://docs.google.com/spreadsheets/d/1xKq9vLeads2026/edit

Tone and style:

- Neutral and brief, like a good sales assistant. No emoji, no exclamation marks.
- One row per message; each field keeps its exact position between the pipes.
- Never mention tools, JSON, counts, or the append step.

## Formatting Contract

The output is always one chat message with exactly two lines:

1. Line one: "Added to {sheet name}: " followed by the six-field row (Name | Title | Company | Email | Company news (1 line) | Enriched date).
2. Line two: "Sheet: " followed by the spreadsheet link.

Missing data never blocks the row: fields the tools could not fill become not found, and a missing news line becomes no recent news found. If both Apollo and Tavily fail, no row is appended and the whole reply is one line: "Could not research {name}. Try again in a minute." If the lead does not match the ICP from the attached documents, the reply is one line explaining why, with no row appended.

## Nodes and Roles

| Node | Role |
|---|---|
| User Chat Input | Input: takes the lead (name and company) |
| Tool Calling Node | Logic: the tool hub — runs the two research tools, appends via the Sheets tool, and feeds the Text Generator |
| Apollo MCP connector | Tool: matches the person and returns their title, company, and work email |
| Tavily Research Node | Tool: returns one recent news line about the company |
| Google Sheets Node | Tool: appends the finished row to your spreadsheet |
| Text Generator | Logic: formats the one-row profile and writes the two-line confirmation with the sheet link |
| User Chat Output | Output: delivers the confirmation to the chat |