Agent context
HubSpot models
18 SQL models that turn the raw HubSpot tables into the reports people ask about. Deploy them in Weld and your agent queries the definitions behind every number.
How the set is built
- 10Raw tables
- 11Staging
- 7Core
- 6Analytics
Staging cleans each raw table once, core holds the logic, and analytics is the table dashboards and agents read.
- Company 360One row per company: firmographics, owner, contacts, open and won pipeline, and last touch.grain: one row per company · 8 raw tables
- Deal activityActivities logged against each deal: counts by type, connected calls, completed meetings, and the first and latest activity.grain: one row per deal with at least one logged activity · 2 raw tables
- Deal flow by monthDeals created, won and lost per month, per pipeline and owner, with win rate.grain: month x pipeline x owner · 7 raw tables
- Deal pipelineEvery deal with its pipeline, stage, outcome, owner and primary company.grain: one row per deal · 7 raw tables
- Deal stage historyEvery stage each deal has been in, when it entered, when it left and how long it stayed.grain: one row per deal x stage entry (a deal that goes back to a stage it already visited gets a second row) · 8 raw tables
- Rep activityCalls, emails, meetings, notes and tasks logged per owner per day.grain: day x owner · 3 raw tables
For the legacy HubSpot connector
Single queries written for the older connector's tables. They keep working there; for new setups, use the models above.
- New companies by monthRetrieves a list of new companies created each month from the HubSpot integration and groups them by month. The results are ordered by month.1 raw table
- Closed won deals by ownerRetrieves the number of closed won deals by owner from HubSpot and orders them in descending order based on the number of deals.2 raw tables
- Closed lost deals by ownerRetrieves the number of closed lost deals by owner from HubSpot and orders them by the highest number of deals. It uses a left join to match the owner ID from the deals table to the owners table and concatenates the first and last name of the owner for readability.2 raw tables
- Closed won deals amount by ownerRetrieves the total amount of closed won deals for each owner in HubSpot and orders them in descending order.2 raw tables
- Emails by ownerRetrieves the number of emails sent by each owner in HubSpot by joining the engagements and owners tables and grouping the results by owner.2 raw tables
- New deals by monthRetrieves the number of new deals created each month from HubSpot and organizes them by month.1 raw table
- Calls by ownerRetrieves the number of calls made by each owner in HubSpot and displays it alongside their first and last name. It uses a left join to connect the engagements and owners tables and filters the results to only include calls. The output is grouped by owner.2 raw tables
- Meetings by ownerRetrieves the number of meetings organized by each owner in HubSpot and displays it alongside their first and last name. It uses a left join to connect the engagements and owners tables and filters the results to only include meetings. The output is grouped by owner.2 raw tables
- Tasks completed by ownerRetrieves the number of completed tasks for each owner in HubSpot, using a left join between the engagements and owners tables. The result includes the owner's first and last name, as well as the count of completed tasks.2 raw tables
- Deals by deal stageRetrieves the number of deals in each stage of the sales pipeline from HubSpot and groups them by their respective stage labels.2 raw tables
- Conversion from contacts to deals by ownerConverts contacts to deals by owner in HubSpot, displaying the owner's name, the number of contacts they have, the number of deals they have, and the conversion rate between the two. It uses left joins to connect the necessary tables and groups the results by owner.4 raw tables
- New contacts by monthRetrieves the number of new contacts added to HubSpot each month and groups them by month. It uses the date_trunc function to extract the month from the createdAt field and orders the results by month.1 raw table
- Weld or dbt
- The same SQL in both dialects. Sync the folder with GitHub Sync, or copy the dbt models into your project.
- Check before you rely on it
- Reconcile a month against HubSpot's own reports first. Each model's notes say what the synced data can and can't support.
Connect HubSpot.
Your agents start with context.
Sync HubSpot to your warehouse, deploy these models, and query them from Claude, Cursor or ChatGPT over MCP. Free for 14 days, no credit card.