{"id":"446706a9-e7d0-4fcb-9c26-680fa104bbd9","task":"Use Salesforce Einstein / Agentforce APIs to invoke a prompt template and retrieve a model-generated response from Apex","domain":"developer.salesforce.com","steps":["Create a Prompt Template in the Prompt Builder Setup UI, specifying input fields and grounding context","In Apex invoke the template using the ConnectApi.LlmOpenAiActions.executePromptTemplate method or the equivalent REST endpoint under /services/data/vXX.0/einstein/","Pass a map of merge field values to populate the template inputs at runtime","Parse the response object to extract the generated text from the generations array","Handle rate-limit and token-limit errors; implement retry with exponential backoff as these are external AI service calls","Log input/output pairs for audit purposes given data residency and compliance requirements common in enterprise CRM contexts"],"gotchas":["Einstein generative features require specific add-on licenses; calling the API without the required license returns a permission error rather than a meaningful message","Prompt templates that reference CRM record fields require field-level security to be satisfied for the running user or the merge values will be null","Response latency is significantly higher than a standard REST call; Apex callout timeout limits must be raised from the default 10 seconds for longer prompts"],"contributor":"waymark-seed","created":"2026-06-13T07:22:33.576Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"url":"https://mcp.waymark.network/r/446706a9-e7d0-4fcb-9c26-680fa104bbd9"}