A Slack bot that uses Google's Gemini 2.0 Flash AI to analyze conversation context and provide both intelligent response suggestions and personality profiles. The bot helps teams quickly respond to complex questions and understand team dynamics by analyzing conversation history and generating actionable insights.
- 🤖 Gemini-Powered Response Suggestions: Get smart, context-aware suggestions for how to reply to any message
- 💬 @mention Activation: Mention the bot in any channel to get instant suggestions
- 📝 /suggest Command: Use
/suggest [your question]
for explicit suggestions - 🎭 Personality Profile Analysis: Analyze communication styles, emotional tones, and key traits with
/personality-analyze
- 🔐 Google SSO Authentication: Secure authentication using Google OAuth2
- 🌍 Multi-language Support: Analyzes conversations in multiple languages
- 🔒 Privacy First: All results are private and only visible to the requesting user
- ⚙️ Flexible Configuration: Multiple analysis methods and user-configurable settings
- Node.js 18+
- Slack App with appropriate permissions
- Google Cloud Project with Gemini API enabled
- Google OAuth2 credentials for SSO
- Clone the repository:
git clone <repository-url>
cd slack-personality-analysis-bot
- Install dependencies:
npm install
- Copy environment template:
cp env.example .env
-
Configure your environment variables in
.env
:- Add your Slack bot token, signing secret, and app token
- Add your Google Gemini API key
- Configure Google OAuth2 credentials for SSO
- Configure other settings as needed
-
Build the project:
npm run build
- Start the bot:
npm start
For development with auto-reload:
npm run dev
Run tests:
npm test
-
@mention the bot in any channel with a question or request:
@YourBotName How should I respond to this client?
The bot will analyze the conversation and provide several Gemini-powered response suggestions as an ephemeral message.
-
Use the
/suggest
command for explicit suggestions:/suggest How should I respond to this client?
The bot will analyze the recent conversation and provide suggestions.
- Use the
/personality-analyze
command in any channel with multiple participants:The bot will analyze the conversation history and generate personality profiles for each participant./personality-analyze
- The bot supports Google SSO for secure authentication:
- Visit
/auth/google
to initiate Google OAuth2 login - Complete the authentication flow
- Access protected features with your authenticated session
- Use
/auth/logout
to sign out
- Visit
- Use the
/config
command to configure analysis methods:- Full month history analysis
- Recent messages focus
- Thread-specific analysis
- Keyword-based filtering
The Slack Personality & Response Assistant Bot follows a modular architecture with clear separation of concerns. Here's how the different services interact:
graph TB
%% External Services
Slack[Slack Platform] --> |commands| Bot[Slack Bot App]
Bot --> |API calls| Slack
Google[Google OAuth2] --> |SSO| Bot
Gemini[Gemini AI] --> |analysis| Bot
%% Core Application Components
Bot --> |HTTP requests| Bolt[Bolt Framework]
Bolt --> |events| Handlers[Event Handlers]
Handlers --> |analyze| PersonalityAnalyzer[Personality Analyzer Service]
Handlers --> |suggest| SuggestionGenerator[Suggestion Generator]
PersonalityAnalyzer --> |fetch history| SlackAPI[Slack API]
SuggestionGenerator --> |fetch history| SlackAPI
SlackAPI --> |message data| PersonalityAnalyzer
SlackAPI --> |message data| SuggestionGenerator
%% AI Integration
PersonalityAnalyzer --> |context| GeminiService[Gemini Service]
SuggestionGenerator --> |context| GeminiService
GeminiService --> |API calls| Gemini
Gemini --> |personality insights| GeminiService
Gemini --> |suggestions| GeminiService
GeminiService --> |profiles| ProfileGenerator[Profile Generator]
%% Authentication
SSOHandler[SSO Handler] --> |OAuth2| Google
AuthMiddleware[Auth Middleware] --> |protect| Handlers
%% Response Flow
ProfileGenerator --> |reports| Handlers
SuggestionGenerator --> |suggestions| Handlers
Handlers --> |ephemeral| Bolt
Bolt --> |private| Slack
%% Configuration
ConfigService[Config Service] --> |preferences| PersonalityAnalyzer
ConfigService --> |methods| ProfileGenerator
%% Middleware
RateLimiter[Rate Limiter] --> |throttle| Bolt
ErrorHandler[Error Handler] --> |handle errors| Handlers
Logger[Logger] --> |monitor| Bot
%% Data Flow
subgraph "Data Processing"
PrivacyUtils[Privacy Utils] --> |sanitize| PersonalityAnalyzer
PrivacyUtils --> |sanitize| SuggestionGenerator
Logger --> |log| Bot
end
%% Styling
classDef external fill:#e1f5fe
classDef core fill:#f3e5f5
classDef service fill:#e8f5e8
classDef middleware fill:#fff3e0
class Slack,Google,Gemini external
class Bot,Bolt,Handlers core
class PersonalityAnalyzer,GeminiService,ProfileGenerator,SuggestionGenerator,ConfigService service
class RateLimiter,ErrorHandler,PrivacyUtils,Logger,SSOHandler,AuthMiddleware middleware
Service | Responsibility | Key Functions |
---|---|---|
Bolt Framework | Slack integration layer | Event routing, API communication |
Event Handlers | Request processing | Command handling, SSO processing, suggestions |
Personality Analyzer | Conversation analysis | History retrieval, participant extraction |
Suggestion Generator | Response suggestions | Gemini-powered suggestions, context analysis |
Gemini Service | AI integration | Gemini API communication, prompt management |
Profile Generator | Report formatting | Slack Block Kit formatting, privacy compliance |
SSO Handler | Authentication | Google OAuth2 flow, JWT management |
Auth Middleware | Route protection | JWT verification, access control |
Rate Limiter | Performance control | Request throttling, abuse prevention |
Error Handler | Error management | Graceful failure handling, logging |
Logger | Monitoring | Structured logging, performance tracking |
Get Gemini-powered response suggestions for your question in the current channel context.
Analyze the personality profiles of conversation participants.
Configure analysis methods and preferences.
Mention the bot in any channel with a question to get Gemini-powered suggestions.
Initiates Google OAuth2 authentication flow.
Handles OAuth2 callback and creates user session.
Logs out the current user and clears session.
Protected endpoint requiring authentication.
# Slack Configuration
SLACK_BOT_TOKEN=xoxb-your-bot-token-here
SLACK_SIGNING_SECRET=your-signing-secret-here
SLACK_APP_TOKEN=xapp-your-app-token-here
# Google Gemini Configuration
GEMINI_API_KEY=your-gemini-api-key-here
GEMINI_MODEL=gemini-2.0-flash-exp
# Google OAuth2 Configuration
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URI=http://localhost:3000/auth/google/callback
# JWT Configuration
JWT_SECRET=your-jwt-secret-key
JWT_EXPIRES_IN=24h
# Application Configuration
NODE_ENV=development
PORT=3000
LOG_LEVEL=info
# Rate Limiting
RATE_LIMIT_WINDOW_MS=60000
RATE_LIMIT_MAX_REQUESTS=10
# Analysis Configuration
MAX_CONTEXT_MESSAGES=1000
MAX_CONTEXT_DAYS=30
CACHE_TTL_MS=300000
- Data Sanitization: All messages are sanitized to remove sensitive information
- Privacy Compliance: Analysis results and suggestions are sent as ephemeral messages
- Rate Limiting: Prevents abuse and ensures fair usage
- JWT Authentication: Secure token-based authentication
- Input Validation: Comprehensive validation of all inputs
- Error Handling: Graceful error handling without exposing sensitive data
The bot includes comprehensive logging and monitoring:
- Structured Logging: JSON-formatted logs with contextual information
- Performance Tracking: Duration measurements for all operations
- Error Monitoring: Detailed error logging with stack traces
- Usage Analytics: Track command usage and success rates
- Health Checks: Built-in health check endpoints
-
Bot not responding to commands or mentions
- Check if bot token is valid
- Verify bot is added to the channel
- Check bot permissions (commands, chat:write)
-
Gemini API errors
- Verify API key is correct
- Check API quota and billing
- Ensure model name is valid
-
SSO authentication issues
- Verify Google OAuth2 credentials
- Check redirect URI configuration
- Ensure JWT secret is set
-
Rate limiting issues
- Check Slack API rate limits
- Verify Gemini API rate limits
- Adjust rate limiting configuration
Enable debug logging by setting LOG_LEVEL=debug
in your environment variables.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions:
- Check the logs for error messages
- Verify all environment variables are set correctly
- Test the health check endpoints
- Contact the development team with specific error details