Skip to main content
Version: Latest

AI Chat with Workflows

When combined with the Workflows feature, the AI Services module introduces new activities that allow workflows to interact directly with AI chat services.

AI Completion using Profile Task

This activity lets you request AI completions using an existing AI Profile, and store the response in a workflow property. To use it, search for the AI Completion using Profile task in your workflow and specify a unique Result Property Name. The generated response will be saved in this property.

For example, if the Result Property Name is AI-CrestApps-Step1, you can access the response later using:

{{ Workflow.Output["AI-CrestApps-Step1"].Content }}

To prevent naming conflicts with other workflow tasks, it's recommended to prefix your Result Property Name with AI-.

The screencast below enables the Workflows feature, creates a workflow, adds the AI Completion using Profile task, and binds it to the Demo Assistant profile with the result property AI-CrestApps-Step1.

AI Completion using Direct Config Task

This activity allows you to request AI completions by defining the configuration directly within the workflow, without relying on a predefined AI Profile. To use it, search for the AI Completion using Direct Config task in your workflow and specify a unique Result Property Name. The generated response will be saved in this property.

This task exposes the same parameters available in the Chat Interactions experience, and its editor is organized into the same tabs. Each enabled feature contributes its own fields through dedicated display drivers, so the options you see depend on which features are turned on:

  • Content — result property name, prompt template, orchestrator, chat deployment, utility deployment, system instructions, prompt template selectors, max response tokens, temperature, top P, frequency penalty, and presence penalty.
  • Knowledge — data source, restrict answers to retrieved data only, strictness, retrieved documents, and the OData filter (contributed by the AI Data Sources feature); document retrieval mode and uploaded knowledgebase files (contributed by the AI Documents feature).
  • Capabilities — tools, tool instances (contributed by the AI Tool Instances feature), MCP connections (contributed by the AI MCP feature), and A2A connections (contributed by the AI A2A feature).
note

This task requires the AI Chat Interactions feature (CrestApps.OrchardCore.AI.Chat.Interactions) to be enabled, because it reuses the same configuration model and completion flow used by Chat Interactions.

When the AI Documents feature is enabled, the Knowledge tab also lets you upload text-based documents that act as a knowledgebase for the activity. Uploaded files are chunked, embedded, and indexed against the configured document index profile, keyed by the activity's embedded interaction identifier, so their content is retrieved to provide context whenever the activity invokes the model.

For example, if the Result Property Name is AI-CrestApps-Step1, you can access the response later using:

{{ Workflow.Output["AI-CrestApps-Step1"].Content }}

As with other AI tasks, it's recommended to prefix your Result Property Name with AI- to avoid conflicts.

Chat Session Workflow Events

The AI Services module triggers workflow events at key points in the chat session lifecycle. These events include full Session and Profile objects in their input dictionaries, enabling rich workflow automation.

AI Chat Session Closed

Triggered when a chat session is closed (either naturally or by inactivity timeout).

Input PropertyTypeDescription
SessionIdstringThe unique session identifier.
ProfileIdstringThe AI profile identifier.
SessionAIChatSessionThe full session object with extracted data and metadata.
ProfileAIProfileThe full AI profile configuration.
ClosedBecauseFarewellDetectedboolWhether the session closed due to farewell intent detection.

AI Chat Session Post-Processed

Triggered after post-session processing completes on a closed session.

Input PropertyTypeDescription
SessionIdstringThe unique session identifier.
ProfileIdstringThe AI profile identifier.
SessionAIChatSessionThe full session object.
ProfileAIProfileThe full AI profile configuration.
ResultsDictionaryPost-session processing results keyed by task name.

AI Chat Session Field Extracted

Triggered each time a data extraction field value is collected from the conversation.

Input PropertyTypeDescription
SessionIdstringThe unique session identifier.
ProfileIdstringThe AI profile identifier.
SessionAIChatSessionThe full session object.
ProfileAIProfileThe full AI profile configuration.
ChangesList<ExtractedFieldChange>The field changes extracted in this turn.

Each ExtractedFieldChange has:

  • Key: The field name.
  • Value: The extracted value.
  • PreviousValue: The previous value (if updated).

AI Chat Session All Fields Extracted

Triggered once when all configured data extraction fields have been collected for a session. Unlike the per-field event, this fires only when every entry in the profile's data extraction configuration has at least one value.

Input PropertyTypeDescription
SessionIdstringThe unique session identifier.
ProfileIdstringThe AI profile identifier.
SessionAIChatSessionThe full session object.
ProfileAIProfileThe full AI profile configuration.