Skip to content

sekuire/slack-agent

Repository files navigation

Slack Agent

A Sekuire AI Agent for Slack that creates Google Docs from Slack threads. This agent demonstrates multi-agent orchestration by delegating document creation to the Google Workspace Agent.

Features

  • Read Threads: Fetch all messages from Slack threads
  • Summarize Threads: Generate AI summaries of conversations
  • Thread to Doc: Create Google Docs from one or more threads
  • Send Messages: Reply in channels or threads
  • Multi-Agent Delegation: Delegates to Google Workspace Agent for document creation

Architecture

┌─────────────┐     ┌──────────────┐     ┌────────────────────┐
│   Slack     │────▶│ Slack Agent  │────▶│ Google Workspace   │
│   (User)    │◀────│  (Port 8003) │◀────│ Agent (Port 8002)  │
└─────────────┘     └──────────────┘     └────────────────────┘
                           │
                           ▼
                    ┌──────────────┐
                    │ Sekuire API  │
                    │  (Port 5556) │
                    └──────────────┘

Prerequisites

  • Node.js 22+
  • Slack App with Bot Token and Socket Mode enabled
  • Google Workspace Agent running (for document creation)
  • Google AI API key (for Gemini LLM features)

Setup

1. Create Slack App

  1. Go to api.slack.com/apps
  2. Create a new app from scratch
  3. Enable Socket Mode in Settings
  4. Generate an App-Level Token with connections:write scope
  5. Under OAuth & Permissions, add these Bot Token Scopes:
    • app_mentions:read
    • channels:history
    • channels:read
    • chat:write
    • commands
    • groups:history
    • groups:read
    • users:read
  6. Install the app to your workspace
  7. Copy the Bot User OAuth Token

2. Enable Events

Under Event Subscriptions, enable and subscribe to:

  • app_mention
  • message.channels

3. Add Slash Command (Optional)

Under Slash Commands, create:

  • Command: /thread-to-doc
  • Description: Create a Google Doc from this thread

4. Environment Variables

Create a .env file:

# Slack Configuration
SLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_SIGNING_SECRET=your-signing-secret
SLACK_APP_TOKEN=xapp-your-app-token

# Google AI for Gemini LLM
GOOGLE_API_KEY=your_google_api_key

# Google Workspace Agent URL
GOOGLE_WORKSPACE_AGENT_URL=http://localhost:8002

# Sekuire Configuration
SEKUIRE_WORKSPACE_ID=your_workspace_id
SEKUIRE_API_URL=http://localhost:5556
SEKUIRE_AUTH_TOKEN=your_auth_token

# Server
PORT=8003

5. Install Dependencies

pnpm install

6. Start the Agents

First, start the Google Workspace Agent:

cd ../google-workspace-agent
pnpm dev

Then start the Slack Agent:

cd ../slack-agent
pnpm dev

Usage

In Slack

Create a doc from a thread:

@SlackAgent create a doc from this thread

With custom title:

@SlackAgent create a doc called "Meeting Notes - Q4 Planning"

Summarize a thread:

@SlackAgent summarize this thread

Using slash command:

/thread-to-doc Weekly Standup Notes

A2A API

Read a thread:

curl -X POST http://localhost:8003/a2a/tasks \
  -H "Content-Type: application/json" \
  -d '{
    "task_id": "read-001",
    "type": "slack:thread:read",
    "input": {
      "channel_id": "C1234567890",
      "thread_ts": "1234567890.123456"
    }
  }'

Create doc from threads:

curl -X POST http://localhost:8003/a2a/tasks \
  -H "Content-Type: application/json" \
  -d '{
    "task_id": "doc-001",
    "type": "slack:thread:to_doc",
    "input": {
      "threads": [
        {"channel_id": "C1234567890", "thread_ts": "1234567890.123456"},
        {"channel_id": "C0987654321", "thread_ts": "0987654321.654321"}
      ],
      "doc_title": "Combined Meeting Notes",
      "include_summary": true
    }
  }'

API Endpoints

Endpoint Method Description
/health GET Health check
/metrics GET Agent metrics
/agent/info GET Agent capabilities
/.well-known/agent.json GET A2A agent card
/a2a/tasks POST Execute A2A tasks
/sekuire/handshake POST Trust protocol handshake
/sekuire/hello GET Protocol discovery

A2A Task Types

Type Description
slack:thread:read Read messages from a thread
slack:thread:summarize Summarize a thread
slack:thread:to_doc Create Google Doc from threads
slack:message:send Send a message
task:chat Natural language interaction

Multi-Agent Flow

When a user asks to create a document:

  1. Slack Agent receives the request
  2. Slack Agent fetches thread content from Slack API
  3. Slack Agent formats content as markdown
  4. Slack Agent (optionally) generates summary using LLM
  5. Slack Agent delegates to Google Workspace Agent via A2A
  6. Google Workspace Agent creates the document
  7. Slack Agent receives the document URL
  8. Slack Agent posts the URL back to Slack

Development

# Run with hot reload
pnpm dev

# Build for production
pnpm build

# Run tests
pnpm test

# Lint code
pnpm lint

Troubleshooting

"Socket Mode not enabled"

Enable Socket Mode in your Slack app settings and generate an App-Level Token.

"Missing scopes"

Ensure all required bot token scopes are added and reinstall the app.

"Document creation failed"

  1. Check that Google Workspace Agent is running
  2. Verify the GOOGLE_WORKSPACE_AGENT_URL is correct
  3. Check Google Workspace Agent logs for errors

"Summarization not working"

Set GOOGLE_API_KEY environment variable for Gemini LLM access.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors