Orchardcore ai workflows

From CrestApps/CrestApps.AgentSkills · View interactive version

Orchardcore ai workflows is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for using CrestApps AI Services in Orchard Core Workflows. Covers the AI Completion using Profile task (AICompletionFromProfileTask) and the AI Completion using Direct Config task (AICompletionWithConfigTask, which needs CrestApps.OrchardCore.AI.Chat.Interactions), the fields other AI features

How to use this skill

Skill file

Orchard Core AI Workflows

With OrchardCore.Workflows enabled, CrestApps AI Services adds two completion tasks and four chat session events.

Guidelines

Enable

{
  "steps": [
    {
      "name": "Feature",
      "enable": [
        "CrestApps.OrchardCore.AI",
        "CrestApps.OrchardCore.AI.Chat",
        "CrestApps.OrchardCore.AI.Chat.Interactions",
        "OrchardCore.Workflows"
      ],
      "disable": []
    }
  ]
}

Drop CrestApps.OrchardCore.AI.Chat.Interactions if you only use the profile task, and CrestApps.OrchardCore.AI.Chat if you do not react to chat sessions.

AI Completion using Profile

  1. Create an AI profile with a chat deployment and the capabilities the workflow needs.
  2. Add AI Completion using Profile, select the profile, write a Liquid Prompt template, and set a Result Property Name such as AI-order-summary.
  3. Wire all three outcomes.

The template is rendered with the selected profile available as Profile. The task builds the completion context from the profile, resolves the chat deployment through the chat slot (IAIDeploymentManager.ResolveSlotAsync(AIDeploymentSlotNames.Chat, ...)), and sends the prompt as a user message.

Summarize this order for the support team.
Order number: {{ Workflow.Input.OrderNumber }}
Customer note: {{ Workflow.Input.CustomerNote }}
{{ Workflow.Output["AI-order-summary"].Content }}

| Outcome | When |

|---|---|

| Failed | Unknown profile, empty rendered prompt, no resolvable chat deployment, or an exception |

| Drew Blank | The model returned no text |

| Done | A reply was stored |

AI Completion using Direct Config

The task owns its configuration. It stores it as an embedded ChatInteraction (the task's Interaction property), builds the completion context with IAICompletionContextBuilder, and resolves the interaction's chat deployment through the chat slot. The editor uses the chat interaction tabs, and each enabled feature contributes its own fields:

| Tab | Fields | Contributed by |

|---|---|---|

| Content | Result property name, prompt template, orchestrator, chat and utility deployments, system instructions, max tokens, temperature, top P, penalties | AI Services |

| Content | Prompt template selection | CrestApps.OrchardCore.AI.Prompting |

| Content | Persona | CrestApps.OrchardCore.AI.Personas |

| Knowledge | Data source, restrict to retrieved data, strictness, retrieved documents, OData filter. A blank strictness or retrieved documents uses the Default strictness / Default top documents of the Data Sources settings card (built-in default 5 documents) | CrestApps.OrchardCore.AI.DataSources |

| Knowledge | Document retrieval mode and uploaded knowledge files | CrestApps.OrchardCore.AI.Documents module |

| Capabilities | Tools | AI Services |

| Capabilities | Tool instances | CrestApps.OrchardCore.AI.ToolInstances |

| Capabilities | MCP connections | CrestApps.OrchardCore.AI.Mcp |

| Capabilities | A2A connections | CrestApps.OrchardCore.AI.A2A |

The deployment pickers list deployments by model capability (see orchardcore-ai-model-capabilities), not by the removed deployment purpose. Uploaded documents are chunked and indexed against the activity's embedded interaction, so they are retrieved whenever the task runs.

| Outcome | When |

|---|---|

| Failed | Empty rendered prompt, no chat deployment with a valid connection, or an exception |

| Drew Blank | The model returned no text |

| Done | A reply was stored |

A workflow that runs in the background (timer, deferred task) has no caller, so tool access checks are skipped. One triggered inside a user's request runs as that user, and a direct-config task can then drop tools that user may not access. Select only the tools the workflow genuinely needs.

Usage metering

Both tasks run inside an AIUsageScope with the Workflow category, so their tokens appear under that category in AI Usage Analytics (orchardcore-ai-usage-analytics).

Chat session events

All events use the chat session ID as the workflow correlation ID and accept an optional Profile filter (ProfileId). Every event input contains SessionId, ProfileId, Session (AIChatSession), Profile (AIProfile). Field Extracted, Closed and Post-Processed also carry the conversation Variables; Closed and Post-Processed also carry Transcript (one Customer: or Assistant: line per turn) and Turns (AIConversationTurn records). An extracted field is also stored as a conversation variable.

| Event | Triggers | Extra input |

|---|---|---|

| AI Chat Session Field Extracted (AIChatSessionFieldExtractedEvent) | Each newly extracted data field | FieldName, Value, IsMultiple, Timestamp |

| AI Chat Session All Fields Extracted (AIChatSessionAllFieldsExtractedEvent) | Once every configured extraction field has a value | ExtractedData, Timestamp |

| AI Chat Session Closed (AIChatSessionClosedEvent) | A session closes during extraction processing or by the inactivity close task | ClosedAtUtc |

| AI Chat Session Post-Processed (AIChatSessionPostProcessedEvent) | Post-session tasks complete for the first time | Results |

DataExtractionChatSessionHandler raises the extraction and closed events; PostSessionProcessingChatSessionHandler raises the post-processed event only when the tasks completed in that run, so it is not delivered twice. The background AIChatSessionCloseBackgroundTask raises the closed event for inactive sessions.

Field-extraction workflow

  1. Configure data extraction on a chat profile (orchardcore-ai-chat).
  2. Start a workflow with AI Chat Session Field Extracted and optionally select the profile.
  3. Use {{ Workflow.Input.FieldName }} and {{ Workflow.Input.Value }} in later activities.
  4. Make the workflow idempotent; several fields can fire separate executions for one session.

Post-session workflow

  1. Configure post-session processing on the profile.
  2. Start a workflow with AI Chat Session Post-Processed.
  3. Read Workflow.Input.Results and route or store them.

AI Conversations activities

With OrchardCore.Workflows and AI Services enabled, the AI Conversations category adds activities for

website chats, text threads and AI phone calls. Their input is AIConversationWorkflowInput (Channel,

Direction, SessionId, ProfileId, ActivityId, ContactId, ContactName, Contact, CustomerAddress,

BusinessAddress, Variables, Simulation).

| Activity | Kind | Outcomes |

|---|---|---|

| AI Conversation Starting | Event, before the first message (3 s budget inbound, 30 s outbound) | Done |

| AI Conversation Turn | Event, after each saved turn (Text, Role) | Done |

| AI Tool Called | Event, run by a Workflow tool instance (Arguments, ToolName) | Done |

| AI Conversation Flow Started / AI Conversation Stage | Event / task, a staged conversation flow with a moveToStage tool | one outcome per way out, Not in a conversation |

| Set Conversation Variables | Task, name: value per line | Done, No conversation |

| Use AI Profile | Task, answer with another profile or a profile version | Done, Not starting |

| Decline Conversation | Task, cancel or refuse (not a web chat) | Done, Not starting |

| Evaluate AI Conversation | Task | Passed, Failed, Not evaluated |

| Simulate AI Conversation | Task | Passed, Failed, Error |

| Rerun AI Conversation Analysis | Task | Done, Nothing to analyze, Not found |

| Split Traffic | Task, weighted outcomes with a sticky key | your outcomes |

| Check AI Conversation Metric | Task | Alert started, Still alerting, Resolved, Normal |

| Update Contact Memory | Task | Updated, Nothing to remember |

| AI Conversation Evaluated, AI Guardrail Triggered, AI Alert Triggered, AI Alert Resolved | Events | Done |

| Send Signed Webhook (category HTTP) | Task, HMAC-signed POST with retries | Delivered, Failed |

The activities that read or change a chat session (Set Conversation Variables, AI Conversation Flow Started,

AI Conversation Stage, Evaluate AI Conversation, Simulate AI Conversation, Rerun AI Conversation Analysis and

Update Contact Memory) are registered only when AI Chat Services (CrestApps.OrchardCore.AI.Chat.Core, brought by

AI Chat or AI Chat Interactions) is enabled too. Without it the workflow editor does not list them, and the other AI

activities stay available.

The Contact Center adds AI Call Action and Transfer AI Call, and Omnichannel Management adds **Create

AI Activity**. Behaviour, services and recipes are in orchardcore-ai-conversations.

Upgrading from 2.x

Troubleshooting

| Symptom | Check |

|---|---|

| Direct-config task missing from the activity picker | Enable CrestApps.OrchardCore.AI.Chat.Interactions. |

| Task ends on Failed at once | The prompt rendered empty, the profile was deleted, or no chat deployment has a connection. Check the log. |

| Task ends on Drew Blank | The model replied with no text; check the deployment and the prompt. |

| Conversation variable, flow, evaluation, simulation or contact memory activities missing | Enable a chat feature (AI Chat or AI Chat Interactions) so AI Chat Services is on. |

| Chat events never fire | No chat feature is enabled, data extraction or post-processing is not configured, or the profile filter does not match. |

| Output is empty in a later activity | The result property name differs, or the read omits .Content. |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.