Integrate slackbot with baml client and sage backend #2308
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Template
Thanks for taking the time to fill out this pull request!
Issue Reference
Please link to any related issues
Changes
Please describe the changes proposed in this pull request
This PR enables a Slackbot by adding a new Slack Events API endpoint to
sage-backend
and making the backend more resilient to environment-dependent initialization at build time.Key changes include:
/api/slack/events
to handle Slackapp_mention
and direct messages, including signature verification and URL challenges.submitQuery
action to process user requests and respond in-thread.OpenAI
,Pinecone
,NotionLogger
, andSlackFeedbackLogger
clients to be initialized on demand within request handlers. This prevents build-time failures when environment variables are not present.submitQuery
to dynamically importbaml_client
at runtime, providing a fallback mechanism (returning top Pinecone docs) if the client is not available (e.g., if not generated during deployment).Testing
Please describe how you tested these changes
sage-backend
builds successfully and outlined Slack configuration for functional testing)typescript/apps/sage-backend
build environmentScreenshots
If applicable, add screenshots to help explain your changes
[Add screenshots here...]
PR Checklist
Please ensure you've completed these items
Additional Notes
Add any other context about the PR here
How to configure Slack:
app_mention
,message.im
.<your-sage-backend-url>/api/slack/events
.SLACK_SIGNING_SECRET
(from your Slack app settings)SLACK_BOUNDARY_BOT_TOKEN
(the Bot User OAuth Token)OPENAI_API_KEY
PINECONE_API_KEY
NOTION_BOUNDARY_BOT_TOKEN
,NOTION_ASK_BAML_LOGS_DATABASE_ID
@baamy find me a friday project
).submitQuery
function now uses aneval
-based dynamic import forbaml_client
. Ifbaml_client
is not generated and available at runtime, the bot will provide a fallback response using Pinecone search results. Ensurebaml_client
is generated perbaml_src/generators.baml
for full functionality.