Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5de4380
Initial commit
manfredcalvo Sep 2, 2025
2d7e06b
Adding all the logic to create a bot azure service that interacts wit…
manfredcalvo Sep 8, 2025
9e43efd
Update README to clarify that we are using auth on behalf of the user.
manfredcalvo Sep 9, 2025
c7e8c82
Update README to clarify some steps and set expectations with the users.
manfredcalvo Sep 9, 2025
eac9cda
Updating databricks client to manage different type of agents in Data…
manfredcalvo Oct 10, 2025
1890654
Merge pull request #1 from manfredcalvo/genie_connection
manfredcalvo Oct 10, 2025
fc56397
Updating appManifest for teams app and adjusting app to work correctl…
manfredcalvo Oct 17, 2025
56799f8
Updating appManifest scopes
manfredcalvo Oct 17, 2025
ad49a74
Merge pull request #2 from manfredcalvo/update_manifest
manfredcalvo Oct 17, 2025
accc0f2
Move existing bot code to azure-bot
smurching Oct 24, 2025
57a252b
Initial slackbot code
smurching Oct 24, 2025
57190a8
Switch to socket mode, but it doesn't work
smurching Oct 24, 2025
8fdfd52
Bot replies work, but oauth flow does not
smurching Oct 24, 2025
4742f75
Basic POC works, just has some broken response parsing
smurching Oct 24, 2025
3914e20
Implement ephemeral responses with share button and auto-respond afte…
smurching Oct 29, 2025
edda0a6
Add rich UX features: reactions, status messages, and share/generate …
smurching Oct 29, 2025
2ddd17a
Clean up UX: remove duplicate messages, auto-delete status, instant b…
smurching Oct 29, 2025
d51d7e0
WIP
smurching Oct 29, 2025
a480367
Show OAuth prompt in thread context instead of channel
smurching Oct 30, 2025
833aef6
Improve button UX and add dismiss functionality
smurching Oct 30, 2025
41b284e
Fix ephemeral message dismissal using response_url
smurching Oct 30, 2025
2a549c9
WIP updating slackbot
smurching Nov 3, 2025
1953765
Remove HTTP mode and add PR documentation
smurching Nov 3, 2025
a91724e
Merge branch 'main' into slackbot
smurching Nov 3, 2025
8de87a2
Merge branch 'main' into slackbot
smurching Nov 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 172 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,174 @@
*conf*.json
.DS_Store
__pycache__
.idea/
.idea
pycache
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# Visual Studio Code
.vscode/

# IntelliJ
.idea/
ml-models.iws
ml-models.iml
ml-models.ipr

.DS_Store
.databricks
.gradio

# Configuration files
*conf*.json

# Node.js / Next.js / Web development
cookies.txt
node_modules
.pnp
.pnp.js
coverage
.next/
out/
*.pem
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
.env.local
*.log
.env.development.local
.env.test.local
.env.production.local
.turbo
.vercel
.env*.local

# Playwright testing
/test-results/
/playwright-report/
/blob-report/
/playwright/*
tsconfig.tsbuildinfo
78 changes: 78 additions & 0 deletions PR_DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Add Slack Bot with Glean-like UX and OAuth Authentication

## Overview

This PR introduces a Slack bot that provides personalized, authenticated access to Databricks AI agents. The bot implements a Glean-like UX featuring ephemeral messages, sharing capabilities, and multi-user support.

## Key Features

- **Glean-like UX**: Bot responds privately to users via ephemeral messages, with options to share responses publicly or dismiss them
- **OAuth Authentication**: Seamless Databricks OAuth flow with automatic response after authentication completes
- **Multi-user Support**: Each user authenticates independently and receives personalized responses
- **Thread-based Conversations**: All interactions happen in threads for clean channel organization
- **Interactive Buttons**:
- "Post in thread" - Share private response publicly
- "Dismiss" - Remove ephemeral message
- "Generate my own answer" - Allow other users to get their own personalized responses
- **Visual Feedback**: Eyes emoji reaction on message receipt, white checkmark when shared
- **Auto-respond After Auth**: Bot stores pending messages and automatically responds after OAuth completes

## Architecture

The bot uses Socket Mode for development and consists of:

- **app_socket.py**: Main Slack app with event handlers and button actions
- **oauth_server.py**: OAuth callback handler running on port 8000
- **handlers/**: Message processing and authentication logic
- **state/**: In-memory state management (can be replaced with Redis/DynamoDB for production)
- **client/**: Databricks API client for agent calls

## User Flow

1. User mentions bot: `@DatabricksBot hello`
2. Bot reacts with 👀 emoji for immediate acknowledgment
3. **First-time users**: Bot sends ephemeral OAuth prompt in thread
4. **After OAuth or for returning users**: Bot sends "Working on it..." status message
5. Bot sends ephemeral response with "Post in thread" and "Dismiss" buttons (visible only to requesting user)
6. Bot posts public message with "Generate my own answer" button for other users
7. When shared: Ephemeral message disappears, response posted publicly, ✅ reaction added to original message

## Technical Highlights

- **Ephemeral Messages**: Uses `chat_postEphemeral` for private responses
- **Response URL Pattern**: Uses `respond(delete_original=True)` for dismissing ephemeral messages
- **Event Deduplication**: Properly handles both `app_mention` and `message` events without duplication
- **PKCE OAuth Flow**: Secure OAuth implementation with proper state management
- **Conversation History**: Per-thread history for context-aware responses
- **Regex Action Patterns**: Dynamic action_id matching for button interactions

## Testing

Run the bot locally:
```bash
cd slack-bot
python app_socket.py
```

The bot will:
- Connect to Slack via Socket Mode
- Start OAuth callback server on port 8000
- Log all events and interactions to console

## Future Enhancements

- Replace in-memory state storage with Redis/DynamoDB for production
- Implement rate limiting and request validation
- Add token encryption at rest
- Horizontal scaling with HTTP mode and load balancer
- Structured logging with correlation IDs
- Metrics and monitoring

## Related Documentation

See `slack-bot/README.md` for:
- Complete setup instructions
- Slack app configuration
- Environment variables
- Development guide
- Troubleshooting tips
Loading