Routes CrestApps.Core 2.0 chat messages through IChatResponseHandler implementations instead of always calling the AI. Covers built-in AI handler, streaming/deferred results, custom webhook or live-agent handlers, and handler selection by session or chat mode.
Ships in crestapps-core. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Implement IChatResponseHandler when a message should not always use the default AI orchestration path. A handler returns either ChatResponseHandlerResult.Streaming(...) with an IAsyncEnumerable<ChatResponseUpdate> or ChatResponseHandlerResult.Deferred() when a later callback, background task, or relay will deliver the response.
ChatResponseHandlerContext exposes Prompt, ConnectionId, SessionId, ChatType, ConversationHistory, Services, Profile, ChatSession, Interaction, AssistantAppearance, and Properties, plus the AG-UI members ClientContext, SharedState, SupportsToolApproval, ClientTools and ContinuesOnNextPage (see crestapps-core-ag-ui), which AIChatResponseHandler copies into AICompletionContextKeys entries. Profile and ChatSession are populated only for AIChatSession; Interaction is populated only for ChatInteraction.
using System.Net.Http.Json;
using CrestApps.Core.AI.ResponseHandling;
public sealed class WebhookResponseHandler(IHttpClientFactory httpClientFactory) : IChatResponseHandler
{
public string Name => "webhook";
public async Task<ChatResponseHandlerResult> HandleAsync(
ChatResponseHandlerContext context,
CancellationToken cancellationToken = default)
{
var client = httpClientFactory.CreateClient();
var response = await client.PostAsJsonAsync(
"https://example.com/chat",
new
{
context.SessionId,
context.ConnectionId,
context.ChatType,
prompt = context.Prompt,
},
cancellationToken);
response.EnsureSuccessStatusCode();
return ChatResponseHandlerResult.Deferred();
}
}
Register the handler as scoped:
builder.Services.AddScoped<IChatResponseHandler, WebhookResponseHandler>();
IChatResponseHandlerResolver.Resolve(handlerName, chatMode) selects by AIChatSession.ResponseHandlerName or ChatInteraction.ResponseHandlerName; GetAll() lists every registered handler. For a profile-created session, set ResponseHandlerProfileSettings.InitialResponseHandlerName (profile templates carry it as ProfileTemplateMetadata.InitialResponseHandlerName); the active session can change its handler name later. An empty or unknown name falls back to the built-in handler named ChatResponseHandlerNames.AI with a warning. ChatMode.Conversation always uses the AI handler, even when a custom name is requested, because voice conversations need the orchestration pipeline.
profile.WithSettings(new ResponseHandlerProfileSettings
{
InitialResponseHandlerName = "webhook",
});
AIChatResponseHandler builds the orchestration context for the profile or interaction and streams the orchestrator's output. It stores the chat interaction, the chat session and the AIChatSession item in AIInvocationScope.Current before building the context, so context handlers and IAIProfileProviders can read the active chat, and adds the completion context and data source afterwards. A custom handler that runs the orchestrator itself should do the same with AIInvocationScope.Begin().
Use a unique, stable handler name and make deferred handlers responsible for their own eventual delivery. Do not return a made-up handled result: the supported result factories are Streaming(...) and Deferred().
orchardcore-ai-response-handlers for the Orchard Core module wrapper (admin-configured chat sessions and chat interactions) built on this same IChatResponseHandler contract.crestapps-core-external-relays for the IExternalChatRelay contract used by deferred, relay-backed handlers.ChatMode.Realtime is gone. Resolve takes a ChatMode, and only Conversation forces the AI handler.ChatResponseHandlerResult.Streaming(...) and Deferred(); there is no Handled, Transferred or NotHandled result, whatever older docs show.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
chat-routing, response-handlers, webhook, live-agent, crestapps-core
/crestapps-core:crestapps-core-response-handlersfrom crestapps-core
npx claudepluginhub crestapps/crestapps.agentskills --plugin crestapps-core51 skills in this plugin
/crestapps-core-a2aSkill for Agent-to-Agent (A2A) protocol support in CrestApps.Core on the A2A 1.0 SDK. Covers AddA2AClient and AddCoreAIA2AClient with Entity Framework Core or YesSql connection stores, A2AConnection and A2AConnectionMetadata authentication, AIProfileA2AMetadata, the agent card cache and A2AToolRegistryProvider, the listAvailableAgents, findAgentForTask and findToolsForTask tools, building an A2A host with IAgentHandler, A2AServer, ITaskStore and MapA2A, A2A 1.0 agent cards with supportedInterfaces published at /.well-known/agent-card.json, A2AHostOptions authentication and ExposeAgentsAsSkill, system agents exposed through the host, and upgrading from the 0.3 SDK./crestapps-core-ag-uiSkill for running the CrestApps.Core 2.0 AI chat as an AG-UI agent. Covers the CrestApps.Core.AI.AGUI package (AGUIRunEventWriter, AGUIRunRequest, AGUIJson), AIChatHubCore.RunAgent over SignalR and MapAGUIChat with Server-Sent Events, the RunAgentInput members and streamed events, tool approvals with RequireApproval or an approval tool kind, ApprovalRequiredAIFunction, interrupts and resume, approvals inside agents, page context with crestAppsAGUI.registerContextProvider, shared state with registerStateProvider and update_shared_state, frontend tools, stored tool calls (ChatTurnToolActivity), runs that continue on the next page, AGUIChatOptions.DisconnectedRunTimeout, the protocol and sendPageContext chat options, and the AICompletionContextKeys and ChatResponseHandlerContext members. Use it when showing tool calls in the chat, asking a person before a tool runs, sharing page state with the agent, connecting CopilotKit or another AG-UI client, or troubleshooting approvals and continued runs.Other plugins' skills for the same job