Generic Activity To Run Any Rule and Give back the results

My use case is:

I want to send JSON metadata for a Pega rule to a Service REST endpoint. The REST service should first map the incoming JSON fields to clipboard properties in Pega. After that, it should trigger an activity.

Inside that activity, I want to dynamically run or load the rule mentioned in the JSON, using the parameters provided in the request. Once the rule is executed, the activity should collect the output/result from the clipboard and return it back to the external application as the REST response.

The goal is to create a generic preview/introspection service that can work for different rule types, such as:

  • Data Pages
  • List Data Pages
  • Data Transforms
  • When rules

Expected flow:

  1. External application sends JSON to Pega REST service.
  2. Pega maps the request JSON to a request clipboard page.
  3. Pega activity reads ruleName, ruleType, className, and parameters.
  4. Activity runs or loads the rule based on its type.
  5. Activity captures the result/output properties.
  6. Activity builds a response clipboard page.
  7. REST service returns that response as JSON to the external application.

Can someone guide me on how to design this generic activity? Specifically:

  • Which activity methods should be used to run/load each type of rule?
  • How can I dynamically call a Data Page, Data Transform, or When rule based on values received

For the activity methods to run any type of rule:
See what you can reuse from pyRunRecordExecute. There are specializations for numerous rule types, but with your use case you would only use some lines that are currently done with a Java step. You would be able to trace this by manually running a rule.

This is not recommended design pattern to expose all the rulename, ruletype, class name to the external application to execute the rules in Pega and provide the output.

Leverage the Pega DX APIs which are more generic to pull any specific information from cases/data types or you can build Service REST to do specific needs.

But like what i need is to pass the results i got from running the rule (which gets triggered when my external application asks for it) to the external application so that it knows about the particular rule

It sounds like your trying to test the Pega platform remotely? Or maybe an agentic use case where you’re trying to pseudo run a process/case/logic?

If its the latter, the new '26 MCP capabilities might be of interest?