• Stars
    star
    190
  • Rank 203,739 (Top 5 %)
  • Language
    TypeScript
  • Created 10 months ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Your new mate on Discord and Slack. Powered by AI.

Upsy: Your new mate on Slack. Powered by AI.

Note

This project is a Community Project.

The project is maintained and supported by the community. Upstash may contribute but does not officially support or assume responsibility for it.

Upsy is an open source Slack bot that remembers your conversations to provide fast, accurate answers whenever you have a question.

  1. Tech Stack
  2. Features
  3. Setup
  4. Testing
  5. Troubleshooting
  6. How Upsy Works
  7. Development
  8. Contributing

Tech Stack

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.

Features

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.

Setup

1. Getting Started

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.

2. Slack 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
  }
}

Click on Create.

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.

3. Backend Deployment

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.

3.1. Fly.io Deployment

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

Now we are ready to test Upsy!

Testing

Once you complete the deployment step, you can install it to your Slack workspace. If Upsy looks unresponsive check the troubleshooting section below.

The simplest way to test the integration is by asking Upsy questions via direct messages or adding it to a channel with prior messages. It'll jump into the conversation to answer questions if it's confident in the answer or will respond if you mention it directly.

🔥 Pro Tip

Once you add Upsy to a channel or send it a direct message, check your Upstash Vector data browser. You should see the data appearing here.

In addition to keeping a long history of the entire chat to draw answers from, Upsy also keeps a short-term memory to provide fast, accurate responses to recent chat topics. Test this by messaging a number and then ask to increment that number :)

Because we've built Upsy to work cross-channel with unified memory, you can always add additional information via direct messages, which it then uses to answer questions in channels and vice-versa.

Troubleshooting

DM Issues: If you see "Sending messages to this app has been turned off" in the DM screen of Upsy, try restarting your Slack. If that doesn't resolve the issue, you can remove Upsy from your workspace, reinstall it, and approve the requested scopes.

Non-responsiveness: If Upsy appears online but does not answer back:

  • Check the runtime logs in the Fly.io.
  • Verify that your Slack token and signing keys are correct

Memory not working: If Upsy answers but is not aware of the channel history to answer your questions:

  • Verify that Upsy has indexed the chat history via the Upstash Vector dashboard, where you should see this data appearing
  • Check the runtime logs on the Fly.io after adding it to a channel; you should see logs indicating that the indexing process has started

Fly deployment issue If the fly deploy command looks stuck, try fly deploy --local-only which builds the image locally then push it to the fly.

How Upsy Works

Upsy is an open-source project. You have complete control over the code, and all information Upsy retrieves is stored securely in your own Upstash database. We've chosen convenient defaults that work great out of the box, but the code is fully customizable for you to tailor Upsy to your needs. Here's an overview of how it works under the hood:



And here's how Upsy knows which messages to store and which ones to answer:

Development

🔥 Pro Tip

Enable the Socket mode in your Slack dashboard. This mode allows your app to use the Events API without exposing a public HTTP Request URL.

To get started in development for a Fly.io deployment, use the root folder:

   npm install
   node index.js

Contributing

Upsy is a work in progress, so we'll add more features and improve the current ones. We've collected a few ideas we believe would make Upsy an even more helpful companion:

  • Add documents to the context so that Upsy can memorize and use them as context.
  • Add a web interface to manage Upsy so you can add new information to Upsy’s memory via the web interface and configure Upsy’s behavior
  • More proactive Upsy - Upsy will initiate conversations with you or respond to welcome, birthday, etc. messages
  • Ability to choose personal characters for Upsy, such as friendlier, funnier, or more serious

If one of these ideas sounds like something you'd like to work on, contributions are very welcome! You can contribute by adding new features, fixing bugs, improving the documentation, writing blog posts, or by sharing Upsy on social media.

More Repositories

1

ratelimit-js

Rate limiting library for serverless runtimes
TypeScript
1,633
star
2

redis-js

HTTP based Redis Client for Serverless and Edge Functions
TypeScript
655
star
3

semantic-cache

A fuzzy key value store based on semantic similarity rather lexical equality.
TypeScript
184
star
4

roadmap

Build and deploy a roadmap voting app for your project/product.
TypeScript
169
star
5

rag-chat

Batteries included SDK for RAG development.
TypeScript
148
star
6

qstash-js

Message queue for serverless
TypeScript
145
star
7

degree-guru

AI chatbot for expert answers on university degrees
TypeScript
128
star
8

redis-examples

Sample applications implemented with serverless Redis
JavaScript
126
star
9

claps

Adds clap button (like medium) to any page for your Next.js apps.
TypeScript
104
star
10

kafka-js

HTTP based Kafka Client for Serverless and Edge Functions
TypeScript
100
star
11

feedback

Feedback Component for Next.js
TypeScript
90
star
12

queue

SQS like stream based queue on top of Redis
TypeScript
81
star
13

edge-flags

Feature flags for edge functions
TypeScript
69
star
14

faq-generator

Generate FAQ for your documentation. Powered by OpenAI, Vercel and Upstash.
TypeScript
59
star
15

chatbox

TypeScript
58
star
16

vector-js

Upstash Vector JS SDK
TypeScript
39
star
17

hackerdigest

Stay in the loop without the time sink. 🚀
TypeScript
36
star
18

examples

Examples how to use Upstash with various tech
TypeScript
29
star
19

query

Secondary indexing and query capabilities for Upstash Redis
TypeScript
29
star
20

waiting-room

A Waiting Room for your website with Cloudflare Workers and Serverless Redis
JavaScript
28
star
21

latency-comparison

Latency Comparison among Serverless Databases: DynamoDB, FaunaDB, MongoDB, Cassandra, Firestore and Upstash
JavaScript
26
star
22

redis-py

HTTP based Python Redis Client for Serverless and Edge Functions
Python
24
star
23

terraform-provider-upstash

Go
22
star
24

cli

Upstash CLI for serverless Redis and Kafka
TypeScript
20
star
25

ratelimit-py

Rate limiting library for serverless runtimes in Python
Python
20
star
26

react-ui

Various react components from our console
TypeScript
19
star
27

lock

TypeScript
18
star
28

core-analytics

Low level analytics building blocks for redis
TypeScript
15
star
29

vercel-note-taker-slackbot

Serverless Slackbot with Vercel
JavaScript
15
star
30

qstash-examples

TypeScript
11
star
31

qstash-py

Python SDK for Upstash QStash
Python
11
star
32

pulumi-upstash

Python
10
star
33

docs

Upstash documentation
MDX
9
star
34

vector-py

Upstash Vector Python SDK
Python
9
star
35

semantic-cache-py

A fuzzy key value store based on semantic similarity rather lexical equality. (python version)
Python
8
star
36

upstash-web

MDX
8
star
37

kafka-examples

Sample applications implemented with Serverless Kafka
JavaScript
8
star
38

stylegenie

JavaScript
7
star
39

serverless-birthday-slackbot

Python
6
star
40

vector-go

Upstash Vector Golang SDK
Go
6
star
41

qstash-go

Go SDK for Upstash QStash
Go
5
star
42

jstack

Confidently ship high-performance, low-cost Next.js apps
TypeScript
4
star
43

rdb

RDB file parser
Go
4
star
44

upstash-cloudformation

Cloudformation private types to provision Upstash infrastructure
TypeScript
3
star
45

upstash-heroku-todo-app

JavaScript
3
star
46

upstats

TypeScript
3
star
47

edge-caching-benchmark

JavaScript
2
star
48

sponsorship

1
star
49

purple-squirrel

TypeScript
1
star
50

transcriber

TypeScript
1
star
51

next-template

TypeScript
1
star
52

redis-connection-benchmark

benchmark the overhead of a Redis connection
JavaScript
1
star
53

QuickApply

A chatbot which will welcome job candidates, do prescreening and answer questions.
JavaScript
1
star
54

kafka-connectors

Kafka Connect with Upstash Kafka®
Shell
1
star
55

issues

Issue Tracker for Upstash
1
star