Run and Develop Sherpa Slackbot#

The Sherpa repository contains the Sherpa code, including a chatbot built using Flask and Slack. The chatbot leverages the Langchain library for question-answering and text processing tasks. While you can talk to Sherpa in the AISC Slack workspace, if you want to go deeper and contribute to code or run Sherpa in your own Slack workspace then this section is for you.

Video tutorial#

https://youtu.be/HX4lxzBkEoQ?si=6NlQupyZPrM3MHr1

Slackbot Features#

  • Receives events from Slack using SlackEventAdapter.

  • Handles app mentions and responds with a message.

  • Implements a conversational retrieval chain for question-answering.

  • Integrates with OpenAI GPT-3.5 Turbo for language modeling.

  • Utilizes Flask and FastAPI frameworks for building the web server.

Preparation#

  1. Clone the repository:

    git clone
    
  2. Create new app in slack workspace following the setup tutorial

  3. Configuration: Copy the contents of src/.env-sample into your own src/.env file, and then modify your configuration as needed. Remember not to share your private keys with anyone else.

Usage#

Run with docker#

  1. Install Docker and docker-compose locally. Then, run the docker-compose, the setup, the sherpa-ai package, and the local vector database prefilled with the production data.

    cd src/
    docker-compose up -d
    
  2. Expose the server to the internet using a tool like ngrok. This is not required if your server is hosted on a public IP address.

  3. Set up the Slack app’s Event Subscriptions and provide the ngrok URL as the Request URL.

    • NOTE: When adding the url to the Slack app, make sure to append /slack/events at the end as this is the default path used by Slack Bolt.

Run with Virtual Environment#

  1. If you want to use the local vector database, you need to build the vector database with Docker. See Setup Local VectorDB with Production Data for how to do this.

  2. Install conda or miniconda

  3. Create a new conda environment:

    conda create -n slackbot python=3.9
    
  4. Activate the environment:

    conda activate slackbot
    
  5. Install the dependencies of the slackbot:

    • Install dependencies with Poetry (recommended, this will give you the ability to edit the code in sherpa_ai without rebuild)

      cd src
      poetry install
      

      Followed by:

      cd apps/slackapp
      poetry install
      
    • Install dependencies with pip

      cd src/apps/slackapp
      pip install -e .
      
  6. Download the spaCy trained pipeline for English.

    • If you installed dependencies with Poetry in the previous step, run:

      poetry run python -m spacy download en_core_web_sm
      
    • If you installed dependencies with pip, run:

      python -m spacy download en_core_web_sm
      
  7. Run the server:

    • Run with Poetry

      poetry run sherpa_slack
      
    • Run the script directly

      cd src/
      python apps/slackapp/slackapp/bolt_app.py
      

Reference#

Once you have the chatbot running you can start interacting with it by mentioning the app in a Slack channel. See Talk to Sherpa for how to do this.

You can also configure a local vector database for the chatbot to use as a context search tool. See Setup Local VectorDB with Production Data