An Agentforce wants to include data from the response of an external service invocation (REST API callout) into a prompt template. The goal is to incorporate dynamic data retrieved from an external API into the AI-generated content.
Solution:
External Service Integration:
Definition:External Services in Salesforce allow the integration of external REST APIs into Salesforce without custom code.
Registration:The external service must be registered in Salesforce, defining the API's schema and methods.
External Service Record Merge Fields:
Purpose:Enables the inclusion of data from external service responses directly into prompt templates using merge fields.
Functionality:
Dynamic Data Inclusion:Allows prompt templates to access and use data returned from REST API callouts.
Merge Fields Syntax:Use merge fields in the prompt template to reference specific data points from the API response.
Implementation Steps:
Register the External Service:
UseExternal Servicesto register the REST API in Salesforce.
Define the API's schema, including methods and data structures.
Create a Named Credential:
Use External Service in Flow:
Build aFlowthat invokes the external service and captures the response.
Ensure the flow outputs the necessary data for use in the prompt template.
Configure the Prompt Template:
UseExternal Service Record merge fieldsin the prompt template to reference data from the flow's output.
Syntax Example: {{flowOutputVariable.fieldName}}
Why Other Options are Less Suitable:
Option A (Convert the JSON to an XML merge field):
Irrelevance:Converting JSON to XML merge fields is unnecessary and complicates the process.
Unsupported Method:Salesforce prompt templates do not support direct inclusion of XML merge fields from JSON conversion.
Option C (Use “Add Prompt Instructions” flow element):
Purpose of Add Prompt Instructions:
Allows adding instructions to the prompt within a flow but does not facilitate including external data.
Limitation:Does not directly help in incorporating external service responses into the prompt template.
[References:, Salesforce Agentforce Specialist Documentation -Integrating External Services with Prompt Templates:, Explains how to use External Services and merge fields in prompt templates., Salesforce Help -Using Merge Fields with External Data:, Provides guidance on referencing external data in templates using merge fields., Salesforce Trailhead -External Services and Flow:, Offers a practical understanding of integrating external APIs using External Services and Flow., Conclusion:, By using External Service Record merge fields, the Agentforce Specialist can effectively include data from external REST API responses into prompt templates, ensuring that the AI-generated content is enriched with up-to-date and relevant external data., ]
Submit