Skip to content

Create CommsCrew agent team for communication classification and response #334

@JustAGhosT

Description

@JustAGhosT

Problem

The system has robust outbound notification infrastructure (SendGrid email, Slack webhooks, Teams Adaptive Cards, generic webhooks) but no inbound communication processing. Inbound emails, Slack messages, and social mentions need to be classified, routed to the right handler, and responded to — either automatically for routine queries or with a draft for human review.

Architecture

Agent Team built on AgentTeamEngineBase. Five agents in a sequential pipeline:

Agent Type Role
MessageClassifier Analyst Classifies inbound messages: support request, feature request, bug report, partnership inquiry, spam, internal
SentimentAnalyzer Analyst Assesses tone/urgency/sentiment, flags escalation-worthy messages
ContextGatherer Researcher Pulls relevant context from knowledge graph, previous conversations, issue backlog
ResponseDrafter Writer Drafts a response appropriate to the classification, with the gathered context
RoutingDecider Planner Decides: auto-send (routine), send-with-approval (non-trivial), escalate-to-human (complex), discard (spam)

Pipeline flow

MessageClassifier (type, category)
  → SentimentAnalyzer (urgency, tone, escalation flag)
  → ContextGatherer (prior interactions, related issues, KB articles)
  → ResponseDrafter (draft response with context)
  → RoutingDecider (auto-send | approve | escalate | discard)
  → Output: CommsReport with classification, draft response, routing decision

Inbound message model

Normalizes across all channels:

public class InboundMessage
{
    public required string MessageId { get; init; }
    public required string Channel { get; init; }  // "email", "slack", "teams", "social"
    public required string SenderIdentifier { get; init; }
    public string? SenderName { get; init; }
    public required string Subject { get; init; }
    public required string Body { get; init; }
    public IReadOnlyList<string> Attachments { get; init; } = [];
    public DateTimeOffset ReceivedAt { get; init; }
    public IDictionary<string, string> Metadata { get; init; } = new Dictionary<string, string>();
}

File structure

src/AgencyLayer/CommsCrew/
    Ports/ICommsCrewPort.cs       — ProcessInboundAsync(InboundMessage) → CommsReport
                                    ProcessBatchAsync(IReadOnlyList<InboundMessage>) → IReadOnlyList<CommsReport>
    Models/CommsCrewModels.cs     — InboundMessage, CommsReport, RoutingDecision, SentimentResult
    Engines/CommsCrewEngine.cs    — extends AgentTeamEngineBase
    Infrastructure/ServiceCollectionExtensions.cs

Integration points

Existing component How it is used
AgentTeamEngineBase (src/AgencyLayer/AgentTeamFramework/Engines/) Base class for CommsCrewEngine
INotificationAdapter (src/FoundationLayer/Notifications/) Outbound response delivery via existing channels
SendGridNotificationService (src/FoundationLayer/Notifications/Services/) Email delivery
SlackNotificationService (src/FoundationLayer/Notifications/Services/) Slack delivery
MicrosoftTeamsNotificationService (src/FoundationLayer/Notifications/Services/) Teams delivery
IKnowledgeGraphManager (src/FoundationLayer/KnowledgeGraph/) Retrieve context about previous interactions
IMeshMemoryStore / IExternalMemoryPort Store conversation history for cross-session continuity
HumanCollaboration (src/AgencyLayer/HumanCollaboration/) Route escalated messages to human review sessions via MediatR

Dependencies

  • Leverages existing NotificationAdapter, SlackNotificationService, SendGridNotificationService
  • Optionally uses IExternalMemoryPort (from memory integrations ticket) for conversation memory
  • No new FoundationLayer adapters required for outbound (uses existing notification infrastructure)
  • Feature flag EnableCommsCrew via IFeatureFlagManager

Acceptance criteria

  • ICommsCrewPort extends IAgentTeamPort with ProcessInboundAsync(InboundMessage) → CommsReport and ProcessBatchAsync
  • CommsCrewEngine extends AgentTeamEngineBase with 5 agents in DefineAgents()
  • InboundMessage normalizes messages from email, Slack, Teams, and social channels
  • CommsReport includes classification, sentiment analysis, context gathered, draft response, and routing decision
  • Auto-send path uses existing INotificationAdapter.SendNotificationAsync() for response delivery
  • Escalation path creates a HumanCollaboration session via MediatR
  • DI registration via AddCommsCrewServices() extension method
  • Unit tests for each pipeline stage
  • Feature flag EnableCommsCrew gates activation
  • XML doc comments on all public types (CS1591 compliance)
  • dotnet build — 0 warnings, 0 errors

Out of scope

  • Inbound webhook receivers / polling services (infrastructure that sits outside the agent team)
  • OAuth flows for Slack/Teams/Gmail API access
  • Social media API integration (Twitter/LinkedIn) — separate FoundationLayer adapters
  • Real-time chat bot functionality

Estimated effort

8-10 days

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions