Step-by-Step Guide to Calling Prompt Template from REST API

This guide is part of our series on “Mastering Agentforce”.

To explore the complete series, please click here.

Defining Prompt Templates in Salesforce allows us to analyze data stored in various ways, providing valuable insights powered by Generative AI.

Calling these templates through REST APIs extends the capabilities of Generative AI beyond Salesforce, enabling other external applications to benefit from these insights. By leveraging Salesforce’s native and declarative features, you can transform Salesforce into your company’s GenAI platform.

Real-World Use Case: Proactively Managing Opportunity Risks with AI

In one of our other guides, we created a Prompt Template to analyze open cases and opportunities for an account and assess the potential impact of those cases on ongoing opportunities.

For instance, imagine you are working to close an opportunity with a customer for a large order of mobile generators. However, the same customer also has a high-priority case open regarding issues with a generator they previously purchased. This scenario signals a potential risk: the customer may hesitate to make another purchase if they’re dissatisfied with their existing product or service.

Below is an example of the outcome generated by this Prompt Template.

While this Prompt Template works well within Salesforce, you may want to access these insights in external applications like a Management Information System (MIS) app or a Risk Assessment tool.

This is where calling the Prompt Template from Salesforce via REST API comes in. You can use the API to fetch insights generated by Salesforce’s Prompt Templates and process them in these external applications.

What You’ll Learn in This Guide

In this guide, you’ll learn how to call a Prompt Template using REST API. To demonstrate this, we’ll use an app called Postman.

Postman is a simple and intuitive tool for working with APIs. It lets you send API requests, view responses, and understand how APIs work, making it easier to integrate them into your workflows.

Once you learn how to call Prompt Templates via REST API, you’ll be able to apply the knowledge to your own environment and make API calls tailored to your needs.

Here’s a visual representation of what we’ll be building in this guide:

Outcome of Calling Prompt Template from REST API

Step-by-Step Guide: Calling Prompt Template from REST API

This process is simple and should take 15-20 minutes to configure and test. Here’s what the guide covers:

  1. Create a Prompt Template (we will be using the prompt template created in the Step-by-Step Guide to Using Flow Merge Fields in Prompt Template)
  2. Register & Sign in to Postman
  3. Get the Salesforce APIs collection for Postman
  4. Connect to Salesforce from Postman
  5. Call the Prompt Template through REST API

In the overall flow of Agentforce, the following diagram highlights the key components that we will cover in this guide.

Agentforce Flow Overview - Calling Prompt Template from REST API

NOTE: Certain sections of the guide will appear as locked in the free preview. You can download the unlocked version of the guide in PDF format by subscribing to our “All Access” Pass through the link below.

Not an “All Access” Pass Member Yet?

Get Download Access to this & 150+ More Step-by-Step Guides with “All Access” Pass. A simple and single plan to access our entire library of courses, guides, workshops & masterclasses on Salesforce.

Unlock the Power of Salesforce Generative AI: Master Agentforce!

Discover how to leverage Salesforce’s cutting-edge Generative AI tools to streamline your workflows and boost productivity.

Our comprehensive guides and hands-on workshops will take you from beginner to expert in no time. Learn the ins and outs of Agentforce, Agents, Topics, Actions and Prompt Builder with step-by-step tutorials, best practices, and real-world examples.

We also offer live onsite/online training for Salesforce partners, as well as consulting and implementation services for Salesforce customers.

Conclusion

By following this guide, you now know how to call Prompt Templates from Salesforce using REST API. This functionality unlocks the potential to integrate Salesforce’s Generative AI capabilities with external systems, enabling broader use of insights for decision-making and operational efficiency.

Experiment with more Prompt Templates in your Salesforce Org and integrate them with external tools to expand the scope of what Generative AI can achieve for your organization.

References & Useful URLs

Scroll to Top