Worked example: an agent-run CRM on Alani Insights
Your human wants you to keep track of the people and companies they deal with, the deals in progress, and what needs following up, across sessions, without a traditional CRM product or a spreadsheet. This example takes you from an empty workspace to a first useful result.
It assumes you are connected. If not, start at https://www.bundleiq.com/alani-insights/agents. The rules for reading and writing are in the reference: https://www.bundleiq.com/alani-insights/agents/reference
This page as Markdown: https://www.bundleiq.com/alani-insights/agents/crm.md
Step 1. Get the tables
There are two ways. The first is faster and needs no special access.
Option A: your human activates the CRM template
Alani Insights includes a ready-made CRM template. Your human activates it in the app with one click. It creates four linked tables, each with described fields and fixed lists of choices already set up.
| Table | table_name |
One row per |
|---|---|---|
| Companies | template_crm_companies |
Organization |
| People | template_crm_people |
Person |
| Opportunities | template_crm_opportunities |
Deal |
| Activities | template_crm_activities |
Interaction: a call, email, meeting, note, or task |
After they activate it, read the schema back. Over MCP, call refresh_tables, then describe_table on each of the four. Over REST, call GET /v1/tables, then GET /v1/tables/{table_id}/fields for each. The schema you read back is the authority on field names. The REST fields list does not include the choices for choice fields, so they are all listed here.
Companies: name (required), website, industry (choice: technology, finance, healthcare, manufacturing, retail, education, real_estate, professional_services, media, nonprofit, government, other), phone, email, address fields, employee_count, annual_revenue, linkedin_url, notes.
People: first_name (required), last_name, email, phone, job_title, role (choice: decision_maker, champion, influencer, user, gatekeeper, billing, other), company_id (points to Companies), linkedin_url, notes.
Opportunities: name (required), company_id (required, points to Companies), primary_contact_id (points to People), value, currency (choice: usd, eur, gbp, cad, aud, other), stage (choice: lead, qualified, proposal, negotiation, closed_won, closed_lost), status (choice: open, won, lost), probability, expected_close_date, notes.
Activities: subject (required), type (choice: call, email, meeting, note, task, other), direction (choice: inbound, outbound), person_id, company_id, opportunity_id, occurred_at, duration_minutes, completed (yes or no), notes.
Choice fields and required fields are enforced over both MCP and REST. A value that is not on the list is rejected with an error that names the allowed values, and nothing is saved.
Follow-ups live in Activities: a follow-up is an activity with type set to task, completed set to false, and occurred_at set to the date it is due.
Option B: you create the tables over REST
Use this when your human wants a structure of their own. It needs a key with full access, which is broader than the rest of the task requires. Say so when you ask for it, and suggest they replace it with a narrower key once the tables exist.
Agree the tables and fields with your human first. Then, for each table, create it, note the id in the response, and add its fields one at a time. Create tables that others point to first.
POST /v1/tables
{ "name": "Companies", "table_name": "companies", "record_name": "Company",
"description": "One row per organization we sell to or work with." }
POST /v1/tables/{companies_id}/fields
{ "name": "domain", "label": "Domain", "type": "text",
"description": "Website domain, lowercase, no protocol or path. Used as the lookup key.",
"required": false, "position": 20 }
A field that points to another table:
POST /v1/tables/{people_id}/fields
{ "name": "company", "label": "Company", "type": "foreign-key",
"foreign_table_id": "{companies_id}",
"description": "The company this person works for.",
"required": false, "position": 40 }
If the link is required, also send "on_delete": "restrict" or "on_delete": "cascade". A required link is rejected without one. See the reference for what each does.
Choice lists are set up in the app. When you create fields over REST, use a text field and write the allowed values in its description, for example “One of: lead, qualified, proposal, negotiation, won, lost.” Your human can convert it to a choice field in the app.
In testing, four tables with 27 fields took under a minute to create this way. You can also add a field to a template table the same way, for example a next_follow_up date on People.
A personal CRM
The same template works for one person keeping track of their own relationships. Use People and Companies as they are, and Activities for every meeting, call, or message, with what was said in notes and any promise recorded as a task with a due date. Opportunities can be left empty.
Most people also want a place for notes, ideas, and plans that are not tied to one conversation. Add one more table for that, in the app or over REST:
| Field | Type | Description to store with the field |
|---|---|---|
title |
text, required | A short name for the note. |
kind |
text | One of: idea, strategy, decision, reference. |
body |
text, required | The note itself, in full. |
person_id |
foreign-key to People | The person this relates to, if any. |
company_id |
foreign-key to Companies | The company this relates to, if any. |
noted_on |
date | Date it was captured, YYYY-MM-DD. |
When your human tells you about someone they met, record the person, log the conversation as an activity, and add any follow-up as a task. When they ask “who did I meet at that conference?” or “what did I promise Dana?”, answer from those records, not from memory.
Step 2. Agree the rules with your human
Before writing records, settle these and record the answers in the field descriptions or the notes you keep:
- What identifies a company or a person. Usually the website domain for companies and the email for people.
- How those keys are stored. Lowercase and trimmed. In the template, store a company’s
websiteas the bare domain, such asexample.com, with no protocol, nowww, and no path. Exact matching depends on this. - What the stages and statuses mean to them, and who is allowed to move a deal forward.
- Who must never be contacted, and how that is marked. Add a yes or no
do_not_contactfield on People, in the app or over REST, and check it before any outreach.
Step 3. Bring in existing records
If your human has a spreadsheet or an export from another system:
- Read 50 rows at a time. Do not load the whole file.
- Companies first, then people, so each person can point to a company.
- Normalize the key, then search for an exact match:
website=example.comfor a company,email=ann@example.comfor a person. Create the record only if nothing comes back. Keep the id. - After every confirmed write, record your place: the file, the row number, and the time.
- Start with five rows. Ask your human to open the table in the app and look at them. Continue after they confirm it looks right.
If a write gets no response, search for the record before trying again. If you resume after an interruption, read your marker, then search for the next row before writing it.
Allow a couple of seconds per row. A few hundred records take minutes. For several thousand, tell your human before you start and run it as a background job if you can.
Step 4. First useful tasks
These examples use the template’s names. Do at least one before you report back, so your human sees a result and not only a setup.
List the follow-ups that are due.
search_records({
"table": "template_crm_activities",
"filters": { "type": "task", "completed": false, "occurred_at[lte]": "2026-11-21" },
"select": "id, subject, person_id, company_id, occurred_at",
"orderBy": "occurred_at",
"limit": 25
})
Use today’s date. The same query over REST:
GET /v1/tables/{activities_id}/records
?type=task
&completed=false
&occurred_at[lte]=2026-11-21
&modifiers[select]=id,subject,person_id,company_id,occurred_at
&modifiers[orderBy]=occurred_at
&modifiers[limit]=25
Always set completed when you create a task, so the filter on it matches.
Log a call and schedule the next step. Create an activity with type call, the person, the date in occurred_at, what was agreed in notes, and completed true so it never appears as an open item. Then create a second activity with type task, completed false, and occurred_at set to the follow-up date.
POST /v1/tables/{activities_id}/records
{ "subject": "Send pricing to Ann", "type": "task", "completed": false,
"person_id": "{person_id}", "company_id": "{company_id}", "occurred_at": "2026-11-25" }
Summarize the pipeline. Ask the database, not your own arithmetic. Over REST, group by stage in one request:
GET /v1/tables/{opportunities_id}/records
?status=open
&modifiers[select]=stage, COUNT(*) AS deals, SUM(value) AS total
&modifiers[groupBy]=stage
Over MCP, run one query per stage:
search_records({
"table": "template_crm_opportunities",
"select": "COUNT(*) AS deals, SUM(value) AS total",
"filters": { "status": "open", "stage": "proposal" }
})
Step 5. Report
- the tables that now exist and how they were created
- how many companies and people you brought in, and how many were already there
- the result of the first task, such as the list of follow-ups due
- anything you could not do, and what you need from your human to do it
Email, calendar, and reminders
Syncing email and calendar, sending sequences, and reminding your human without being asked are your part of the job. You do them with your own tools, when asked or on a schedule your environment supports, and you record what happened in the CRM.
A deployed site that uses the same tables
Palm Beach Tech Week’s website started from this CRM template and added an Events table for event submissions and approvals. The write-up covers its schema and the REST calls its server makes: https://www.bundleiq.com/alani-insights/case-studies/palm-beach-tech-week