Data Analyst
- Slack
- Postgres
- Vercel
A Slack-based data analyst that answers business questions from Postgres, with charts and tables for useful results.
- Slack
- Postgres
- Vercel
agent/agent.tstypescripteve Data Analyst Template
Slack-based data analyst built on eve that answers questions about your business from a Postgres database. Ask "What was our MRR last month?" in Slack and it replies with the number, plus a chart or table when one helps.
Getting started
Vercel's project setup flow will create a repository in your Git account and a Vercel project. You'll create and install a Slack app via Vercel Connect, and the flow adds a private Vercel Blob store for the agent's memory. You'll then be prompted to add the following environment variables:
Each deploy prepares your database before building the agent. It loads the demo data when ANALYST_SEED_DEMO_DATA is true, and it creates the read-only database user the agent queries with.
When the deploy finishes, add the agent to a Slack channel, @mention it, and ask "What was our MRR last month?"
Use your own data
Add an environment variable named ANALYST_SCHEMAS that lists the database schemas holding your tables, separated by commas, such as public,billing. Then redeploy. Use your own database in the customization guide covers the other available options.
Tech stack
How it answers
The agent looks up which tables it can read and what their columns mean, then loads your metric definitions from agent/skills/metric-definitions.md, so terms like "MRR" and "churn" follow your team's rules. It runs a summarizing query and replies with the number, the exact period, and the time zone. Trends, rankings, and breakdowns appear as Slack charts and tables.
Below each answer, a collapsed "SQL query" section shows the queries the agent ran, the tables each one read, and when it ran. The agent remembers preferences such as number formatting or a channel's default region, while metric definitions stay in the skill file.
How it stays safe
The agent can only read your database. These safeguards keep it that way and protect your data:
- The agent connects as a dedicated database user, which reads data through the asking person's role.
- Every query runs in a read-only transaction with a time limit, and the transaction is rolled back afterwards.
- Each query is wrapped so the database runs it as a single
SELECTstatement. - Before running a query, the agent asks Postgres to estimate its cost. Expensive queries wait for approval from the person who asked.
- Query results stay in the conversation, because web search, web fetching, and outbound network access are turned off.
- Query results, column descriptions, Slack messages, and memory are treated as information to read rather than instructions to follow.
Access control
Each person queries as a Postgres role, so your database permissions decide what they can see. Everyone uses the role named in the ANALYST_DEFAULT_ROLE environment variable, which is analyst_readonly by default. To give a specific person or everyone in a Slack channel their own role, set the ANALYST_ROLE_MAP environment variable to a JSON object of Slack IDs and role names:
In this example, the person U0456EFGH queries as analyst_exec wherever they ask, everyone in the channel C0789IJKL queries as analyst_finance there, and an empty role turns off access for U0999ZZZZ. Bots, including Slack Workflows, get access once you add them to the map. See Control who can query what for how roles combine and how to set up team roles.
Local development
Use Node.js 24 and pnpm, and install the Vercel CLI. Then clone your repository.
-
Link the project and pull its development environment variables into
.env.local:Choose your deployed project when prompted. This also saves a Vercel OIDC token that lets the agent use AI Gateway locally. It expires after about 12 hours, so rerun
vercel env pull .env.localto get a new one. -
Add your database connection string and demo data setting to
.env.local, sincevercel env pullcopies non-sensitive values only:Use the same
DATABASE_URLas your Vercel project, or a local Postgres database such as one started withdocker run -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres:17. -
Prepare the database the same way a deploy does, and start the agent:
pnpm dev opens eve's interactive chat in your terminal. Ask "What was our MRR last month?" to try the full path from schema lookup to answer. Local sessions answer in plain text, because Slack charts and tables appear in Slack threads. Run pnpm db:doctor to check that the database is set up the way the agent expects.
Before deploying, check your changes and confirm the agent builds:
pnpm eval runs automated checks that ask the agent real questions about the demo data, such as last month's MRR. pnpm fix applies formatting and lint fixes. Deploy with vercel deploy --prod, which keeps your .env.local file as it is.
Customization
For more, including team roles, approval thresholds, and connecting Stripe or PostHog, see CUSTOMIZATION.md.