Skip to main content

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

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:

Discovery Call calendar event for Acme Manufacturing scheduled for November 10 at 10:00 am.

The agent then sends out an email with next steps:

An email scheduling a discovery call for November 16, 2025, from Andrew at Retool Agents to Sarah, regarding internal tools for production scheduling and inventory tracking for Acme Manufacturing.

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

Email from Retool Agents with subject "Additional Information Needed - HealthBridge Medical", requesting company size and project timeline.

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:

Agent configuration page with instructions for an AI assistant including user variables, GPT-4.1 model selected, and an empty tools section.

This is the hub from which you will build your agent. Here, you will add the two key components:

    1.
  1. 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.
  2. 2.
  3. 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:

You are a professional deal processing agent responsible for managing new deals in our pipeline. 
When you receive a new deal, follow these instructions:

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:

### Instructions
1. Review the deal details including company name, deal value, contact information, and any notes about requirements.
2. Qualify the deal based on these criteria:
   - Deal value is above $10,000
   - Company has provided valid contact information
   - Required information fields are complete (company size, industry, timeline)

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:

3. For qualified deals:
   - Update the deal status to "Qualified" in the CRM
   - Send a welcome email to the primary contact acknowledging receipt and next steps
   - Schedule a discovery call within the next 3-5 business days during business hours
   - Create the calendar event with title "Discovery Call - ${companyName}" and invite the contact

4. For deals requiring more information:
   - Update status to "Needs Info" in the CRM
   - Send an email requesting the missing information
   - Set a reminder to follow up in 2 business days

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:

**Qualified Deal:**
Subject: Welcome to ${companyName} - Next Steps
Hi ${contactFirstName},
Thank you for your interest in our solution. I've reviewed your request for ${dealDescription} and I'm excited to explore how we can help.
I've scheduled a discovery call for us on ${meetingTime}. During this call, we'll discuss your specific needs and demonstrate how our platform can address them.
If this time doesn't work, please let me know and I'll find an alternative.
Looking forward to speaking with you!
Best,
{{ current_user.firstName }}

**Needs More Information:**
Subject: Additional Information Needed - ${companyName}
Hi ${contactFirstName},
Thanks for reaching out! To better assist you, I need a bit more information:
${missingFields}
Once I have these details, I can move your request forward quickly.
Best,
{{ current_user.firstName }}

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:

### Remember:
- Always verify deal value and contact info before proceeding
- Keep emails professional but warm
- Never process the same deal twice
- Prioritize high-value deals (>$50,000) for same-day response
- Log every action in the CRM

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:

### Additional Context:
You are acting on behalf of {{ current_user.fullName }} ({{ current_user.email }}).
Current date: {{ new Date() }}
Timezone: {{ timezone }}

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:

A software interface displaying a list of tools including GetNewDeals, Send Email, and calendar management options.

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:

A web page for creating a new custom tool with fields for name, description, parameters, function logic, and tool timeout.

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:

A visual programming workflow displaying a SQL query `SELECT * FROM mock_deals WHERE "status" = 'New'` connected to a return block with a 200 status code.

We don’t have any parameters, as we want to get everything in the database. We do that through this SQL code:

SELECT * FROM mock_deals WHERE "status" = 'New'

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:

Visual programming interface showing blocks for parameters, SQL queries, JavaScript code, and a return statement.

What is happening here? This tool follows a multi-step workflow to add activity logs to a deal record:

    1.
  1. 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.
  2. 2.
  3. 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.
  4. 3.
  5. 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).
  6. 4.
  7. updateNotesQuery: Writes the updated notes back to the database with an UPDATE SQL statement, replacing the old notes field with the new concatenated version.
  8. 5.
  9. 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:

Deal meets all qualification criteria: value above $10,000, valid contact info, and all required fields complete.
[2025-11-07T17:46:19Z] (status_update) Marked deal as Qualified after verifying all required criteria.

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:

Create a function that fetches complete information for a specific deal from the mock_deals table in the @Retool Database. 

Inputs: deal_id
Returns: all deal fields

The function generator will have a think and plan it out:

A chat log showing a user requesting a function to fetch deal information from a Retool Database by ID, and the "Function Generator" AI responding with a detailed plan outlining parameters (deal_id), steps (SQL Query, Execute Code), and expected outputs.

Then it’ll create the logic for you:

A workflow diagram shows a 'deal_id' parameter being used in a SQL database query, and the query's result being returned.

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:

A chat interface showing a user asking a "Deal Processing Agent" to identify unqualified deals and follow up. The agent's response outlines steps using tools like "GetNewDeals," "UpdateDealStatus," and "Send Email" to retrieve deals, identify missing information, update status, and send follow-up emails.

You can then see each email being sent:

An email titled "Additional Information Needed - GreenEnergy Solutions" requesting a project timeline.

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

Current activity screen from LogDealActivity showing details for deal ID 19, an email activity requesting a project timeline, and notes about the deal's status.

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.