Optimizing AI Data Agent in Workflows: Email Analysis and Record Updates Based on Returned Deal ID

Hi everyone! :waving_hand:

I’ve recently been testing the capabilities of the AI Data Agent in HubSpot. I set up a workflow that verifies logged one-to-one emails for either quote requests or delivery issue reports. So far, the AI is doing great—I haven’t noticed any major errors or hallucinations.

However, I’d like to consult my process with you.

How my current workflow operates:

  • Trigger (Testing phase): Logging an email assigned to a specific user.
  • Step 1 (AI Analysis): The Data Agent examines the email subject and body, then routes it to one of two branches.

Branch 1: Sales Inquiry

  1. The system creates a new Deal associated with the Contact. It copies the Contact owner and sets them as the Deal owner.
  2. The Data Agent re-analyzes the email, comparing it with the text in the Contact property - “Offer”; (our standard offer is placed ther - text property).
  3. Next a Note is created on the newly created Deal with an AI-generated draft response for the customer.

Branch 2: Delivery Issue Report

  1. The Data Agent re-examines the email, this time looking for a tracking or order number. Then, the AI looks for a match for this data in the names, descriptions, or properties of existing Deals.
  2. Result: The Data Agent returns the ID and name of the matched Deal, than a Note containing this information is created on the Contact.

**
My questions for the community:**

1. Is this workflow built optimally? Do you see any areas where I could optimize this (e.g., avoiding calling the Data Agent twice), or are there other native features/tools I should use instead of the current setup? I didn’t use the Customer Agent because I don’t want the AI replying directly to customers.

2.Is storing the offer in a text property optimal(Branch1)? Currently, I am using a custom text property where our standard offer is pasted as text. The Data Agent with Data Tokens analyzes this property very well and generates highly accurate responses based on it. However, I’m wondering if this is the most optimal and scalable approach in HubSpot, or if I should be storing and referencing this offer data differently? I’ve tried using a file property with the .pdf file, but it doesn’t work at all.

3. Using the returned ID to change a property (Branch 2):

Since the Data Agent correctly returns the ID of the matched Deal in the second branch, am I able to create an action in the workflow that dynamically uses this knowledge (this specific ID) to update a property on that Deal—e.g., setting a property like “Delivery issue reported - Yes”? How can I technically pass this ID to the record update action?

Thanks in advance for any tips!

Hey @SzymonSzymski,

Thank you for posting in the Community!

Tagging in a few Community experts here to see if they have any insight to share regarding your inquiries. @karstenkoehler, @danmoyle, and @Josh - any input for @SzymonSzymski ?

Shane, Senior Community Moderator

Hey @SzymonSzymski. I think this is a really interesting use case for an agent, and a solid setup for a pilot. Keeping the AI response as an internal draft instead of auto-sending is the right call. As to your optimization question, here’s my 2 cents.

On calling the Data Agent twice: You can cut this down by having your first prompt return more than just a routing decision. I’d try asking it to return intent, the order or tracking number (if present), a confidence level, and a short summary, all in one pass. Then branch on intent. That removes the second call entirely in the sales branch. In the delivery branch, you’ll likely still need a second step, but it can be a deterministic lookup instead of another AI analysis call.

One thing worth flagging: the Data Agent only works with what you explicitly hand it in the prompt. It doesn’t pull in every contact property or timeline activity on its own, so keep your context intentional.

As for the the offer text property, I think using a text property works fine for one stable offer, since the Data Agent reads it well as a token. It won’t scale cleanly if you ever have multiple offers by region, product, or segment, and it makes version control harder over time. A custom object like “Offer” or “Commercial Policy,” associated to the relevant record, gives you a lot more room to grow. As for the PDF file property not working, that tracks. Custom Prompt actions need text handed to them directly. They don’t parse attachments on their own.

Now on to updating the matched Deal. This is the one I’d spend some time with. It’s the one I personally leaned into AI research to better understand. Here’s what I got back in my ‘conversation’ with Perplexity: The Edit record action expects an already-associated record. It won’t use an AI-returned ID as a dynamic target on its own. The cleanest native path is to have the AI extract just the tracking or order number, then use a Find one record action to look up the Deal by a dedicated identifier property. From there, you can pass that found Deal into Edit record and update your delivery issue fields. If your builder doesn’t have that lookup action yet, a custom code step that queries the Deals API and confirms a single match is the more flexible fallback.

So to your general question on how this looks. Overall, I’d lean on AI for extraction and classification, native lookup for identity resolution, and native workflow actions for the actual update. Keeps the parts of this that are working well working well, without letting a plausible match turn into a wrong one.

Hope that helps!