How to build a deal processing agent
An SDR sits down on a Monday morning, looks at the CRM, and sighs. 30 deals to qualify, 30 emails to send, 30 calendars to check, and 30 meetings to book.
Having a pipeline is great, but working through it is a ton of work. So let’s get AI to do it.
Here, you’re going to build a deal processing agent that will:
- Review new deals and qualify them based on your criteria (deal value, completeness, timeline)
- Check your calendar and find available meeting slots
- Book discovery calls and send calendar invites
- Send personalized emails to qualified leads with the right context
- Update your CRM with status changes and activity logs
By the end of this tutorial, you'll have an agent that processes the initial stages of deals automatically, so you can focus on selling instead of administrative work.
What we’re building
Let’s run through how our agent goes about processing deals.
It starts with our CRM, which in this case is a Retool database. You could imagine this being connected to a contact form on your website to take in the necessary information for each lead. We’ve added a few mock details to ours, with each record including:
- Basic company information (name, industry, size)
- Contact details (name, email, phone)
- Deal specifics (value, requirements, timeline)
- Status tracking (currently all set to "New")
For example, we have TechStart Solutions requesting $125,000 worth of custom dashboards with an "ASAP" timeline. They've provided complete information, including contact details and a clear description of their needs. This is exactly the kind of deal an SDR wants to jump on immediately.
However, we also have deals like HealthBridge Medical at $8,500, which lacks company size information, and InsureTech Co at $7,200, both of which may not meet our qualification criteria. These need different handling, either requesting more information or potentially being deprioritized.
The agent's job is to process all of these automatically, applying consistent qualification logic and taking the appropriate action for each one.
We’ll interact with our agent through a chat window, and all we need to do is ask, “Can you process new deals?”
![Agent responding to deal processing request, showing GetNewDeals tool usage and qualification reasoning.]](/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fbclf52sw%2Fproduction%2F5cf0b02475af6fce18cffeda99652838048a1617-1122x1236.png%3Fw%3D1200%26q%3D80%26fit%3Dmax%26auto%3Dformat&w=3840&q=75)
With that single command, the agent will run through each “New” lead in the CRM and decide whether to qualify each deal based on the criteria in the instructions or ask for more information from the lead.
If the lead is good, it looks for free times in the user's calendar and books a time:

The agent then sends out an email with next steps:

If the lead isn’t so good, we can ask for more information:

The agent can run through dozens of leads in just a few minutes, allowing the sales team to work on higher-value tasks and close more deals.
What you’ll need to get started
The prerequisites for this are pretty simple:
- A CRM. You can connect your CRM to Retool and feed your agent data from there, or use a Retool database as your CRM.
- Email. We’re sending emails automatically to each lead for meetings or information. Retool will use the current user's email to send these emails.
- Agents. Agents are available to all Retool users, so you can just head to the Agents tab in your dashboard to get started.
That’s all you need to start building.
How to build a deal processing agent
Now that we’ve established what this agent will do and what you’ll need to build it, lets begin building.
Setting up your agent
Head to the Agents tab and then select New Agent. For this agent, we’ll select Start from scratch. Give your agent a name (e.g., “Deal Processing Agent”) and a description if you want.
Select Create, and you’ll be taken to the configuration pane:

This is the hub from which you will build your agent. Here, you will add the two key components:
- Instructions: The prompt that defines what the agent should do, how it should behave, and how it should use available tools and data to accomplish its tasks.
- Tools: The capabilities the agent can use to take actions, like sending emails, querying databases, or updating records in your CRM.
There are also other, more advanced settings that you can change here, such as the trigger (you can also email your agent to initiate deal processing), model (use any SOTA model or your custom AI), temperature for creativity, and maximum iterations for stopping your agent.
But for building your agent, the instructions and tools are where it’s at.
Create your agent instructions
Instructions are the natural language prompts your agent sends to the LLM, so it knows what it needs to do. You can think of this as detailed guidelines for the workflow you want the agent to follow, as well as how to access your tools to achieve the aim.
Let’s walk through our instructions to see what our agent is doing. First, the role definition:
This establishes your agent's identity and core responsibility. By defining it as "professional" and "responsible for managing new deals," we set expectations for tone and scope. The agent knows it's not handling customer support or technical questions; it's focused solely on deal processing.
We follow this with the core workflow:
These first two steps define the qualification logic. You're telling the agent exactly what constitutes a qualified deal. Without these specific criteria, the agent would need to make judgment calls, which isn’t great for AI to do (you don’t want your agent lowballing deals). Therefore, you should use concrete thresholds (such as $10,000) rather than vague terms like "high value."
Then we move on to the actions your agent can take:
This creates two distinct paths based on the qualification outcome. Each path has a clear sequence of actions. The agent knows that qualified deals get immediate scheduling, while incomplete deals get information requests. Again, the specificity here (3-5 business days, two business days) prevents the agent from making arbitrary decisions about timing.
Your agent is emailing people, and again we don’t want it going rogue with this communication, so let’s set out the emails to send:
The ${variables} tell the agent which data to pull from the deal record and where to insert it.
Pro tip: Always add guardrails to any agent you create, like this:
These are the safety rails. They prevent common mistakes (like duplicate processing) and reinforce priorities (high-value deals first). Think of these as the things you'd repeatedly remind a new hire about during their first week.
Finally, add some helpful information for the agent:
These variables inject real-time data into the instructions. The agent needs to know whose calendar to check, which timezone to use for scheduling, and the current date to calculate the "next 3-5 business days." The double curly braces {{ }} are Retool's syntax for dynamic values that get evaluated when the agent runs.
Now, let’s give your agent the tools it needs to act on these instructions.
Connect your tools
Here’s all the tools we’re giving our agent to execute the instructions:

This seems like a lot, and it is. After all, we want our agent to be able to perform a lot of functions to process all our deals. But adding these tools is very simple, for two reasons.
First, five of these tools (Send Email, Create Calendar Event, Get Calendar Events, Get Open Time Slots, and Search Web) are all built-in tools in Retool. All you have to do is add these tools from the Add Tool menu. Here’s what do these tools do:
- Create Calendar Event, Get Calendar Events, and Get Open Time Slots handle all the scheduling logic. The agent uses these to check your availability, find open slots that work for discovery calls, and actually create the calendar invites that get sent to prospects.
- Send Email lets the agent send the qualification emails and information requests directly from your email account.
- Search Web gives the agent the ability to research companies if it needs additional context.
The other four tools are all custom. We need them for the specifics of interacting with our CRM:
- GetNewDeals queries the database for all deals with status "New" that haven't been processed yet. This is how the agent knows which deals need attention.
- UpdateDealStatus changes a deal's status in the CRM from "New" to "Qualified" or "Needs Info" based on the agent's assessment. This keeps your pipeline organized and lets the team know which deals have been reviewed.
- LogDealActivity records every action the agent takes (emails sent, meetings scheduled, status changes) in the deal's notes. This creates an audit trail so you can see exactly what the agent did with each deal.
- GetDealDetails retrieves all the information about a specific deal (company name, contact info, requirements, etc.) when the agent needs it. The agent uses this to pull the data it needs to personalize emails and make qualification decisions.
To create a new tool, head to Add tool then Create new custom tool. You then want to give the tool a name and a description:

The magic of tools happens in the Function Logic. This is where you can create a workflow that runs each time the tool is invoked. Let’s take a look at the logic for the GetNewDeals tool:

We don’t have any parameters, as we want to get everything in the database. We do that through this SQL code:
This selects all data from our table where the status is “New.” Then we return the query results to the agent. As these are all Retool integrations, this could just as easily be a Salesforce or HubSpot query.
Some tools are a little more complicated. For instance, this is the logic for the LogDealActivity tool:

What is happening here? This tool follows a multi-step workflow to add activity logs to a deal record:
- params: Accepts four parameters: the deal_id to log activity for, the
activity_type(like "email_sent" or "status_updated"), a description of what happened, and a timestamp. - fetchNotesQuery: Runs a SQL query to retrieve the existing notes field from the deal record. Since we're storing activity logs as accumulated text in a notes field, we need to grab what's already there first.
- appendNoteBlock: JavaScript code that takes the existing notes and appends the new activity entry. It formats the new activity with the timestamp and description, then combines it with previous notes using a separator (likely newlines or formatting characters).
- updateNotesQuery: Writes the updated notes back to the database with an
UPDATE SQLstatement, replacing the old notes field with the new concatenated version. - returnBlock1: Returns a success response (status code 200) with the updated notes data, confirming the activity was logged successfully.
This pattern of fetch, transform, update is common for custom tools that need to modify existing data rather than just read or create new records. With this, we get a notes section that contains an audit trail of everything that has happened with the deal:
You can imagine multiple agents, all with access to this CRM, adding notes and allowing the human team to understand what is happening.
Now, you might look at that logic block above and worry about implementing it yourself, especially if you don’t have a lot of coding experience. But here is the second reason that adding these tools is very simple: the function generator. Instead of writing that logic ourselves, we can ask AI to write our logic for our tool for our AI agent to use. E.g., for the GetDealDetails tool, we might say:
The function generator will have a think and plan it out:

Then it’ll create the logic for you:

That’s all you need to do. Just use your plan as the input to the AI, and have the generator create all your tools! It’s magic, but unlike the other magic tools that are springing up everywhere, this one comes with built-in observability and metrics so you can double-check and verify the magic.
Running your agent
Now you can head back to the start and ask your agent to process deals. You don’t have to just go through each deal every time. For instance, we can just ask to process deals that aren’t qualified:

You can then see each email being sent:

In the right pane, you can see what each tool is doing as it works through the ask:

With a simple prompt and straightforward tools (which can also be generated through AI), we've streamlined an extremely manual and time-consuming process, reducing it to just a few minutes of AI time.
The agent processes deals consistently using your exact criteria, never forgets to follow up, and works around the clock. Your sales team can now focus on high-value activities, such as actual conversations with prospects, instead of spending time on administrative busywork.
What to build next
Now that you've built a deal processing agent, here are other workflows you could automate:
- Account Research Agent: Automatically research prospects before discovery calls by pulling company news, recent funding rounds, competitor information, and key executives to personalize your pitch
- Follow-up Sequence Agent: Monitor deals that haven't responded in X days, send personalized follow-up emails based on deal stage, and escalate to manual outreach after multiple attempts
- Meeting Prep Agent: Read previous conversation notes, pull relevant case studies from similar customers, generate discussion questions, and create a one-page brief before each sales call
- Proposal Generation Agent: Build custom proposals by pulling pricing from your database, selecting relevant case studies based on industry, and generating SOWs based on requirements discussed
- Pipeline Health Monitor: Review all deals weekly, identify stuck opportunities, flag deals missing next steps, and surface accounts that need immediate attention from sales leadership
Ready to build your own agent?
Head over to Retool Agents to start building. If you want to learn more about prompt engineering and tool design, check out the Retool Agents documentation.