Prompt Builder

Ground a prompt template in curated context instead of raw merge fields. Every ContextWorks action is an ordinary Apex action, so Prompt Builder can add one as a resource — no flow, no class to write. The template gets the same payload an agent gets, assembled fresh on each run from the entity’s active version.

Add the action as a resource

  1. Setup → Prompt Builder. Open your template, or click New Prompt Template and choose Flex. Add a resource for the record: set Source Type to Object and pick the object.
  2. In Resources, click + beside Actions and choose Apex.
  3. Pick the action. They sit in the ContextWorks category, labeled ContextWorks: Get Records, ContextWorks: Find Records and ContextWorks: Get Catalog. In an installed org their API names carry the ctxl namespace.
  4. Fill in the inputs. Get Records and Find Records each need a Domain, which decides the entity that answers for each object. Record IDs is usually the template’s record variable; Level, Format and Entity are optional.
  5. Put the cursor where the context belongs in the prompt body and insert the action’s Result output.
  6. Preview against a real record to see the resolved prompt, then Activate.

Which action

ActionUse forInputs that matter
Get RecordsOne record, or a few by IDRecord IDs, Level, Domain
Find RecordsA set the template describes — this quarter’s open renewalsDomain, Object API Name, Filters, Sort By, Max Rows, Level
Get CatalogRarely — it’s discovery, for agents that plan their own calls

Full input reference: Invocable actions. Filter syntax: Query filters.

Notes

  • Leave Format as markdown. It reads as prose to the model. Use json only when something downstream parses the output.
  • Match the Level to the job. Get Records defaults to detailed; drop to standard or list when the prompt covers several records, or when context crowds out your instructions. Find Records returns the entity’s list columns unless you ask for standard.
  • Leave Entity empty for a mix of objects. Each record comes back through the domain’s entity for its own object. Name Entity only to pin one object’s view.
  • The template resolves as the user who runs it, so security applies unchanged — two users can get different context from one template.
  • A failed call returns Success = false and an Error Message rather than throwing, so the template still renders. Check Preview if a section comes back empty.

Need a call the inputs can’t express? A scoped tool is a plain invocable action too. It appears in the same picker, with the domain and level already pinned.

What’s next