/bot-chan

A minimum framework of a Slack AI Chatbot

Primary LanguagePythonApache License 2.0Apache-2.0

Introduction

Welcome to Bot-chan! This is a minimal but fully functional framework for a Slack AI Chatbot that is easy setup and customize.

We made Botchan open source to help those who want to create their own chatbot application but don't know where to start. You can use Botchan as a personal chatbot on your Slack workspace, or develop it into a product or something even bigger.

Spotlights

As a Slack Chatbot application, Botchan has the following features.

  • Reposonse to IM(direct message) or @ mentioned in public channels.
  • Engage in interactive conversions.
  • Retrieval-augmented Generation.
  • Index knowledge from text messages, web base url and uploaded PDF.
  • Capable of using tools: like proactive invlove Google search and Wiki lookup.

Learn knowledge from PDF Learn from WEB url Learn from pinned messages
Screenshot 2024-03-04 at 2 42 28 PM

Screenshot 2024-03-04 at 9 38 54 AM

Screenshot 2024-03-04 at 9 39 02 AM

rag1

rag2

rag3

Context awareness Help summary messages or posts in place Help writing code
Screenshot 2023-04-27 at 11 46 44 AM Screenshot 2023-04-27 at 11 51 34 AM Screenshot 2023-04-27 at 11 58 07 AM
Looking math with LLM Checing Arxiv Doing google search
Screenshot 2023-09-15 at 12 02 42 PM Screenshot 2023-09-15 at 11 59 44 AM Screenshot 2023-09-15 at 11 58 59 AM

Setup

Bot-chan requires three tokens to function properly, which can be added to the env.dev file. Please rename the env.dev.template file as env.dev and insert the required tokens.

To obtain the necessary Slack tokens, please follow the instructions provided in the setup_slack_app.md guide. For OpenAI API Token, simply generate a token on their developer page.

Requirements env.

We use Docker to run the application.

But if you prefer, you may choose to install requirements without Docker. Bot-chan utilizes python3.9 and poetry 1.2+. You can install these dependencies using any preferred method, but we recommend the virtual env management tool ASDF.

Development

To start developing with Bot-chan, run the command docker-compose up --build -d. Logs can be reviewed with docker-compose logs.

Deployment

Botchan is fully functional and running on your local dev machine or laptop. If you are looking at optional to turn it into a 24/7 online bot here are some suggestions.

  • Deploying the application in a cloud Kubernetes environment is recommended since it is already containerized.
  • Deploy on serverless env like Heroku.

Developer guide

Tooling

Run make to see help tips

===== All tasks =====
build                build image
server               start prod server
server-dev           start dev server
bash                 Connect to a bash within the docker image
ci-bash              Connect to a bash within the tool image(faster), for running task like `poetry lock`
lint                 Lint the code folder
fmt                  Apply python formater(will edit the code)

Slack event handling

Botchat only subscribes to Slack message events. If you want to subscribe to other events and do sth cool. Make your change in the app.py.

Security and privacy reminder.

  • It is essential to be aware that if you need to log chat messages, the author suggests only doing so when the debug flag is on.
  • The repository is not designed to be secure for production use, so use it at your own risk.