Building an AI agent is a multi-step process. Marketers need to define the agent’s task, connect approved data and tools, and set limits on its actions. Once they master the basics, anyone — marketers, sales reps, or customer teams — can build agents with ease.
Today, AI agent adoption is growing. A 2026 survey of 5,000 U.S. adults from Menlo Ventures found that one in four AI users has used an agent, with 24% of respondents citing regular use.
To make the most of the tech, teams need to find the right use cases and start experimenting. This post covers how to build an AI agent for those just getting started. Discover how to deploy, test, improve, and set guardrails for your first AI agent.
- What is an AI agent?
- Is an AI agent the right fit for your workflow?
- How to Create an AI Agent
- How to Build an AI Agent Without Code
- Test, Evaluate, and Improve
- Add guardrails and human handoff.
- How to Deploy an AI Agent to a Real Workflow
- AI Agent Use Cases for Marketing, Sales, and Service
- When to Consider Models, Protocols, or Multiple Agents
- Frequently Asked Questions About How to Build an AI Agent
- Start with one agent your team can rely on.
What is an AI agent?
An AI agent is software that uses an AI model to work toward a goal autonomously, or without human input. Agents can choose among approved tools, review the results, and decide what to do next until they finish the task or reach a set limit.
Agents need pre-defined goals or functions. For a marketing team, that could be to review a campaign’s performance and recommend optimizations. The agent would need to examine channel metrics, compare results with the campaign objective, identify likely causes, and explain the recommended change.
Looking to build your first agent? HubSpot users now have access to a no-code AI agent builder. Marketers can describe the automation they want to create, and Agent Builder will do the rest.
AI Agent vs. Chatbot vs. Rules-Based Automation: Explaining the Difference
Agents, chatbots, and workflows have different problem-solving capabilities and serve different functions:
- Chatbots respond to queries or conversations, answering questions that the user inputs.
- Agents are able to make decisions on their own and problem-solve independently.
- Rule-based automations perform a predefined task based on a set trigger. For example, if a buyer changes deal stages, an email may be sent with a discount code.
Agents, chatbots, and automations can also work together. A chatbot, for example, can act as the conversation window for an agent, as well as a predefined workflow can also include an agentic step
Marketing example
Answers a visitor’s question about a product.
Alerts the campaign owner when cost per lead exceeds a set threshold.
Reviews campaign metrics, investigates possible reasons for a change, and recommends an adjustment.
How it works
Matches a question to a prepared answer or uses AI to compose a response.
Follows explicit rules, such as “if this happens, do that.”
Chooses a permitted tool, examines its result, and decides whether to take another step or return an answer.
Configuration
Reference material, answers, and conversation rules.
Triggers, conditions, and actions for each defined path.
The task, instructions, available tools and data, permissions, guardrails, and success criteria.
The Four Building Blocks of an AI Agent
An effective custom AI agent needs a repeatable job, relevant data, a clear starting point, and a measurable result, as defined by Elle Oshiro, a professor at HubSpot Academy. These four building blocks help marketers turn an idea into a workflow they can put to use.
1. Repeatable Work
AI agents excel at regular tasks that need to be performed consistently. For example, a marketing team might review lost deals each month to identify buyer concerns. Even though each deal contains different evidence, the agent’s job stays the same: examine the concern, check existing assets, and recommend a next step.
That said, choose a task that the team can describe clearly and expects to perform over and over.
2. Data Already in Your CRM
AI agent development relies on high-quality training data. CRM data gives the AI context it can use to make decisions. Relevant information might include deal properties, company details, sales notes, and recorded customer conversations.
Before building an agent, check whether the necessary information exists, is current, and is accessible to the agent.
3. A Trigger That Fires Under the Right Conditions
A trigger determines when the agent starts its work. It could be a manual request, a schedule, or a change to a CRM record. With HubSpot, marketers and sales ops can use any of these options through Agent Hub workflow triggers.
4. A Clearly Defined, Measurable Outcome
Define what the agent must deliver, what a correct result looks like, and how the team will measure success. For a campaign review, the output could be a report that flags underperforming channels and recommends one change to test. Each recommendation should cite the relevant metrics, explain the rationale, and acknowledge data gaps.
Is an AI agent the right fit for your workflow?
AI agents are worth a closer look when a task is repeatable, tedious, and requires interpreting information and deciding what to do next. If all you need is a summary of text or data analysis you paste into a chat, a single AI prompt may do the job. Even Anthropic recommends starting with the simplest approach that meets the need, since agents can add cost and delay.
Three questions to ask before you build:
- Where does the task require judgment?
- Can the agent access enough information to do the job?
- Will it save work after human review?
When Rules-Based Automation is Better
Choose rules-based automation when the next steps are clear. Automations work well when outcomes follow one or several defined branches. Each step of the process should follow a decision tree that the team can define in advance and automate.
Common examples for rule-based automation include:
- Assigning a lead to a regional team based on its country field
- Creating a follow-up task after a demo request
- Notifying an account owner when a renewal date approaches
- Excluding unsubscribed contacts from a promotional email audience
Even a complex lead-routing process can work well with rules-based automation. A workflow might check territory, company size, and product interest, then assign the lead to an eligible rep. If nobody accepts a lead within a set period, it can alert a manager or reassign the contact.
How to Build an AI Agent Without Code
For teams learning how to set up an AI agent, start with a clear goal. Define what an agent has to do and its output. Then, write clear instructions for the agent and test it before full deployment.
Looking to create a custom agent? HubSpot now offers an AI agent builder. Just describe your mission in plain language, and Agent Builder will do the rest. HubSpot users also have access to pre-built agents that can help with tasks like data management or prospecting.
Define a narrow goal and success criteria.
First, write down the manual task you want the agent to take over. For example, review lost deals and recommend content that addresses buyers’ unanswered questions.
Before you open the Agent Builder, put together a short brief for the task. That explanation should cover the agent’s goal, scope, and what you hope it delivers. See an example below.
- Goal: Help marketers identify content needs from documented buyer concerns.
- Scope: One selected closed-lost deal and an approved content catalog.
- Deliverable: A short brief with the concern, supporting evidence, and a recommendation to reuse, update, or create content.
- Reviewer: A marketer who checks the recommendation before anyone acts on it.
Note: Give your first agent access to just one deal, so reviewers have a manageable set of records when quality assessing the agent’s work.
Next, define your success criteria, or the checks you’ll use to judge whether the agent completed the task correctly. For this example, here’s what success looks like:
- Each buyer concern has a source reference you can verify.
- Any recommended existing asset appears in the approved catalog and addresses the concern.
- A proposed content brief states the buyer’s question and what the content should explain.
- The agent flags missing evidence or problems that content cannot solve.
- Include cases where no content recommendation is appropriate
Write clear instructions.
Learning how to train an AI agent? Start by turning your notes into clear instructions the agent can follow. Explain how the agent should examine the evidence, choose a recommendation, and handle missing information.
For marketers using HubSpot, open the selected agent in Agent Builder and review its existing instructions. Update the Instructions field to reflect the task you defined. Cover the role, goal, approach, and expected output.
Here’s a starting point for our example. Notice how these instructions explain what to do in different situations:
Role and goal: You help marketers identify content needs from one selected closed-lost deal.
Approach: Read the available deal details and relevant associated records. Identify a documented buyer concern, then compare it with the approved content catalog. Distinguish direct buyer feedback from a salesperson’s interpretation.
Recommend an existing asset when it answers the buyer’s question. If an asset only partly answers it, specify what needs an update. Propose new content only when the supplied catalog lacks a suitable asset.
Missing evidence: If the records don’t support a conclusion, explain what information is missing. If content cannot address the concern, state why. Do not assume that missing content caused the deal loss. A request for an unsupported integration should be flagged as a product limitation.”
Output: Return a short brief with four sections: Buyer concern, Supporting sources, Content recommendation, and Information gaps.
Add tools and permissions.
Depending on the job, an agent might need to search the web, retrieve CRM records, or update customer information. It may also need connectors to reach other apps, such as Zoom, Appcues, or Google Docs. For our lost-deal review, the setup is simple: the agent only needs to retrieve relevant CRM information and compare it with approved marketing content.
In Agent Builder, use Knowledge for reusable reference material and Inputs for information that changes with each run, such as the customer or deal to review. For example, a service agent might reference your support policies while reviewing a selected customer’s issue.
Agent Builder lets users create a knowledge vault supporting images, website pages, blog articles, and uploaded documents, including spreadsheets, PowerPoints, and PDFs.
With HubSpot, teams can also set AI context for agents. With Context filled out, AI will know virtually everything about you and your business.
Teams must also decide who can use an agent and who has the ability to edit it. Agent Builder allows users to designate who on the team has permission.
Test with representative scenarios.
Try the agent on records you understand well enough to judge its answer. Check that the agent reviewed the intended deal or metrics, used the approved references, and supported its recommendation. Be sure to vet the cited material yourself.
Pro tip: Test runs in Agent Builder don’t cost extra credits. Repeat testing until the output is consistent and meets your requirements.
Compare the time needed to check and correct the agent’s outcome with the time needed to do the task manually. A useful agent should produce reliable work and save the team some effort.
Iterate on scope and instructions.
A failing test isn’t necessarily a failure! It’s an opportunity to identify what needs fixing. This is an opportunity to revise instructions and retool prompting. Change one thing at a time, then rerun the failed example and a previously successful one. This helps teams see whether the change fixed the problem without creating another.
Test, Evaluate, and Improve
After an agent is built, ongoing evaluation helps teams decide whether it works properly and delivers value. Teams should review agents after their instructions are edited and when tools, permissions, models, or connected data sources change. Schedule monthly reviews and run a test after a reported error.
Build a practical test set.
A test set is a collection of examples of the work an agent typically handles, such as analyzing closed-lost deals. In this case, each closed-lost deal counts as one example in the test set.
Keep the test set in a spreadsheet so you can compare what you expected with what happened. Analyze each example before running an agent. Fill in your expectations in the spreadsheet. Next, run each deal through the agent and score its output.
Pro tip: Run selected cases several times. Model outputs can vary between attempts.
Review failures and edge cases.
Keep a failure log in the test sheet. For each problem, add a column for “reviewer notes” and explain what went wrong and what needs checking. Be extremely specific about mistakes. Next, group similar failures, investigate the cause, and apply the appropriate fix. Rerun the affected cases after changes are made. Record the change and the new result alongside the original so you can compare them.
Common agentic failures and fixes are as follows:
- Outdated answers. Check which source an agent used. Replace obsolete documents or remove them from its approved references.
- Missing information. Check whether the required source is connected and accessible. If the information doesn’t exist, instruct an agent to request it or flag the gap.
- Wrong record or recipient. Check the input passed to an agent and how it identifies its target. Use a unique record ID.
- Unsupported conclusions. Require supporting evidence and explain when an agent should leave a question unanswered.
- Unwanted actions. Remove unnecessary tools or restrict their permissions. Require human approval for consequential changes.
Track success metrics.
Use the test spreadsheet to measure whether an agent completes useful work and reduces the effort your team spends on it. Add columns for Review time, Corrections needed, Run cost, and Agent version.
After each test, record how long you spent checking and correcting the result. Enter the run cost if available. Then summarize these measures in a separate tab, calculating task success rate, correction rate, human time spent, and cost per successful task.
Task success rate
Divide cases that meet your success criteria by all cases tested. Count failed runs, too.
Correction rate
Divide outputs needing substantive changes by all outputs reviewed.
Human time per task
Add preparation, review, and correction time, then divide by the number of tasks.
Cost per successful task
Divide total run costs, including retries, by the number of successful tasks.
Compare human time with the time needed to complete similar tasks manually. For example, if preparing a customer handoff takes 20 minutes manually and eight minutes with an agent, that’s 12 minutes saved — provided the result meets the same quality requirements.
Add guardrails and human handoff.
AI guardrails define what the agent may handle, what data it shouldn’t touch, and when a person should take over. Set these rules before launch to reduce the risk of unauthorized actions, data exposure, and malicious instructions hidden in prompts or source material.
Here’s how teams should approach setting guardrails:
- Define the job’s boundaries in the agent’s instructions, including how to handle unrelated requests and instructions found in source material.
- Limit the agent’s tools and permissions to what the job requires.
- Enforce access restrictions through the connected apps’ controls.
- Specify when the agent must stop and who should take over.
- Require an authorized person’s approval before sensitive or high-impact actions, enforced through the workflow or tool.
- Test the complete handoff.
Agent Builder allows teams to set guardrails across four dimensions: instructions, actions, knowledge vault, and permissions. Build safe agents for marketing and sales purposes through Agent Hub.
Choose the first deployment surface.
A deployment surface is where people use an agent or receive its work. An internal inbox, a CRM workflow, and a customer-facing chat fall under different deployment surfaces. Choose one surface that your agent supports.
Next, define how to run the agent based on the following categories.
- On demand: A person decides when to start the task and supplies the inputs.
- Event-triggered workflow: The task should start when something happens, such as a form submission or record update.
- Scheduled workflow: The task should run at a set time or interval.
For any workflow, define the starting condition, the inputs passed to the agent, and where its results go. With Agent Hub, teams can move and connect workflow actions and agents without breaking the overall logic.
Complete the preflight check.
Before publishing an agent, look through its setup with intended users. Check for:
- Instructions, tools, and reference material are correct.
- Pilot users can complete the job, and reviewers can open its output and supporting sources.
- The starting conditions are met (records, triggers, events).
- Credit usage per run and a monthly run limit are set.
- An authorized person owns the review.
- There is a fallback (decide who completes the task manually if an agent fails).
Once the checks are complete, save and publish the agent version.
Monitor the first live run.
Run a small pilot first, and review every initial result. Follow each task from beginning to end. In Agent Hub, teams can filter for the agent and inspect its runs. Users can check the status, output, sources, and estimated credits.
A Success status means the run completed without an execution error. A human still needs to judge whether the agent’s answer is useful and accurate.
The workflow’s Run history helps teams investigate whether the workflow started and where an execution failed. If a serious problem creeps in, pause the workflow, identify affected runs, and use the manual fallback while you fix and retest the workflow.
AI Agent Use Cases for Marketing, Sales, and Service
Curious what AI agents teams have built for different purposes? See how real marketers have used agents to simplify their workflows.
Marketing Use Case: Spot Influenced Deals Through Cross-References to LinkedIn Engagement
Not everyone who sees a LinkedIn ad clicks. But, that exposure may still influence a deal. Filippo Irdi, a senior demand marketing manager at Unmuted, built an agent that cross-references LinkedIn ad impression data with HubSpot closed-won deals to identify that influence. I asked Filippo to walk me through a detailed agent setup.
Here’s how you can recreate his work.
1. Pull LinkedIn impression data.
Using the LinkedIn API, pull impression data week by week for a specific timeframe. The data shows which companies were served your ads and how many impressions they received. LinkedIn doesn’t provide granular company-level impression data. Weekly data is enough to identify useful patterns.
2. Match it with HubSpot deals.
“For the same timeframe — for example, the last six months — pull deal data from HubSpot. For each deal, capture the company, when the deal was created, when it changed stages, and when it closed. Then match the two datasets,” Irdi suggests.
From there, you can now see whether a company was exposed to LinkedIn ads before entering the sales pipeline or closing a deal. Use the following configurations to pull the deals.
3. Build a timeline.
Results will be returned in two tables. I recommend reformatting results into a timeline that’s easier to understand. Marketers can then view the timeline by week or month, making it easier to see the relationship between ad exposure and sales activity. This is what Irdi’s timeline looks like.
4. Automate the analysis.
Using LinkedIn and HubSpot MCPs, an agent can handle this process by pulling both datasets, matching companies, and generating the timeline automatically.
“I run the agent every month to have a repeatable way to identify overlap between LinkedIn ad exposure and closed deals, even when those customers never clicked an ad,” shares Filippo.
A Few Agent Guardrails to Get You Started
Before Pulling Data
- Do not query anything until the ad account, exact date range, time granularity, and output format are defined.
- Do not interpret vague periods such as “Q3” or “last quarter.” Convert them to explicit dates and confirm them.
- Show the expected API cost of monthly vs. weekly granularity before running the analysis.
Time Periods
- Define the complete time grid before pulling data.
- Mark partial weeks or months explicitly.
- Keep LinkedIn exposure bucketed by week/month, but keep deal close dates on their exact dates.
LinkedIn Data
- Never use only currently active campaigns for historical analysis.
- Never reuse one period’s campaign list for another period.
- If company-level data comes back empty but campaign performance shows impressions, treat it as a likely campaign-selection problem—not “no data.”
- Preserve LinkedIn organization IDs for deduplication.
HubSpot Data
- Retrieve the HubSpot portal timezone before processing close dates.
- Identify closed-won deals using hs_is_closed_won, not hardcoded stage IDs.
- Use home-currency values when calculating totals across currencies.
Sales Use Case: An AI Sales Compensation Agent
Commission disputes rarely stem from a single bad month. They come from reps not being able to see the math. AI can help.
Driven, a sales commission platform, built an agent for HubSpot that takes a question or a planning document. The agent reviews Driven’s compensation data and returns an explanation grounded in specific deals and targets.
Andres De Jonge, co-founder at Driven, explains how the agent works.
- How reps use the agent: A rep asks, “Why is my payout lower this month?” The agent pulls their payout, the credited deals, and quota attainment. It then explains the gap, for example: “Two deals slipped to the next period, and attainment dropped below the 100% accelerator threshold.”
- How admins use the agent: An admin pastes a rule, uploads a plan PDF or Excel file, or selects CRM fields. The agent translates it into a structured draft plan, including formulas, tiers, quota references, and filters. It also runs a preview against real historical deals.
Inputs for this agent are natural-language questions, plan documents (PDF, Word, Excel), and CRM field selections from HubSpot or Salesforce, synced into Driven’s database. Outputs are payout explanations with linked deals, variance breakdowns between periods, and draft plan configurations with calculation previews.
If you try replicating this agent, you may encounter a bump since the agent model never does the math. Payouts are calculated by Driven’s formula engine with decimal.js for financial-grade rounding. The agent’s job is to fetch the calculation trace and explain it, or to propose a configuration that the engine then executes.
Service Use Case: Find Recurring Support Issues With HubSpot and ChatGPT
Your support team may answer the same question dozens of times without realizing how often it comes up. Connecting HubSpot to ChatGPT lets you investigate recurring ticket topics and decide which issue deserves better documentation or a closer look from the product team.
Here’s how it works.
1. Connect HubSpot to ChatGPT.
Ask your HubSpot Super Admin to approve the connector and grant access to the ticket data you’ll review. Then, in ChatGPT, open Settings > Apps > HubSpot > Connect. Follow the prompts to select your HubSpot account and authorize the connection.









