-
Notifications
You must be signed in to change notification settings - Fork 89
Feat/inkeep slack app v2 #1595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feat/inkeep slack app v2 #1595
Conversation
Add initial landing page at /[tenantId]/slack-app with account info, connection status, and install button placeholder.
- Add /manage/slack/install and /oauth_redirect API routes
- Add Slack env vars (CLIENT_ID, CLIENT_SECRET, SIGNING_SECRET, APP_URL)
- Update .env.example files with Slack configuration template
- Update slack-app page with Install to Slack button
- Display installed workspaces with bot token
- Use localStorage for workspace data (DB integration coming soon)
- Fix hydration mismatch with mounted state pattern
- Add Nango Connect UI to use production URLs (not local dev MCP URLs)
- Add hasConnected flag to prevent false "cancelled" toast after successful nango connect
- Enrich Nango connection metadata with Slack user info via API call
(slack_username, slack_display_name, slack_email, is_slack_admin, is_slack_owner)
- Add findConnectionBySlackUser helper to look up connections by Slack user ID
- Add slack command /inkeep status to show actual linked Inkeep account info
- Add /inkeep link to link to dashboard and show "Already Connected" if user is linked
- Add /inkeep disconnect to delete Nango connection directly from Slack
- Add /manage/slack/events endpoint for Slack URL verification
- Add Slack-specific Nango env vars (NANGO_SLACK_SECRET_KEY, NANGO_SLACK_INTEGRATION_ID)
Backend: - Add @slack/web-api, @slack/bolt, slack-block-builder packages - Create modular service structure under services/slack/: - types.ts, client.ts, nango.ts, security.ts - blocks/index.ts with slack-block-builder message templates - commands/index.ts with handler functions - Refactor slack routes to use new services - Add GET /status and POST /disconnect API endpoints - Add findConnectionByAppUser and getConnectionStatus helpers - Store tenantId in Nango metadata for proper API context - Add SLACK_BOT_TOKEN to env schema Frontend: - Add TanStack Query layer (api/slack-api.ts, api/queries.ts) - Create PostgreSQL-like localStorage schema: - WorkspaceRecord, UserRecord, SlackUserConnection, AuditLogRecord - Full CRUD operations in db/local-db.ts - Add useWorkspaceDb, useSlackSync hooks - Update DatabasePreviewCard with 5 tabs: Workspaces, Users, Slack, Audit, Raw JSON - Save workspace installs and user connections to new database - Add workspace installation check before allowing user linking - Fix disconnect flow to call Nango API and clear local state - Add clickable workspace links in Installed Workspaces table
- Add new /work-apps route with overview page showing all work apps - Move Slack dashboard to /work-apps/slack sub-route - Update sidebar: rename 'Slack App' to 'Work Apps', use Plug icon - Add stub work apps: GitHub, Discord, Linear, Notion, Jira (Coming Soon) - Create WorkAppCard component with status badges and actions - Add custom SVG icons for work app integrations - Add auto-refresh for Database Preview on connection changes: - Dispatch 'inkeep-db-update' custom event on data changes - Listen for event in useDatabaseState hook - Add back navigation link from Slack dashboard to Work Apps - Remove Session column from Database Preview (not stored) - Remove updateSessionToken function (not needed)
…sues
- Store session token in Nango metadata for authenticated Slack API calls
- Add /refresh-session endpoint to update token on re-login
- Fix infinite fetch loop causing Slack rate limiting
- Fix OAuth redirect to new /work-apps/slack route
- Replace custom hooks with TanStack Query + Zustand store
- Fix hydration mismatches with proper mounted state pattern
- Use Bearer token auth for Slack commands instead of cookie
- Add SlackApiClient for modular, DRY API calls
- Add session refresh on dashboard visit to keep Nango token fresh
- Sync localDb on connect/disconnect for database preview
- Add auto-dismiss (5s) and manual close button to notification banner
- Handle 404 gracefully in workspace info query (no error toast on disconnect)
- Add workspace count indicator and Beta badge to Work Apps UI
- Remove external link from card (available in Installed Workspaces instead)
- Extract localDb sync helpers to db/sync.ts for future PostgreSQL migration
- Add SlackNotificationAction type for type-safe notification triggers
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
|
Claude finished @victor-inkeep's task —— View job Staff Engineer Code Review - Slack Integration v2Conducting comprehensive architectural and code quality review for the Slack integration feature. Review Tasks:
Review SummaryThis PR introduces a comprehensive Slack integration with a modular "Work Apps" architecture. While the implementation is functionally sound, there are several critical security concerns and architectural considerations that need to be addressed. 🚨 Critical Security Issues1. Session Token Storage in Third-Party Service (HIGH)Location: The current implementation stores Inkeep session tokens in Nango connection metadata, which introduces significant security risks: // Storing sensitive session tokens in external service
inkeep_session_token: pendingSession.token,
inkeep_session_expires_at: pendingSession.expiresAt,Issues:
Recommendation:
2. In-Memory Session Storage Without Persistence (MEDIUM)Location: const pendingSessionTokens = new Map<string, { token: string; expiresAt: string; createdAt: number }>();Issues:
Recommendation:
3. Insufficient Request Validation (MEDIUM)Location: if (env.SLACK_SIGNING_SECRET) {
if (!verifySlackRequest(env.SLACK_SIGNING_SECRET, body, timestamp, signature)) {
// ... error handling
}
}Issues:
Recommendation:
🏗️ Architectural Concerns4. Local Database Implementation is Over-Engineered (MEDIUM)Location: The local database implementation (574+ lines) creates unnecessary complexity: Issues:
Recommendation:
5. Work Apps Architecture Needs Extension Points (LOW)Location: Current implementation hardcodes all future integrations: export const WORK_APPS_CONFIG: Record<WorkAppId, Omit<WorkApp, 'status' | 'installUrl' | 'dashboardUrl'>> = {
slack: { /* config */ },
github: { /* config */ },
discord: { /* config */ },
// ... all future apps hardcoded
};Recommendation:
✅ Positive AspectsStrong Error HandlingThe Slack API client includes comprehensive error handling with specific error types and user-friendly messages. Modular Architecture FoundationThe Work Apps concept provides a good foundation for future integrations, though it needs refinement for extensibility. Comprehensive State ManagementGood use of TanStack Query for server state and Zustand for client state, following React best practices. 🧪 Testing GapsCritical Missing: No tests found for any Slack integration code. For a feature of this complexity and security sensitivity, comprehensive testing is essential: Required Tests:
📋 Required Actions Before MergeHigh Priority (Must Fix)
Medium Priority (Should Fix)
Low Priority (Consider)
🎯 VerdictThis PR introduces valuable functionality but has critical security issues that must be resolved before merging. The session token storage pattern is particularly concerning and could expose user authentication data. The architectural foundation is solid, but the implementation needs security hardening and testing before production deployment. |
Extract Slack integration into a modular work-apps domain for better
separation of concerns and future extractability. This sets up a clean
boundary for third-party integrations that can be easily exported.
Changes:
- Create new work-apps domain at agents-api/src/domains/work-apps/
- Move Slack routes from /manage/slack/* to /work-apps/slack/*
- Update OAuth redirect URIs to use /work-apps/slack/oauth_redirect
- Update frontend slack-api.ts to call /work-apps/slack/* endpoints
- Export workAppsRoutes from domains barrel file
API endpoints are now:
- /work-apps/slack/install
- /work-apps/slack/connect
- /work-apps/slack/commands
- /work-apps/slack/status
- etc.
…default agent @mention improvements: - Add real-time streaming responses using Slack's chatStream API - Support thread context inference - mentioning bot in thread without query uses thread history as context - Fix authentication by using API key pattern instead of session token - Filter out data-operation metadata events from streamed responses - Filter bot messages to prevent event loops - Add session token validation with user-friendly reconnect prompts Default agent persistence: - Persist workspace default agent in Nango metadata (survives restarts) - Fall back to in-memory cache for performance - Add getWorkspaceDefaultAgentFromNango and setWorkspaceDefaultAgent Slash commands: - Add /inkeep run [agent] [question] command - Add /inkeep settings for personal default agent - Add /inkeep list to show available agents - Add /inkeep help with comprehensive command reference Other: - Add legacy route mount at /manage/slack for backwards compatibility - Export DefaultAgentConfig type from nango services
… types Update tsconfig.json exclude to be more specific, excluding .next/cache, .next/server, and .next/static instead of the entire .next directory. This allows .next/types/routes.d.ts to be processed, providing global PageProps, LayoutProps, and RouteContext types.
b15e039 to
5e61b1d
Compare
Slack integration for Inkeep Agents with workspace installation, user account linking via Nango, and slash command support. I added a modular "Work Apps" architecture for future integrations.
API Authentication Pattern: Session Token Flow
How are authenticated API calls are made from Slack commands? We are using the user's session token:
Flow Overview
Implementation
Frontend captures session token during linking (
slack-provider.tsx):API client uses Bearer token for requests (
api-client.ts):Commands use the client (
commands/index.ts):Features
Test Plan
[ ] Install Slack app to workspace via OAuth
[ ] Link user account through Nango flow
[ ] Verify /inkeep list returns projects using session token auth
[ ] Test session refresh on reconnection
[ ] Verify disconnect clears connection properly