Invoke Flows From Prompt Template in Salesforce Agentforce

When the customer raises a query regarding the issue they are having with the product, and if they ask for a refund, the support agent needs to go through the terms and conditions of the product sold to give the customer a refund.

So here, if we have the AI in Salesforce Agentforce, it understands the issue and shows the agent a suggestion using a prompt template. The template gives agents options to launch a flow.

In this tutorial, we will learn how to invoke flows from prompt template in Salesforce Agentforce, which will provide some dynamic data to the prompt template.

Invoke Flows From Prompt Template in Salesforce Agentforce

To invoke an apex class, we should have a method with an Invokable method as a notation and a capability type as one of the prompt template types. If this method has the prompt template type, then it is accessible in our prompt template.

Now, to make a flow Invokeable from the prompt template, we need to create a special flow type to use in the prompt template. So, if we go to the flows and try to create a new flow, we will see a new type here.

Here, we will see a new option called template-triggered prompt flow, which invokes it from the prompt template.

Create an Invocable Flow in Salesforce

Now, we will create the template-triggered prompt flow and call it in the prompt template in Agentforce.

Before starting to create the flow, we also want to utilize the same prompt template that was created. This prompt template will be used to summarize the account summary field. It needs the contact details previously provided by the apex class.

Prompt Template Builder in Salesforce

Now to create the flow, navigate to Setup -> in Quick Find, search for Flows -> New Flow -> select Start From Scratch -> in Flow Type, select Template-Triggered Prompt Flow -> click the Create button to proceed.

In this flow, we can add instructions, and the flow can invoke from the prompt template.

Create Flow to call from Prompt Template in Salesforce

It is asking for the Input Type, so I have selected Automatic Inputs because we are taking input from prompts. Then, which Prompt Template Type is going to invoke this flow? So we are saying that it will be a Field Generation Template Capability.

After that, we need to select the object for that prompt template. Here is the Account.