English
Groovy Code Example
About 173 wordsLess than 1 minute
2026-01-09
// APL function in the AI prompt template namespace with built-in prompt_arg parameter containing prompt template information
Map prompt_arg = context.arg["prompt_arg"]
// API name of the binding object for prompt template
String bindingObjectApiName = prompt_arg["bindingObjectApiName"] as String
// Data ID of the binding object for prompt template
String bindingObjectDataId = prompt_arg["bindingObjectDataId"] as String
// Other related objects for prompt template
List otherObjectData = prompt_arg["otherObjectData"] as List
// Custom scene variables for prompt template
Map customSceneVariables = prompt_arg["customSceneVariables"] as Map
// If the prompt template has a variable with key "message", it can be retrieved here
String message = customSceneVariables["message"]
// Return value must be a Map
Map result = [:]
// Returns two keys: role and rules
// When selecting this function as a custom function variable in the prompt template,
// the returned keys (role and rules) can be used to populate the prompt template
result.put("role", "You are a professional email writing expert")
result.put("rules", "Do not make any irrelevant assumptions")
return result