chatops Package

Overview

Package chatops provides comprehensive ChatOps integration for the incident management platform.

This package implements ChatOps (Chat Operations) functionality that enables incident management through popular chat platforms like Slack, Microsoft Teams, Discord, and Mattermost. It provides a unified interface for managing incidents directly from chat channels through slash commands, interactive buttons, bot mentions, and automated notifications.

Key Features:

  • Multi-platform chat integration with provider abstraction
  • Slash command processing for incident lifecycle management
  • Interactive bot responses with button and menu support
  • Automated incident notifications to relevant channels
  • Webhook processing for real-time chat platform events
  • Natural language processing for bot mentions and queries
  • Channel routing based on incident severity and team assignments
  • Timeline integration for comprehensive audit trails

Architecture:

The ChatOps system follows a provider-based architecture with centralized management:

┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│ Chat Platforms  │───►│ ChatOps Manager  │───►│ Incident System │
│ (Slack/Teams)   │    │ (Orchestration)  │    │ (Timeline/API)  │
└─────────────────┘    └──────────────────┘    └─────────────────┘
                                                      
┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│ Provider        │    │ Command          │    │ Event           │
│ Registry        │    │ Processing       │    │ Broadcasting    │
└─────────────────┘    └──────────────────┘    └─────────────────┘

Supported Platforms:

  • Slack: Full integration with slash commands, interactive components, and webhooks
  • Microsoft Teams: Command processing and notification support
  • Discord: Bot integration with command and notification capabilities
  • Mattermost: Open source chat platform integration

Command Interface: The ChatOps system supports comprehensive incident management through slash commands:

  • /im declare [title] - Create new incidents with automated channel creation
  • /im ack [incident-id] - Acknowledge incidents with timestamp tracking
  • /im resolve [incident-id] [note] - Resolve incidents with resolution notes
  • /im close [incident-id] - Close resolved incidents
  • /im status [incident-id] - Get detailed incident status and timeline
  • /im list - List active incidents with filtering options

Example usage:

// Create ChatOps manager with timeline integration
manager := chatops.NewManager(timelineService)

// Configure Slack integration
slackConfig := chatops.Config{
	BotToken:            "xoxb-your-bot-token",
	SigningSecret:       "your-signing-secret",
	BotName:            "incident-bot",
	DefaultChannel:     "#incidents",
	IncidentChannel:    "#incident-response",
	EnableNotifications: true,
	NotificationChannels: map[string]string{
		"SEV-1": "#critical-incidents",
		"SEV-2": "#major-incidents",
		"SEV-3": "#incidents",
	},
}

err := manager.AddProvider(ctx, "main-slack", "slack", slackConfig)
if err != nil {
	log.Fatal(err)
}

// Send incident notification
incident := &models.Incident{
	ID:       "INC-123",
	Title:    "Database Connection Issues",
	Severity: models.SeveritySEV2,
	Status:   models.StatusOpen,
}

err = manager.SendIncidentNotification(ctx, incident, NotificationIncidentCreated)
if err != nil {
	log.Fatal(err)
}

// Process slash command from webhook
command := &SlashCommand{
	Command:   "/im",
	Text:     "declare Database timeout issues",
	UserID:   "U12345",
	ChannelID: "C67890",
}

response, err := manager.ProcessSlashCommand(ctx, "main-slack", command)
if err != nil {
	log.Fatal(err)
}

Provider System: The ChatOps system uses a provider registry that allows pluggable chat platform integrations. Each provider implements the Provider interface and handles:

  • Platform-specific authentication and connection management
  • Message formatting and interactive component rendering
  • Webhook signature validation and event parsing
  • Real-time communication and notification delivery

Notification Types:

  • NotificationIncidentCreated: New incident alerts with severity-based routing
  • NotificationIncidentAcknowledged: Acknowledgment confirmations
  • NotificationIncidentUpdated: Status and metadata changes
  • NotificationIncidentResolved: Resolution notifications with summaries
  • NotificationIncidentClosed: Closure confirmations and post-mortems

Integration Patterns: The ChatOps system integrates seamlessly with other platform components:

  • Timeline Service: All chat-initiated actions are recorded in incident timelines
  • Real-time Broadcasting: Chat notifications sync with web dashboard updates
  • Authentication: Chat user IDs are mapped to platform user accounts
  • Policy Engine: Role-based permissions control chat command access

Security: All chat platform integrations include comprehensive security measures:

  • Webhook signature validation for request authenticity
  • Rate limiting to prevent command abuse
  • User authentication and authorization checks
  • Sensitive data redaction in chat messages
  • Audit logging for all ChatOps actions

Import Path: github.com/systmms/incidents/internal/chatops

Variables

ErrProviderNotFound (and others)

Common errors

var ErrProviderNotFound ErrConnectionFailed ErrAuthenticationFailed ErrOperationNotSupported ErrChannelNotFound ErrUserNotFound ErrMessageNotFound ErrInvalidWebhook ErrRateLimited

Types

ActionType

ActionType represents different types of incident actions

{<nil> 8742 type 0 [0x140004a1980] 0}

Constants

const ActionDeclare const ActionAck const ActionMitigate const ActionResolve const ActionClose const ActionEscalate const ActionAssign const ActionNote const ActionJoin const ActionLeave

Attachment

Attachment represents a message attachment (file, image, etc.)

{<nil> 10520 type 0 [0x140004b01c0] 0}

AttachmentField

AttachmentField represents a field in an attachment

{<nil> 11468 type 0 [0x140004b05c0] 0}

AttachmentType

AttachmentType represents the type of attachment

{<nil> 11149 type 0 [0x140004b04c0] 0}

Constants

const AttachmentText const AttachmentImage const AttachmentFile const AttachmentCard const AttachmentTemplate

Channel

Channel represents a chat channel/room

{<nil> 11630 type 0 [0x140004b0700] 0}

ChannelType

ChannelType represents the type of channel

{<nil> 12159 type 0 [0x140004b09c0] 0}

Constants

const ChannelPublic const ChannelPrivate const ChannelDM const ChannelGroup

ChatOpsError

ChatOpsError represents structured errors with detailed context for ChatOps operations.

This error type provides comprehensive error information including error codes for programmatic handling, user-friendly messages, and detailed context for debugging and troubleshooting. It supports error classification and enables appropriate error handling strategies across different chat platforms.

{<nil> 16322 type 0 [0x140004b1b40] 0}

Config

Config holds comprehensive provider-specific configuration for chat platform integration.

This structure contains all necessary configuration parameters for establishing and maintaining connections to chat platforms, including authentication credentials, channel routing preferences, feature enablement flags, and platform-specific settings. The configuration supports multi-tenant deployments and flexible feature management.

{<nil> 3103 type 0 [0x140004a0200] 0}

CreateChannelRequest

CreateChannelRequest represents a request to create a new channel

{<nil> 12416 type 0 [0x140004b0ac0] 0}

ElementType

ElementType represents the type of interactive element

{<nil> 6944 type 0 [0x140004a1100] 0}

Constants

const ElementButton const ElementSelect const ElementInput const ElementCheckbox const ElementRadio

IncidentAction

IncidentAction represents an action to be performed on an incident

{<nil> 8435 type 0 [0x140004a1800] 0}

Interaction

Interaction represents user interaction with interactive elements

{<nil> 7444 type 0 [0x140004a1340] 0}

InteractionResponse

InteractionResponse represents response to user interaction

{<nil> 8093 type 0 [0x140004a1680] 0}

InteractiveElement

InteractiveElement represents an interactive UI element

{<nil> 6466 type 0 [0x140004a0e80] 0}

InteractiveMessage

InteractiveMessage represents a message with interactive elements

{<nil> 6312 type 0 [0x140004a0d80] 0}

Manager

Manager orchestrates ChatOps operations across multiple chat platform providers.

The Manager serves as the central coordination point for all ChatOps functionality, providing a unified interface for managing chat platform integrations, processing commands and webhooks, and coordinating incident management activities across different chat platforms simultaneously.

Core Responsibilities:

  • Chat provider lifecycle management (connection, health monitoring, failover)
  • Slash command processing and routing to appropriate incident actions
  • Webhook event processing and validation from multiple chat platforms
  • Incident notification distribution with severity-based channel routing
  • Interactive response handling (buttons, menus, dialogs)
  • Natural language processing for bot mentions and conversational queries
  • Timeline integration for comprehensive audit trails of chat-initiated actions

The Manager supports multiple concurrent chat platform connections, enabling organizations to use their preferred combination of Slack, Teams, Discord, and other platforms while maintaining consistent incident management workflows.

{<nil> 24283 type 0 [0x140004b1f00] 0}

Methods

NewManager

NewManager creates a new ChatOps manager with comprehensive provider support.

This constructor initializes the ChatOps management system with a provider registry containing all supported chat platforms. The manager is immediately ready to accept provider configurations and begin processing chat-based incident management commands.

Provider Registration: The manager automatically registers built-in providers:

  • Slack: Full-featured integration with interactive components
  • Microsoft Teams: Command processing and notification support
  • Discord: Bot integration with slash command support
  • Mattermost: Open source platform integration

Parameters:

  • timeline: Timeline service for logging all ChatOps actions to incident audit trails

Integration: The manager integrates with:

  • Timeline service for comprehensive audit logging of chat-initiated actions
  • Provider registry for pluggable chat platform support
  • Configuration management for multi-platform deployment flexibility

The manager supports concurrent connections to multiple chat platforms, enabling organizations to use their preferred mix of communication tools while maintaining consistent incident management workflows.

Returns a fully configured Manager ready for provider setup and command processing.

{<nil> <nil> NewManager 0x140004da140 <nil>}

Message

Message represents a chat message to be sent

{<nil> 4136 type 0 [0x140004a0640] 0}

MessageUpdate

MessageUpdate represents updates to an existing message

{<nil> 10234 type 0 [0x140004b0080] 0}

Notification

Notification represents a formatted incident notification for chat platform delivery.

This structure contains all necessary information for generating rich, contextual notifications about incident lifecycle events. It supports platform-specific formatting, severity-based styling, and deep linking to facilitate effective incident response coordination through chat channels.

{<nil> 4976 type 0 [0x140004a0900] 0}

NotificationType

NotificationType represents different types of notifications

{<nil> 5703 type 0 [0x140004a0c80] 0}

Constants

const NotificationIncidentCreated const NotificationIncidentUpdated const NotificationIncidentAcknowledged const NotificationIncidentResolved const NotificationIncidentClosed const NotificationIncidentEscalated const NotificationSLABreach

Operation

Operation represents supported ChatOps operations

{<nil> 2129 type 0 [0x140004a0080] 0}

Constants

const OpSendMessage const OpSendNotification const OpUpdateMessage const OpDeleteMessage const OpInteractive const OpWebhooks const OpChannelManagement const OpUserManagement const OpSlashCommands const OpBotMentions

Option

Option represents an option in a select element

{<nil> 7231 type 0 [0x140004a1200] 0}

Provider

Provider defines the comprehensive interface that all ChatOps platform integrations must implement.

This interface abstracts the differences between chat platforms (Slack, Teams, Discord, etc.) while providing a unified API for incident management operations. Providers handle platform-specific authentication, message formatting, interactive components, and webhook processing while presenting a consistent interface to the ChatOps manager.

The interface is designed to support the full spectrum of ChatOps functionality including real-time messaging, interactive components, webhook event processing, and comprehensive channel and user management across different chat platform ecosystems.

{<nil> 771 type 0 [0x1400048ac80] 0}

Methods

NewSlackProvider

NewSlackProvider creates a new Slack provider with optimized configuration.

This constructor initializes a Slack provider with production-ready defaults including appropriate HTTP timeouts, connection pooling, and error handling. The provider is immediately ready for configuration and connection to Slack workspaces.

HTTP Client Configuration: The provider uses an HTTP client configured for:

  • 30-second timeout for API operations to handle Slack API latency
  • Connection pooling for efficient concurrent operations
  • Automatic decompression for optimal bandwidth usage
  • Proper User-Agent headers for API tracking and support

Slack API Compatibility: The provider is built for compatibility with:

  • Slack Web API v1.0+ for all standard operations
  • Events API v1.0+ for real-time webhook processing
  • Block Kit v2.0+ for modern interactive components
  • OAuth v2.0 for secure authentication flows

Provider Lifecycle: The provider follows the standard lifecycle:

  1. Creation with NewSlackProvider()
  2. Configuration through Connect() with workspace credentials
  3. Health monitoring through Health() checks
  4. Operational use through Provider interface methods
  5. Cleanup through Disconnect() when shutting down

Returns a fully configured SlackProvider ready for workspace connection.

{<nil> <nil> NewSlackProvider 0x1400022b480 <nil>}

ProviderFactory

ProviderFactory creates new instances of a specific ChatOps provider type.

Factory functions enable dynamic provider instantiation and support the plugin architecture of the ChatOps system. Each provider type registers a factory that creates properly initialized provider instances ready for configuration.

{<nil> 14252 type 0 [0x140004b1140] 0}

ProviderInstance

ProviderInstance represents an active chat platform connection with comprehensive state tracking.

This structure wraps a chat platform provider with its configuration, connection status, health monitoring data, and operational metadata. It provides the foundation for multi-provider ChatOps management with detailed visibility into each platform’s operational state and performance characteristics.

State Management: Each instance maintains detailed operational state including connection status, last successful synchronization timestamps, error tracking, and performance metrics. This enables proactive monitoring, troubleshooting, and automated failover capabilities.

{<nil> 25459 type 0 [0x140004d2180] 0}

Registry

Registry manages ChatOps provider registration and instantiation.

The Registry implements the factory pattern for ChatOps providers, enabling dynamic provider registration and creation. It supports plugin-style architecture where new chat platform integrations can be added without modifying core code.

The registry maintains thread-safe access to provider factories and supports runtime provider discovery and instantiation for flexible deployment configurations.

{<nil> 13800 type 0 [0x140004b1040] 0}

Methods

NewRegistry

NewRegistry creates a new provider registry

{<nil> <nil> NewRegistry 0x140004adde0 <nil>}

SlackAttachment

{<nil> 93389 type 0 [0x1400025f400] 0}

SlackAttachmentField

{<nil> 93784 type 0 [0x1400025f640] 0}

SlackBlock

{<nil> 93909 type 0 [0x1400025f780] 0}

SlackBlockElement

{<nil> 94038 type 0 [0x1400025f880] 0}

SlackChannel

{<nil> 95434 type 0 [0x14000276a00] 0}

SlackChannelInfo

{<nil> 95836 type 0 [0x14000277000] 0}

SlackChannelResponse

{<nil> 96383 type 0 [0x14000277540] 0}

SlackChannelsResponse

{<nil> 96286 type 0 [0x14000277440] 0}

SlackCreateChannel

{<nil> 96644 type 0 [0x14000277840] 0}

SlackDeleteMessage

{<nil> 93292 type 0 [0x1400025f300] 0}

SlackEventData

{<nil> 95211 type 0 [0x14000276200] 0}

SlackInviteToChannel

{<nil> 96750 type 0 [0x14000277940] 0}

SlackMessage

SlackMessage represents a complete Slack message structure for API delivery.

This structure encapsulates all message components supported by Slack’s chat.postMessage API, including rich formatting, attachments, threading, and modern Block Kit components for interactive messaging.

Message Components:

  • Channel: Target channel, DM, or thread for message delivery
  • Text: Primary message content with Slack markdown formatting
  • ThreadTS: Thread timestamp for organized conversation flows
  • Attachments: Legacy rich formatting with colors and fields
  • Blocks: Modern Block Kit components for interactive elements
{<nil> 92406 type 0 [0x1400025ef80] 0}

SlackMessageUpdate

{<nil> 93048 type 0 [0x1400025f180] 0}

SlackOption

{<nil> 94393 type 0 [0x1400025fc00] 0}

SlackProfile

{<nil> 96141 type 0 [0x14000277300] 0}

SlackProvider

SlackProvider implements the Provider interface for comprehensive Slack integration.

This provider offers full-featured Slack integration for the incident management platform, including slash commands, interactive components, webhooks, channel management, and user management. It handles all aspects of Slack API interaction including authentication, message formatting, and real-time event processing.

Core Capabilities:

  • Complete Slack API integration with OAuth and bot token authentication
  • Rich message formatting with blocks, attachments, and interactive components
  • Comprehensive webhook processing for slash commands and interactive events
  • Channel and user management operations through Slack’s conversations API
  • Real-time event handling for bot mentions and workspace events
  • Proper error handling with Slack-specific error responses

Authentication: The provider supports multiple authentication methods:

  • Bot tokens for workspace-level integration and API access
  • OAuth tokens for user-specific operations and permissions
  • Webhook signature validation for secure event processing
  • Proper scope management for different API endpoints

Interactive Features: Supports comprehensive interactive functionality:

  • Slash commands for incident management operations
  • Interactive buttons for quick actions (acknowledge, resolve, escalate)
  • Select menus for complex option selection and workflow management
  • Modal dialogs for detailed form inputs and confirmations
  • Bot mentions for conversational incident queries

Message Formatting: Provides rich message formatting capabilities:

  • Slack Block Kit for modern interactive components
  • Legacy attachments for backward compatibility
  • Severity-based color coding and emoji indicators
  • Thread support for organized conversation flows
  • Deep linking to incident management dashboard

Channel Management: Comprehensive channel operations including:

  • Public and private channel creation for incident response
  • User invitation and membership management
  • Channel metadata and configuration management
  • Thread management for structured incident discussions

Error Handling: Robust error handling with Slack API specifics:

  • Proper Slack API error code interpretation
  • Rate limiting awareness and backoff strategies
  • Network failure handling and retry mechanisms
  • Validation error reporting with actionable context
{<nil> 56283 type 0 [0x140001e2b80] 0}

SlackResponse

SlackResponse represents the standard response structure from Slack API endpoints.

This structure captures the common response format used across all Slack API operations, providing consistent error handling and success indication for all provider operations including messaging, channel management, and user operations.

{<nil> 91535 type 0 [0x1400025ee40] 0}

SlackText

{<nil> 94312 type 0 [0x1400025fb00] 0}

SlackUser

{<nil> 95899 type 0 [0x140002770c0] 0}

SlackUserResponse

{<nil> 96564 type 0 [0x14000277740] 0}

SlackUsersResponse

{<nil> 96475 type 0 [0x14000277640] 0}

SlackWebhookEvent

{<nil> 94485 type 0 [0x1400025fd00] 0}

SlashCommand

SlashCommand represents a slash command execution

{<nil> 9894 type 0 [0x140004a1dc0] 0}

Status

Status represents the current operational status of a ChatOps provider.

The status provides visibility into provider health and connectivity, enabling monitoring, alerting, and automated recovery workflows.

{<nil> 26515 type 0 [0x140004d2440] 0}

Constants

const StatusDisconnected const StatusConnecting const StatusConnected const StatusError

User

User represents a chat platform user

{<nil> 12759 type 0 [0x140004b0d00] 0}

WebhookEvent

WebhookEvent represents a parsed webhook event from chat platform

{<nil> 9251 type 0 [0x140004a1a80] 0}

Generated automatically from Go source code. Last updated: 2025-08-25T07:51:05-04:00