How to Use AI in the Workflow Engine
The SETWorks Workflow Engine allows you to use AI to evaluate information in a record and automatically determine what happens next. Using an AI Yes/No Branch, you can analyze documentation, identify specific information, and trigger different actions based on the AI's response.
For example, you can create a workflow that reviews a case note for mentions of an injury and automatically sends a notification when an injury is identified.
This article walks through configuring an AI-powered workflow using the Prompt Utility and Workflow Engine.
Before You BeginAI workflows require three components:
- Prompt Context: Defines which area of SETWorks the AI can access, such as an Activity Instance.
- Prompt: Contains the instructions telling the AI what to evaluate and how to respond.
- Workflow: Determines when the AI evaluation runs and what actions to take based on the result.
Prompts and Prompt Contexts are configured in the Prompt Utility, while the AI evaluation and subsequent actions are configured in the Workflow Engine.
Step 1: Create a Prompt ContextThe Prompt Context establishes which SETWorks entity provides information to the AI.
- Navigate to Settings → Provider Build → Utilities.
- Select Prompt Utility.
- Open the Prompt Contexts tab.
- Create a new Prompt Context.
- Enter a name that describes its purpose, such as
TCM. - Select the appropriate entity, such as
Activity Instance. - Save the Prompt Context.
In this example, the Activity Instance entity allows the AI to evaluate information associated with an Activity Record.
Important: The Prompt Context should correspond to the data your workflow needs to evaluate. Selecting an unrelated entity may prevent the AI from receiving the intended information.
Step 2: Create an AI PromptNext, create the instructions the AI will use to evaluate the record.
- Within Prompt Utility, open the Prompts tab.
- Click Add New Prompt.
- Enter a descriptive name, such as
TCM Injury Check. - Enter the AI instructions in the Prompt Text field.
- Select the appropriate Prompt Type, Response Type, and Action Type.
- Ensure the prompt is Enabled.
- Save the prompt.
Example AI Instructions
For a workflow that identifies whether a TCM note contains the word "injury", enter:
Does the TCM note contain the word "injury"? Matching is case-insensitive. Answer "yes" only if the word "injury" appears in the note text. Answer "no" otherwise. Do not infer an injury from symptoms or related words such as "injuries" or "injured".
For the example configuration, the Prompt Type is Standard and the Prompt Action Type is Summary. Select the response type appropriate for your environment.
Tip: For Yes/No branches, use instructions that clearly define when the AI should return Yes and when it should return No. Avoid open-ended questions or instructions that could produce ambiguous responses.
Step 3: Create a WorkflowOnce the Prompt Context and Prompt are configured, create the workflow that will trigger the AI evaluation.
- Navigate to the Workflow Engine.
- Create a new workflow.
- Enter a workflow name, such as
TCM Injury. - Set the workflow's primary entity or focus to the record type being evaluated. In this example, use
Activity Record/Activity Instance, as appropriate to the available configuration. - Add conditions to limit which records should trigger the workflow.
Example Conditions
To evaluate only TCM notes, configure a condition similar to:
| Setting | Value |
|---|---|
| Entity | Activity Instance |
| Field | Activity |
| Operator | Equal |
| Value | TCM Note |
If your organization has multiple TCM note activity types, additional conditions may be necessary.
Configure the Trigger
Set the workflow event to:
- Event: Data Changed
- Trigger: Created
This is intended to start the workflow when a qualifying TCM Activity Instance is created.
Save the workflow configuration and proceed to the Workflow Builder.
Step 4: Add an AI Yes/No BranchThe AI Yes/No Branch evaluates the record using your prompt and routes the workflow based on the AI's response.
- Open the workflow in the Workflow Builder.
- Locate the Branches section in the right-hand catalog.
- Add an AI Yes/No Branch to the workflow canvas.
- Connect the workflow event to the AI branch.
- Open the AI branch configuration.
Complete the following fields:
| Field | Example |
|---|---|
| Name | Check for Injury |
| Description | Evaluate TCM note for injury |
| Prompt | TCM Injury Check |
| Prompt Context | TCM |
The Prompt identifies the instructions to execute, while the Prompt Context identifies the SETWorks data context available to the AI.
Save the branch configuration.
The branch will have two possible outcomes:
- Yes: The AI determines that the specified condition is met.
- No: The AI determines that the specified condition is not met.
Next, define what should happen after the AI evaluates the record.
For example, you can use the Send Secure Message action to notify a staff member.
Yes Branch — Injury Identified
- Add a Send Secure Message action.
- Connect it to the Yes output of the AI branch.
- Configure the message recipient and content.
- Save the action.
Example message: "An injury was identified in a TCM note. Please review the documentation."
No Branch — No Injury Identified
Optionally, add another action to the No output.
For testing, you might send a message stating: "No injury was identified in the TCM note."
In a production workflow, you may choose to leave the No branch without an action if no follow-up is required.
Step 6: Save and Test the WorkflowBefore relying on the workflow, test it using sample records.
- Save and activate the workflow as appropriate.
- Create a TCM Activity Record containing information that should produce a Yes response.
- Verify that the expected action occurs.
- Repeat with a record that should produce a No response.
- Review the Instances section of the Workflow Engine to inspect workflow execution.
Example Test Cases
| Note text | Expected response |
|---|---|
| "Michael had an injury today." | Yes |
| "Michael attended his scheduled appointment." | No |
| "Michael reported no injury today." | Yes — the word appears |
| "Michael was injured during the activity." | No — different word |
These expected responses apply to the example's exact-word instructions. Other prompts may evaluate the same notes differently.
Important: AI responses should be tested before enabling workflows that generate notifications or other operational actions. Verify that the workflow executes the expected branch and does not generate duplicate actions.
TroubleshootingThe AI Branch does not execute
Verify that the workflow event is configured correctly, the record meets the workflow conditions, and the AI branch is connected to the event.
The AI returns an unexpected Yes or No response
Review the Prompt Text and Prompt Context. Confirm that the AI has access to the intended record information and that the instructions clearly define the expected response.
The workflow sends duplicate or conflicting notifications
Review the workflow's Instances to determine whether the workflow executed multiple times or whether multiple actions were triggered. Also verify that overlapping workflow conditions or multiple qualifying activity types are not causing additional executions.
The desired prompt or context is unavailable
Confirm that the prompt is enabled and that the appropriate Prompt Context has been created. Verify that the selected context is compatible with the workflow's data.
Additional Notes- Prompts and Prompt Contexts are reusable and can support other SETWorks AI functionality beyond the Workflow Engine.
- Changes to a shared prompt may affect multiple workflows or features using that prompt.
- Workflow conditions determine which records qualify for evaluation; AI instructions determine how those records are analyzed.
- AI evaluations should be tested with representative examples before being used in operational workflows.
By combining Prompt Contexts, Prompts, and AI Yes/No Branches, organizations can automate documentation reviews and follow-up actions using information already available in SETWorks.