How to build an AI agent: from goal to live deployment

7 hours ago 8

Want Your Business Featured Here?

Get instant exposure to our readers

Chat on WhatsApp

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.

Get Started with HubSpot's Agent Builder

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.

Table of Contents

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

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.

HubSpot’s agent marketplace displays prebuilt agents for data enrichment, customer service, prospecting, knowledge base creation, and deal analysis.

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.

instructions for updating an agent used to pre-qualify leads.

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.

Supported knowledge vault uploads include PDF, Markdown, HTML, PowerPoint, text, Word, Excel, CSV, JSON, and XML files.

With HubSpot, teams can also set AI context for agents. With Context filled out, AI will know virtually everything about you and your business.

HubSpot’s AI Context page shows a business summary, context coverage, and options to add files or custom text.

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.

A Company Research Agent test displays its output and estimated credit usage alongside previous runs.

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.

An example agent test spreadsheet compares expected and actual results across five cases, with pass/fail scores and reviewer notes.

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.

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:

  1. Define the job’s boundaries in the agent’s instructions, including how to handle unrelated requests and instructions found in source material.
  2. Limit the agent’s tools and permissions to what the job requires.
  3. Enforce access restrictions through the connected apps’ controls.
  4. Share only necessary private information and restrict who can view the output.
  5. Specify when the agent must stop and who should take over.
  6. Require an authorized person’s approval before sensitive or high-impact actions, enforced through the workflow or tool.
  7. 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.

A HubSpot workflow connects a property-change trigger, a delay, and a Video Clip Search Agent, with a separate Assign to Customer Agent action.

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.

Agent Inbox filters let users view runs by status, including Needs Approval, Success, Running, Failed, and Waiting.

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.

A LinkedIn API request and response show company-level ad impressions and engagement metrics for a selected week.

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.

A HubSpot CRM query retrieves closed-won deals within a date range, including amounts, close dates, pipeline details, and record links.

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.

A weekly heatmap compares LinkedIn ad impressions with deal close dates, with account names and deal values redacted.

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.”

Driven’s payout dashboard pairs a deal breakdown with an AI explanation of how quota attainment affects commission.

  • 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.

Driven’s AI plan builder uses an uploaded compensation document to display a live preview of deal-level payouts.

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.

2. Choose the tickets to investigate.

Start with one support pipeline and an exact date range. Open Deep research in ChatGPT and enable HubSpot under Apps. Then adapt this prompt:

Review HubSpot tickets created in [pipeline name] between [start date] and [end date]. Use the ticket names and descriptions you can access. Group tickets by the underlying customer problem, count each group, and link to supporting tickets. Keep unclear cases separate. State how many tickets you analyzed and any retrieval limits. Don’t change records.

3. Turn the findings into recommendations.

Once the report is ready, ask:

For the three largest groups, recommend what the service team should investigate next. Distinguish questions that might benefit from clearer instructions from reported product problems. Explain your reasoning using linked tickets. Flag where the evidence is insufficient.

Treat these as suggestions for review. Remember, seeing a symptom doesn’t establish its cause.

4. Check the evidence and assign the next step.

Open the linked tickets and check that they belong in their groups. Compare the reported total with the same filters in HubSpot. Then, investigate any mismatch before presenting the findings as a complete picture.

From there, give an approved recommendation to the appropriate owner. The deliverable is a short, sourced issue report. Judge its usefulness by whether the groupings are accurate, if the recommendations survive review, and if the process takes less time than your manual review.

When to Consider Models, Protocols, or Multiple Agents

Your first agent is up and running. As you give it more work, you may find breaking points. Before adding complexity, identify when the system breaks. That will help you decide whether to change the model, connect another tool, or divide the work among agents.

Choosing a Model

The model is the specific AI program that interprets instructions, evaluates information, and chooses the agent’s next step. Its capabilities affect the quality, speed, and cost of the work. Examples include models from OpenAI’s GPT, Anthropic’s Claude, and Google’s Gemini.

The tools you use may have a default AI model. If your platform lets you choose models, compare outputs using the same test cases. Pick the least expensive option that meets quality and response-time requirements.

What Agent Protocols Mean

A protocol is how software exchanges requests and results. For agents, there are two protocols:

  • Model Context Protocol (MCP). This connects AI applications to tools and data sources. For example, an agent could use an MCP connection to search an approved document library.
  • Agent2Agent (A2A). This allows independent agents to exchange tasks and results, including agents built on different platforms.

In Agent Hub, teams can connect external tools to HubSpot through MCP. This lets agents access live business data and take action across supported applications without custom integrations or code.

When Multiple Agents Make Sense

A multi-agent setup divides work among agents with separate responsibilities. One might gather research, while another uses that research to prepare a brief. Remember: more agents mean more outputs and handoffs to check. Add an agent only when the improvement in quality or speed justifies the extra cost and maintenance.

Consider splitting the work among agents when:

  • Different tasks need distinct tools, instructions, or access permissions.
  • Independent research tasks could run at the same time.
  • Testing shows that one agent repeatedly mixes up responsibilities despite a clear, narrow setup.

Pro tip: Always compare the combined result with your single-agent setup using the same tests.

Frequently Asked Questions About How to Build an AI Agent

Do I need a developer to build my first agent?

No, developers are not necessary when building AI agents. Bring in a developer when the task requires a custom integration or controls that your builder doesn’t support. You can build dozens of marketing, social media, and sales agents in a no-code builder like HubSpot Agent Builder.

How do I improve an AI agent without training a model?

Use failed tests to identify what needs changing. That may include unclear instructions, missing reference material, incorrect inputs, or unsuitable tools. Fix the relevant part and rerun your test set.

How should I handle sensitive actions like refunds or data deletion?

Set AI guardrails for high-impact actions. Have the agent prepare the proposed action for an authorized person to review. Show exactly what would happen, including the customer, amount, or records affected. Enforce approval through the workflow or connected tool, and keep execution blocked until approval arrives.

When should I move from one agent to multiple agents?

Build multi-agent systems when testing shows a clear benefit from separating responsibilities. For example, different tasks might need separate access permissions. If you add another agent, define what each one receives and returns, then compare quality, speed, and total cost with your original setup.

What data can a no-code AI agent use?

Access depends on each builder, its supported connections, and the permissions you grant. Common sources include CRM records, uploaded documents, help articles, spreadsheets, and information supplied with each request. HubSpot’s knowledge vaults support files, images, selected HubSpot content, and CRM segments.

Start with one agent your team can rely on.

When building your first agent, start with one task your team knows well. Give the agent the information and tools it needs, then test its work against clear expectations. And, before you scale an agent, review results carefully.

Already a HubSpot user? Agent Builder lets you create agents in plain language, no coding required. So get started, and see what you can build.

Read Entire Article
Chatroom