Call GenAI Connect rule in case workflow

This knowledge sharing article demonstrates how to call GenAI Connect rule from a case workflow and use it as an AI agent to quickly research needed information and summarize the findings in a structured format for user review.

Pega Infinity version used: 25.1.2

= = =

Runtime results

Let’s first look at the runtime results before getting into the configurations.

We have a FSC- case type (Find Sports Champion) that uses a GenAI model to quickly research the champion details in a given sports (entered by user).

Step 1 - Launch the Find Sports Champion case type.

Enter the Which sports? and From year fields.

Click Submit.

Step 2 – Calling a GenAI Connect rule and waiting for the response.

Step 3 – Display the GenAI response in a structured list

The following table shows a list of FIFA World Cup Soccer champions since year 2000 (prompted by user).

Note: GenAI Connect rule was smart enough to get the additional details such as venue, head coach, Most Valuable Player (MVP), and the team strengths and map to the table even though those information were not explicitly requested in the prompt. The following configurations will show how this happened in the GenAI Connect rule.

Prompted for another example - NFL champions since 2020.

Configurations

Step 1 – Create a GenAI Connect rule.

We’re using a structured list for Response.

Here is the Champion data object used to define the .ChampionList field referenced in the GenAI Connect rule > Response.

Note: One key observation is that the GenAI Connect rule was smart enough to retrieve additional information about each champion based on the Champion fields mapped in the Response section (even though those details were not included in the prompt).

The user prompt is configured in a Field Value rule.

There are two parameters: .WhichSports and .FromYear (entered by user)

Research and provide a list of all-time sports champions in {.WhichSports} since year {.FromYear}.  Save this prompt. 

Under the Advanced tab, we selected Gemini-Pro as our GenAI model.

There are additional GenAI models available if needed.

Step 2 – Create a view to capture the prompt details from user.

Step 3 – Reference the GenAI Connect rule in the case workflow.

Step 4 – Save the GenAI prompt text.

In this example, we’re prompting GenAI to save the prompt text in the .ChampionList() response field.

Step 5 – Configure a view to display the GenAI response.

Display the ChampionList in a Table layout.

Runtime view:

Additional notes

  • This was my first-time implementing GenAI Connect rule in Pega Infinity, and the experience was seamless.
  • Had to enable GenAI feature in my Pega Lab instance.
  • Refer to this article if you want to learn about how Pega GenAI Agent can perform actual tangible tasks during a case workflow.
  • Will provide additional information as I gain more experiences on Pega GenAI capabilities in coming months.
4 Likes

Nice walkthrough @Will_Cho !

In your setup, you rely on the LLM to provide the facts on the sports teams. While this of course is possible as you demonstrated, I wanted to add that in most enterprise settings we would typically not want to rely on the ‘knowledge’ of the LLM itself, because they have been pre-trained, and so their knowledge has a cut-off point (For Gemini 2.5 Pro I believe this was January 2025)

So in a use case like this, we would typically either

  • Provide the Connect GenAI prompt with current data from the case Data Model that needs to be used in the response
  • Use a Knowledge Buddy to retrieve correct and current information from a content store that is in our enterprise domain
  • Or, use an Agent with a Tool that allows it to query the internet or external sources (e.g. a tool that lets the Agent retrieve live data from Wikipedia)
2 Likes

When using GenAI Connect to read documents (DocAI) the convention to populate a page list property is a little strange. It is very difficult to do in AppStudio. But if you are configuring the connect rule in DevStudio the convention is this:

  • Select Structured Single
  • Configure the Page List properties like this
    • .PageListName().propertyName

The LLM should find the properties in it’s processing results and popultate a PageListName page for each set of properties. It is possible that the same configuration will work in your case.

2 Likes

I agree with you @Tim_Straatsma somewhat but have a slightly different take on this.

I believe every knowledge repository used by an AI system needs to be updated regularly; otherwise, it may generate outdated or inaccurate responses. Organizational policies may not change frequently, but whenever they do, the knowledge base should be updated accordingly. Similarly, if an underlying API changes, the corresponding tool definitions or integration schemas should also be updated to ensure the AI interacts with the system correctly.

Questions from my colleage:

Is this prompt working for all the models listed in GenAI connector?

I think No. Depending on the model, I receive error like

Gateway LLM Resource Not Found

Will it consume tokens in each query?

I think Yes. Depending on the usage, I receive error like below (since i’m using Pega Lab where there is a daily GenAI usage limit). On the other hand, clients will not experience this on real systems.

Gateway Authentication Error: DAILY_QUOTA_EXCEEDED

Please feel free for others to chime in.

Hi @Will_Cho, nice setup, well done!!!

I don’t think this is a prompt issue. If this is happening in a Pega GenAI Connect rule and only with some models, “Gateway LLM Resource Not Found” sounds more like the gateway can’t resolve that model/resource in that environment. I’d look at model mapping, provisioning, region,gateway service config or temporary model integration rather than the prompt itself.

2 Likes

@Will_Cho Thanks for the details. This is very useful. If we were to debug the GenAI connect rule, are there better/alternatives apart from tracing the standalone rule and checking the request and response details from the Tracer? I dont see the request and response getting logged in PegaRules when I set the log level of RESTConnector to debug.

1 Like

@anandchouti hi Anand, hope you are doing well. I tried a couple of GenAI loggers but they didn’t print out the actual content of GenAI request/response. They only logged the GenAI activity steps with DEBUG.

I can see the Request/Response details in Tracer but not in the log. As a temporary work around, you could Log-Message (InfoForded) the page that contains the GenAI Request/Response.

In my example, i stored the GenAI request here:

And the GenAI response here:

1 Like

@Tim_Straatsma is there any DEBUG logger that can print out the actual content of the GenAI prompt text and reponse to PegaRULES log? Please see @anandchouti’s question. I offered a workaround but that requires a development (and deployment). It will be nice if we have GenAI loggers that clients can control using Admin Studio without any code development/deployment.