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
- 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.
- In Resources, click + beside Actions and choose Apex.
- 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
ctxlnamespace. - 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.
- Put the cursor where the context belongs in the prompt body and insert the action’s Result output.
- Preview against a real record to see the resolved prompt, then Activate.
Which action
| Action | Use for | Inputs that matter |
|---|---|---|
| Get Records | One record, or a few by ID | Record IDs, Level, Domain |
| Find Records | A set the template describes — this quarter’s open renewals | Domain, Object API Name, Filters, Sort By, Max Rows, Level |
| Get Catalog | Rarely — 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
jsononly when something downstream parses the output. - Match the Level to the job. Get Records defaults to
detailed; drop tostandardorlistwhen the prompt covers several records, or when context crowds out your instructions. Find Records returns the entity’s list columns unless you ask forstandard. - 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 = falseand 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.