您在此处:
为 移动生成器 准备 Apex 操作
要在 移动生成器 for Agentforce 中配置 Apex 可调用操作,该操作必须满足这些要求。
| 要求 | 原因 |
|---|---|
| 可调用方法返回 Apex 类的列表<>。 | 生成器将响应呈现为轮播,这需要列表。对于单项目响应,返回一个包含一个元素的列表。 |
| 所有输出字段使用简单类型:字符串、整数、布尔值、小数。 | Beta 版不支持嵌套对象和复杂类型。 |
| 输出是平的,没有任何嵌套对象或列表中的列表。 | 生成器仅将顶级字段显示为属性窗格中的可选字段。 |
| 在 @InvocableVariable 输出变量上选择在对话中显示标志。 | 如果没有此标记,操作会显示在生成器中,但无法正确保存。 |
| 输出类型是 Apex 类,而不是通用 SObject。 | 生成器从 Apex 类中读取字段名称和类型。 |
兼容 Apex 操作的示例:
public class FetchRecipes {
@InvocableMethod(label='Fetch Recipes' description='Returns a list of recipes')
public static List<RecipeOutput> execute(List<RecipeInput> inputs) {
// Implementation
}
public class RecipeOutput {
@InvocableVariable(label='Recipe Title')
public String recipe_title;
@InvocableVariable(label='Cook Time')
public Integer cook_time;
@InvocableVariable(label='Image URL')
public String image_url;
}
}部署 Apex 类后,创建指向可调用方法的 Agentforce 客服人员、主题和操作。然后,返回 移动生成器 for Agentforce,配置移动布局。

