Contact Us

April 12, 2024

June 4, 2026 12:36 pm

Calling prompt templates from a community user in Agentforce

Share with

Understanding the Issue

The error message indicates that the community user lacks the necessary permissions to access the Prompt Template feature. This is because the Prompt Template User permission set only provides access to the Prompt Template feature, but does not grant the necessary Data Cloud permissions.

The root cause of the issue is the missing Data Cloud permission set, which is required to access the Prompt Template feature from a community user.

Step-by-Step Solution

To resolve the issue, follow these steps:

First, assign the Prompt Template User permission set to the community user. This will provide access to the Prompt Template feature.

Next, assign the Data Cloud permission set to the community user. This will grant the necessary Data Cloud permissions to access the Prompt Template feature.

Finally, ensure that the Apex code is executed with the necessary privileges by using the without sharing keyword.

ApexExample.cls

public without sharing class ApexExample {    public static void callPromptTemplate() {        ConnectApi.EinsteinLLM.generateMessagesForPromptTemplate('templateId', new ConnectApi.EinsteinPromptTemplateGenerationsInput());    }}

Best Practices

To avoid similar issues in the future, ensure that community users have the necessary permission sets and that Apex code is executed with the necessary privileges.

Heads up: always test your code in a development environment before deploying it to production.

Checklist

  • Assign the Prompt Template User permission set to the community user
  • Assign the Data Cloud permission set to the community user
  • Use the without sharing keyword in Apex code
  • Test code in a development environment before deploying to production
  • Ensure that community users have the necessary permissions to access the Prompt Template feature

What is the Prompt Template User permission set?

The Prompt Template User permission set provides access to the Prompt Template feature.

What is the Data Cloud permission set?

The Data Cloud permission set grants the necessary Data Cloud permissions to access the Prompt Template feature.

How do I assign permission sets to a community user?

You can assign permission sets to a community user by going to the community user’s profile and clicking on the Permission Sets tab.

What is the without sharing keyword in Apex?

The without sharing keyword in Apex ensures that the code is executed with the necessary privileges.

Genetrix Technology · Salesforce Marketing Cloud Partner

Need help shipping this in production?

Genetrix builds and untangles Salesforce Marketing Cloud and Agentforce setups for teams that want it done right the first time. If anything in this post sounds familiar, talk to us before it ships.

Get in Touch with Genetrix →

Blogs for the

Business-Savvy!​

Let’s Connect

A 30 min no cost strategy session
with cloud support expert

Let’s Connect

A 30 min no cost strategy session
with cloud support expert