Agent skill

slack-channel-integration

Build Slack as a communication channel for AI agents. Use when implementing Slack OAuth, webhooks, event processing, or creating agent-to-Slack messaging pipelines.

Stars 0
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/rbarazi/agent-skills/tree/main/skills/slack-channel-integration

SKILL.md

Slack Channel Integration

Build Slack as a channel for AI agents - users interact with agents via mentions, DMs, and threads.

Problem Statement

AI agents need to communicate with users through familiar platforms. Slack provides a natural interface where users can @mention agents, receive responses in threads, and see real-time status through reactions.

When to Use

  • Building a Slack bot that connects to an AI agent backend
  • Implementing OAuth v2 flow for Slack workspace installation
  • Processing Slack events (mentions, DMs, reactions)
  • Mapping Slack threads to agent conversations/tasks
  • Keywords: slack bot, slack integration, slack oauth, slack webhooks, agent channel

Quick Start

ruby
class SlackChannel < AgentChannel
  include ChannelClient
  include ChannelOAuth

  OAUTH_SCOPES = %w[app_mentions:read chat:write users:read].freeze

  has_many :user_slack_channels, foreign_key: :agent_channel_id
end

Process events in Webhooks::SlackEvent#process!:

ruby
def process!
  react("eyes")  # Received
  task = agent.tasks.find_or_create_by!(name: "slack-#{thread_ts}")
  response = task.process_message(content: event[:event][:text])
  send_slack_response(response)
  react("white_check_mark")  # Done
end

Architecture

Channel → AccountChannel → AgentChannel → UserAgentChannel
                              ↓
                         SlackChannel
                              ↓
                      UserSlackChannel (OAuth tokens)

Key Patterns

Reaction-based status: eyes (received) → white_check_mark (done) → x (failed)

Thread mapping: thread_ts || ts → Task name for conversation continuity

Duplicate prevention: Validate unique event_id and team_id + ts combination

Testing Strategy

ruby
RSpec.describe SlackChannel do
  it "stores OAuth tokens securely" do
    channel = create(:slack_channel)
    expect(channel.access_token).to be_encrypted
  end
end

RSpec.describe "Slack webhooks", type: :request do
  it "verifies signature before processing" do
    post "/webhooks/slack", headers: invalid_signature
    expect(response).to have_http_status(:unauthorized)
  end
end

Common Pitfalls

  1. Signature verification: Always verify X-Slack-Signature before processing
  2. Duplicate events: Slack may retry - use event_id for idempotency
  3. 3-second timeout: Respond quickly, process async if needed

Reference Files

  • oauth.md - OAuth flow, scopes, and token management
  • webhooks.md - Event processing and controller setup
  • manifest.md - Slack app manifest generation
  • mrkdwn.md - Markdown to mrkdwn conversion

Expand your agent's capabilities with these related and highly-rated skills.

rbarazi/agent-skills

test-auth-helpers

Implement authentication testing patterns with RSpec, FactoryBot, and test helpers for Rails applications. Use when writing controller specs, system tests, or request specs that require authenticated users and multi-tenant account context.

0 0
Explore
rbarazi/agent-skills

multi-tenant-accounts

Implement multi-tenant architecture using an Account model as the tenant boundary. Use when building SaaS applications, team-based apps, or any system where data must be isolated between organizations/accounts.

0 0
Explore
rbarazi/agent-skills

user-management

Implement user CRUD operations within an account with permission controls and feature flags. Use when building team member management, user administration, or account user settings in multi-tenant Rails applications.

0 0
Explore
rbarazi/agent-skills

oauth21-provider

Implement an RFC-compliant OAuth 2.1 authorization server in Rails applications. Use when building apps that need to authorize third-party clients (like MCP clients, API consumers, or external integrations) using industry-standard OAuth flows with PKCE, dynamic client registration, and token management.

0 0
Explore
rbarazi/agent-skills

password-reset-flow

Implement secure password reset with Rails 8's built-in token generation. Use when building "forgot password" functionality with email verification and time-limited reset tokens.

0 0
Explore
rbarazi/agent-skills

code-pattern-extraction

Extract reusable design and implementation patterns from codebases into Skills. Use when asked to analyze code for patterns, document architectural decisions, create transferrable implementation guides, or extract knowledge into Skills. Transforms working implementations into comprehensive, reusable Skills that can be applied to new projects.

0 0
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results