Upsy is an open source Slack bot that remembers your conversations to provide fast, accurate answers whenever you have a question.
We've chosen the following tech stack because it works reliably out of the box. Because of the modular design, you can completely customize any part of Upsy to fit your needs.
- Backend: Node.js
- AI Integration: OpenAI API
- Data Storage: Upstash Vector & Upstash Redis
- LLM Orchestration: Langchain
- Deployment Option: Fly.io
No matter how old or buried within a channel the answer to your question might be, Upsy will find relevant messages from its memory and respond immediately and only if it's sure of the answer. Upsy stores only data you explicitly allow it to process by adding it to specific channels and stores all data in your own database.
🧠 Unified Memory: Upsy's memory works across channels you've added Upsy to. Get to-the-point answers even if the corresponding information is buried deep within another channel.
🔒 Privacy Preserved: Upsy only accesses data from the channel you add it to. It is open source and self-hosted. The communication between the Upsy server and Slack is encrypted.
⌚ Works Retrospectively: Add Upsy to any channel, and it will store the channel history in its memory. The bot jumps in only if someone asks a question it can find a relevant answer to or if someone mentions Upsy in their message.
💡 Add Data via DMs: Communicate with Upsy via Direct Messages (DMs). You can even add new information to Upsy’s memory by interacting in DMs that it can then use to answer questions in any other channel.
To get started, you'll need an OpenAI, Fly and Upstash accounts. After signing in to Upstash, create one Redis and one Vector database - these will later contain your Slack data. Unless you change the default configuration, choose a dimension of 1536 for your Upstash Vector database. Simply creating these databases is enough for now; we'll get back to this step in the setup.
To create a new Slack app in your team account, go to https://api.slack.com/apps, click Create New App
, then select from an app manifest
. After selecting your workspace, copy and paste the below configuration into the JSON editor:
App manifest
{
"display_information": {
"name": "upsy",
"description": "Your new mate on Slack. Powered by AI.",
"background_color": "#000000"
},
"features": {
"bot_user": {
"display_name": "upsy",
"always_online": true
}
},
"oauth_config": {
"scopes": {
"bot": [
"app_mentions:read",
"channels:history",
"channels:join",
"channels:read",
"chat:write",
"groups:history",
"im:history",
"im:read",
"im:write",
"im:write.invites",
"mpim:history",
"reactions:read",
"reactions:write",
"users:read",
"groups:read",
"mpim:read"
]
}
},
"settings": {
"event_subscriptions": {
"request_url": "https://example.com/",
"bot_events": [
"member_joined_channel",
"member_left_channel",
"message.channels",
"message.groups",
"message.im",
"message.mpim"
]
},
"org_deploy_enabled": false,
"socket_mode_enabled": false,
"token_rotation_enabled": false
}
}
After clicking on Create:
- Go to OAuth & Permissions in the App dashboard
- Click
Install to Workspace
and install.
One last step is to enable Upsy for direct messages. Go to your Features
> App Home
and set the checkbox for "Allow users to send Slash commands and messages from the messages tab".
Congratulations, you've created your Slack app! 🎉 Keep this dashboard open because we'll need the generated Slack tokens in the next step.
The backend is a simple Node application that runs Slack's Bolt SDK. We will deploy it on Fly, but it can be hosted anywhere that supports Node.
Clone the Upsy repository:
git clone [email protected]:upstash/upsy.git
Rename fly.toml.example
to fly.toml
and set the environment variables correctly.
[env]
# Retrieved here: https://platform.openai.com/api-keys
OPENAI_API_KEY=
# Retrieved here: https://console.upstash.com/
UPSTASH_REDIS_REST_URL=
UPSTASH_REDIS_REST_TOKEN=
# Retrieved here: https://console.upstash.com/vector
UPSTASH_VECTOR_REST_URL=
UPSTASH_VECTOR_REST_TOKEN=
# Retrieved from the Slack dashboard we just created.
# SLACK_ACCESS_TOKEN should start with xoxb-. `Features > OAuth & Permissions`
# SLACK_SIGNING_SECRET `Settings > Basic Information`
SLACK_ACCESS_TOKEN=
SLACK_SIGNING_SECRET=
First create a Fly app by running fly launch
. Say Yes
to the question Would you like to copy its configuration to the new app?
Deploy your app to Fly.io by running the below command:
fly deploy
Once we deployed our project, Fly will give us the URL for this deployment. Copy the URL of your Fly app, i.e., https://your-upsy.fly.dev and head to your Slack dashboard. Find the Features > Event Subscriptions
menu on the sidebar and enter the URL appending 'slack/events' to Request URL input field in Slack. The final result looks like this:
https://your-upsy.fly.dev/slack/events
and you should see the message Verified
on Slack dashboard.
Fly.io allows you to see runtime logs in case you're curious about what Upsy is doing under the hood when a message on Slack comes in! Simply run:
fly logs