Data Context Builder

Data Context Builder

Data Context Builder is a packaged System Agent that helps admins define AI Data Context Definition records and the JSON used to load Salesforce data context for agents, templates, and other services.

What it handles

  • Clarifies the primary record and related datasets needed for a use case.
  • Verifies object, field, and relationship names before they are added to the definition.
  • Produces a valid Data Context Definition (DCD) JSON structure and saves it back to the current definition record.
  • Tunes the data shape for agent enrichment, document generation, and other runtime consumers.
  • Creates deterministic aggregate datasets for rollups that should be available to templates and agents.

Data context capabilities

The Data Context Builder can create record-scoped definitions that start from a master Salesforce record, then add:

  • The master record fields, such as Opportunity, Account, Case, Contact, or a custom object.
  • Parent datasets, such as the Account for an Opportunity.
  • Child datasets, such as Opportunity Products, Contacts, Cases, or related custom records.
  • Literal filters, sorting, and record limits for row-based datasets.
  • Field aliases that make long Salesforce API names easier to use in templates.
  • Single-row aggregate datasets for deterministic totals, counts, distinct counts, and min/max values.

Aggregate datasets use aggregateFields and support:

Function Use it for Example field
sum Numeric or currency totals Amount, TotalPrice, Quantity
count Record counts Id
countDistinct Number of distinct non-null values Product2.Family, StageName
min Lowest value or earliest date TotalPrice, CloseDate
max Highest value or latest date TotalPrice, CloseDate

Aggregate datasets are single-row only. They do not support grouping, avg, GROUP BY, or HAVING. For financial or operational totals, prefer DCD aggregates over template-time arithmetic so the values are deterministic and available to both AI agents and rendered documents.

Prompt examples

Use plain business language. The agent should confirm object and field API names with Salesforce metadata before saving the DCD.

Opportunity context

Ask:

Create a data context for an Opportunity quote. Include Opportunity fields, Account billing fields, Opportunity Products, and aggregate totals for line item revenue, line count, distinct product families, smallest line total, and largest line total.

Expected aggregate intent:

  • Master: Opportunity
  • Child object: OpportunityLineItem
  • Relationship: OpportunityLineItem.OpportunityId
  • Aggregates:
    • sum(TotalPrice) as totalLineRevenue
    • count(Id) as lineItemCount
    • countDistinct(Product2.Family) as distinctProductFamilies
    • min(TotalPrice) as smallestLineTotal
    • max(TotalPrice) as largestLineTotal

Ask:

Add filtered implementation product totals to this Opportunity data context. Only count Opportunity Products where Product Family is Implementation.

Expected aggregate intent:

  • Object: OpportunityLineItem
  • Filter: Product2.Family = "Implementation"
  • Aggregates:
    • sum(TotalPrice) as implementationRevenue
    • count(Id) as implementationLineCount

Ask:

Add earliest and latest service dates for Opportunity Products if the org has a service date field on line items.

Expected aggregate intent:

  • Object: OpportunityLineItem
  • Confirm the date field API name first.
  • Aggregates:
    • min(<ServiceDateField>) as earliestServiceDate
    • max(<ServiceDateField>) as latestServiceDate

Account context

Ask:

Create an Account data context with totals for closed-won Opportunity revenue, open Cases, closed Cases, and Contacts.

Expected aggregate intent:

  • Master: Account
  • Closed-won Opportunity revenue:
    • Object: Opportunity
    • Relationship: Opportunity.AccountId
    • Filter: IsWon = true
    • Aggregate: sum(Amount) as closedWonRevenue
  • Open Cases:
    • Object: Case
    • Relationship: Case.AccountId
    • Filter: IsClosed = false
    • Aggregate: count(Id) as openCaseCount
  • Closed Cases:
    • Object: Case
    • Relationship: Case.AccountId
    • Filter: IsClosed = true
    • Aggregate: count(Id) as closedCaseCount
  • Contacts:
    • Object: Contact
    • Relationship: Contact.AccountId
    • Aggregate: count(Id) as totalContacts

Ask:

Add Account Opportunity health metrics: total open pipeline, distinct active stages, smallest open Opportunity, largest open Opportunity, earliest close date, and latest close date.

Expected aggregate intent:

  • Object: Opportunity
  • Relationship: Opportunity.AccountId
  • Filter: IsClosed = false
  • Aggregates:
    • sum(Amount) as openPipeline
    • countDistinct(StageName) as distinctOpenStages
    • min(Amount) as smallestOpenOpportunity
    • max(Amount) as largestOpenOpportunity
    • min(CloseDate) as earliestOpenCloseDate
    • max(CloseDate) as latestOpenCloseDate

Ask:

Add contact coverage metrics to the Account context: total Contacts and distinct Contact titles.

Expected aggregate intent:

  • Object: Contact
  • Relationship: Contact.AccountId
  • Aggregates:
    • count(Id) as totalContacts
    • countDistinct(Title) as distinctContactTitles

Operating notes

  • This is a bootstrap helper for the iDialogue Agent OS.
  • It is typically installed as foundational system tooling and reused across implementations.
  • The agent should not guess field names. It should inspect Salesforce metadata when object, field, or relationship API names are uncertain.
  • Aggregate datasets expose alias keys only, not Salesforce expression names like expr0.
  • See System Agents for how packaged helper agents are resolved.
  • See Data Context Definition (DCD) for the underlying schema.
iDialogue Agent

Ask about this page, related knowledge or specific iDialogue product and support features.