Skip to main content
AI/MLCrestApps

crestapps-core-response-handlers

Skill for routing chat responses through AI, webhook, relay, and custom handlers in CrestApps.Core.

Stars
13
Source
CrestApps/CrestApps.AgentSkills
Updated
2026-05-29
Slug
CrestApps--CrestApps.AgentSkills--crestapps-core-response-handlers
View on GitHubRaw SKILL.md

// install — copy + paste into any project

mkdir -p .claude/skills && curl -fsSL https://raw.githubusercontent.com/CrestApps/CrestApps.AgentSkills/HEAD/plugins/crestapps-core/skills/crestapps-core-response-handlers/SKILL.md -o .claude/skills/crestapps-core-response-handlers.md

Drops the SKILL.md into .claude/skills/crestapps-core-response-handlers.md. Works with Claude Code, Cursor, and any agent that loads SKILL.md files from .claude/skills/.

CrestApps.Core Response Handlers - Prompt Templates

Implement Response Handlers

You are a CrestApps.Core expert. Generate code and architecture guidance for response handlers in CrestApps.Core.

Guidelines

  • Use response handlers when not every message should go to the default AI path.
  • Implement IChatResponseHandler.
  • Keep handler names unique.
  • Use handlers for AI, webhook, live-agent, and external relay scenarios.
  • Build timeouts and cancellation handling into custom handlers.

Interface

public interface IChatResponseHandler
{
    string Name { get; }

    Task<ChatResponseHandlerResult> HandleAsync(
        ChatResponseHandlerContext context,
        CancellationToken cancellationToken = default);
}

Webhook Handler Example

public sealed class WebhookResponseHandler(IHttpClientFactory httpClientFactory) : IChatResponseHandler
{
    public string Name => "webhook";

    public async Task<ChatResponseHandlerResult> HandleAsync(
        ChatResponseHandlerContext context,
        CancellationToken cancellationToken)
    {
        var client = httpClientFactory.CreateClient();
        var payload = new
        {
            sessionId = context.Session.Id,
            message = context.Messages.Last().Text,
        };

        var response = await client.PostAsJsonAsync("https://example.com/chat", payload, cancellationToken);
        return response.IsSuccessStatusCode
            ? ChatResponseHandlerResult.Handled()
            : ChatResponseHandlerResult.NotHandled();
    }
}

Register a Handler

builder.Services.AddScoped<IChatResponseHandler, WebhookResponseHandler>();