Appearance
Exercise 2 (Optional): Invoke a Prompt Template using the REST API
In this exercise, you’ll use Postman to invoke the prompt template through the Connect REST API, so you'll learn how to use it when calling out from an external system.
Step 1: Invoke the prompt template from Postman and the Connect REST API
Navigate to https://www.postman.com.
Sign in or create a new account.
Navigate to the Salesforce Platform APIs postman collection.
Fork the collection by clicking on the Fork button on the top right corner.
Leave the default Fork label and Workspace, and click on Fork collection.
Navigate to the Authorization tab.
Scroll to the bottom and click on Get New Access Token.
Log into your org, and Allow Access.
Close the window, and click Proceed.
Copy the instance_url value.
Click Use Token (very important).
Open the Variables tab and paste the
instance_url
value that you copied in the Current value column for endpoint.Don’t forget to click Save, on the top right corner.
Step 2: Run a request to Salesforce from Postman
In the collection, open Connect > Einstein > Generate Response Based on Template.
Navigate to the Params tab.
Locate the PROMPT_TEMPLATE_API_NAME path variable and set its value to
Generate_Social_Media_Posts
.Navigate to the Body tab.
Replace <INPUT_PARAMS> with:
javascript"Input:experienceSession": { "value": { "id": "An Experience Session Id from your org" } }
Replace the Id above with an Id that corresponds to an experience session record in your org.
TIP
You can copy it from the URL of the record page.
Click Send.
You should receive a response including the prompt and generations (what the LLM responded).
That’s it! You saw how flexible prompt template invocation is, and how developers can leverage it to create generative AI-powered apps on and off the Salesforce Platform.