Appearance
Put AI inside a business workflow
The real problem
When an employee resigns, Northwind's HR manager must read the letter, judge whether the person is a flight risk for the team, and decide on a retention conversation. Today that is manual and slow. Letting an AI "handle it" end to end would be unsafe: HR must approve, and the path must be auditable.
The answer is not a free-running agent. The workflow engine keeps the path (steps, approvals, conditions); each AI step does one bounded thing and returns fields that the workflow's conditions can test. The model suggests; the workflow decides and a human approves.
The AI steps
AI steps are workflow service tasks. In the Workflow Designer they are under Add task > AI.
| Task type | Does | Payload (required in bold) | Returns |
|---|---|---|---|
ai.prompt | Runs a library prompt | code, label (default prod) or version, values, profileCode | text, token counts, version |
ai.classify | Same, but the prompt answers in JSON | as ai.prompt | each JSON field of the answer, plus text |
ai.retrieve | Searches a knowledge base | knowledgeBase, query, mode, topK, threshold | hits, count, context |
ai.rag | Runs a RAG pipeline | pipelineCode, question, label | answer, citations, citationCount |
ai.agent | Runs an agent | agentCode, intent | status, finalResponse, executionId |
ai.guardrail | Checks (and can mask) text | text, checks, blockedTerms, action, maxLength | passed, findings, text |
Any payload value may read an earlier step with ${context.<taskKey>.<field>}. The token must be the whole value: text around it, such as "Notice for ${context.grade}", is not substituted. Task keys and field names use letters, digits and underscores only (no hyphens). A whole-value token keeps its type (a number stays a number). A step that fails stops the workflow with a clear message rather than passing on an empty answer.
Designer path: the resignation flow
- Create a prompt
exit-riskwhose user text isReason given: {{reason}}\nReturn JSON: {"risk":"low|medium|high","summary":"..."}(Prompts). - In the Workflow Designer, add a service task analyse of type
ai.classifyand fill the payload: codeexit-risk, valuesreason= the letter text from the earlier step. - Add a condition after it:
context.analyse.risk == "high". - High risk goes to a human task "Retention conversation" assigned to the HR manager, showing
context.analyse.summary. Low and medium go straight to the normal exit checklist. - Optionally add an
ai.guardrailstep first to mask personal data before the text reaches the model. - Publish and run a test instance. Open the instance and read the
analyseoutput:risk,summary,text.
Developer path
The same step in a workflow file (see Use AI Studio from your plugin):
json
{
"taskKey": "analyse",
"stage": "review",
"kind": "service",
"taskType": "ai.classify",
"payload": {
"code": "exit-risk",
"label": "prod",
"values": { "reason": "${context.get_letter.text}" }
}
}A grounded answer step:
json
{ "taskKey": "policy", "kind": "service", "taskType": "ai.rag",
"payload": { "pipelineCode": "hr-qa", "question": "${context.question}" } }The worker that runs service tasks needs the AI platform address: start it with --aiBaseUrl https://your-erp (the platform adds the tenant and instance itself).
How to verify
- Run an instance with a clearly high-risk letter; the flow reaches the human task with the summary shown.
- Run one with a neutral letter; it skips the human task.
- Break the prompt on purpose (label it to a version that does not answer JSON). The
analysestep fails with the prompt code and reason; nothing downstream runs.
Common mistakes
- Letting the AI decide the route with free text. Have it answer in JSON fields and test those fields in a condition.
- No human step for a consequential outcome. Keep approvals for anything that affects a person.
- Passing the whole record to the model. Pass only the field it needs; mask personal data with
ai.guardrail. - Calling a version number. Use a label so you can fix the prompt without editing the workflow.
Not built
Workflow templates that come pre-wired with AI steps.
Next
Evaluations and guardrails - trust the AI step before you release it.
