You are not looking at the latest version of the documentation. Check it out there.
You are looking at draft pre-release documentation for the next release of Flows for APEX. Product features documented here may not be released or may have different behavior to that documented here. You should not make any purchase decisions based on this draft documentation..

Configure an AI Service Task

The Flows for APEX AI Service Task allows you to call Generative AI Services as a workflow step.

Pre-Requisites

The AI Service Task is implemented using APEX AI infrastructure, so you need to define an AI Service in APEX. See APEX documentation.

Future versions may allow direct AI connection.

Configuration of AI Service Task in BPMN Diagram

Add a Service Task into your BPMN diagram by adding a task ( the symbol). Then, using the spanner tool , convert the task to a Service Task ( ).

Name. On the Modeler properties panel, in the General section , give your task a descriptive name.

ID. By default, this generates a random name like โ€˜โ€˜Activity_0d5gtyhโ€. You can change this to something more descriptive, but it should be short and not contain any spaces.

Task Type. Select APEX AI Generation and open the APEX Human Task section.

Screenshot 2025-08-05 at 14.43.00

APEX AI Generation

All three of the AI settings can accept a value as:

  • static value - enter the value n the Expression item.
  • a process variable - enter the variable name in the Expression item.
  • a SQL query returning the value - enter the SQL query in the Expression item.
  • a PL/SQL expression returning the value - enter the PL/SQL expression in the Expression item.
  • a PL/SQL function body returning the value - enter the PL/SQL expression in the Expression item.

Required settings are:

APEX AI Service. This should contain the APEX static ID of your AI service, previously created in APEX Workspace Utilities. (App Builderย ยป Workspace Utilitiesย ยป Generative AI Services).

AI Temperature. AI temperature controls randomness in responses: lower values mean more predictable output; higher values increase creativity and variation.

  • 0.0: Most deterministic (almost identical output every time)
  • ~0.5: Balanced โ€“ good for general-purpose writing or code
  • 0.7+: More creative, poetic, less predictable
  • >1.0 (where supported): Risk of incoherence or hallucinations increases
Model Temperature Range Notes on Behavior
GPT (OpenAI) 0.0 โ€“ 2.0 0.7 is common default; >1.0 adds significant randomness
LLaMA / Meta 0.0 โ€“ 1.0 (typical) Similar behavior; 0.7 often used for balanced output
Cohere 0.0 โ€“ 1.0 Docs recommend 0.3โ€“0.9; 0.5 for general use
Claude (Anthropic) 0.0 โ€“ 1.0 0.7 is default; lower for stability, higher for creativity
Mistral / Mixtral 0.0 โ€“ 1.0 Follows same convention; may appear slightly more โ€œcreativeโ€ per temp
Google Gemini (former Bard) 0.0 โ€“ 1.0 Internally tuned but follows similar temp behavior when exposed

AI Prompt: This variable should contain your complete prompt to be submitted to the AI service. Typically you will assemble this from several components, including one or more of the following:

  • System prompt - telling the LLM what it should be doing and establishing any required guardrails.
  • RAG Content - relevant data from the database that you need to give the LLM to perform its task.
  • Process Data - data about the process subject, etc.

Typically you can assemble these into a prompt in either a BEFORE TASK variable expression defined in this step, or in the step using a defined type of PL/SQL Expression or function body.

Result Variable The LLM results will be returned into the process variable named here. Your system prompt could include instructions to the LLM to return the output in a specific format, for example, as a colon-separated list of values, as free text, or as a JSON document with some pre-defined format. (e.g., โ€œRespond only with a valid JSON object.โ€).

Use Cases for AI Service Task

In some applications, you can use GenAI to recommend a course of action in your process. This can then be combined with a BPMN Gateway to direct process flow. This could be used to create some level of Agentic AI application.

For example, we have a scenario where we are going to pass information about a taxpayer to an AI agent, who has been instructed in their system prompt that they are an expert on determining taxpayer fraud. The complete prompt includes instructions plus taxpayer info, and the response is requested as a list of recommended next actions in a format that we can use to drive an Inclusive Gateway.

Hereโ€™s the BPMN model (simplified for the example).

Screenshot 2025-08-05 at 16.02.16

The AI prompt being used is:

You are an expert in assessing whether a taxpayer is correctly declaring their income and expenses, and in detecting potential tax evaders or tax frauds. Using the taxpayer information below, respond with JSON using one or more of the following labels, separated by colons in field result:

- ok (no suspicion)
- email (request more information)
- human (flag for human review)
- fraud (confirmed fraud based on inconsistencies)

And add an additional field called rationale into the JSON with the reason for the labels. Only return the plain JSON object without any extra decoration.
here is an example of the return:
{ "result": "human:email", "rationale": "The expenses seem to outweigh the declared income." }
Here is a taxpayer info:  
{
 "name" : "John Doe", 
  "age": 33,
  "occupation": "Consultant",
  "annual_salary": 90000,
  "declared_income": 25000,
  "major_purchases": ["Luxury SUV", "Vacation home"]
}

The AI Service Task returns a JSON into a process variable OUTCOME

{ 
  "result": "human:email", 
  "rationale": "Declared income is significantly lower than the occupation's typical salary and major purchases suggest higher income." 
}

Our result is then used to control the Inclusive gateway, choosing paths HUMAN and EMAIL

For a task like this, we will set the temperature to a low value - try 0 or close to that.

Generate Document

An AI Service Task combined can be used to generate a document. Combining this with a Send Mail Service task, we could then send this document to its recipient, or route it first for checking and approval, and then sending by email.

Letโ€™s use our taxpayer example from above, and look at the EMAIL course of action. In this case we can make another call to the GenAI service, giving it instructions that it is a tax agent requesting additional information from a taxpayer, asking it to generate an email requesting more info, and providing it with the taxpayer information, and the rationale for suspecting the tax return might be inaccurate.

You are part of a fraud detection workflow. Earlier we have you information about a taxpaper which was: 

Here is a taxpayer info: { "name" : "John Doe", "age": 33, "occupation": "Consultant", "annual_salary": 90000, "declared_income": 25000, "major_purchases": ["Luxury SUV", "Vacation home"] } 

Your rationale for requiring more information is the rationale item in below data: 
  {"result": "human:email", 
  "rationale": "Declared income is significantly lower than the occupation's typical salary and major purchases suggest higher income." }
  
Please generate a detailed email to this taxpayer asking for clarification about his situation, asking for details of items that you think are suspicious. Return the email text.

This time we will use a temperature value that is a little higher - say 0.5.

Our response is:

Subject: Request for Clarification Regarding Your Tax Filing 

Dear Mr. Doe, 

I hope this email finds you well. As part of our routine review process, we are conducting an assessment of the tax declarations and financial activities of various taxpayers. We have reviewed your recent tax filing and would like to seek some clarification regarding certain aspects of your declared financial information.

While we appreciate your timely submission, there are a few items that require additional information to ensure everything is accurately represented and compliant with current tax regulations. These items mainly pertain to the significant difference observed between your annual salary and your declared income, as well as certain major purchases.

1. **Declared Income vs. Annual Salary:**
  - You have declared an income of $25,000, whereas your occupation and reported annual salary as a Consultant is listed as $90,000. Kindly provide clarification on this discrepancy. It would be helpful if you could furnish supporting documents or an explanation for any deductions, non-taxable income, or other relevant factors that may have contributed to this difference.

2. **Major Purchases:**
  - It has come to our attention that you have made substantial purchases, including a Luxury SUV and a Vacation Home. Given the disparity between your declared income and these significant purchases, we require documentation or an explanation on how these were financed. This may include loan agreements, savings or investment withdrawals, or any other pertinent records.

3. **Additional Income Sources:**
  - If there are any additional sources of income or financial support that have not been previously declared, please provide details and relevant documentation for these. This will help us gain a clearer understanding of your financial situation and ensure accurate records.

We understand that these matters can be complex, and we are here to assist you through this process. Please provide the requested information by [insert deadline, e.g., two weeks from the date of this email] to prevent any further action or delay in processing your file.

Your cooperation is greatly appreciated. Should you have any questions or require further assistance, please feel free to contact our office at [insert contact information]. We are more than happy to help clarify our requests or assist in gathering the required information.

Thank you for your attention to this matter and your prompt response.

Warm regards,

[Your Full Name]  
[Your Position]  
[Your Company's Name]  
[Contact Information]