Slack chat bot written in Rust that allows the user to interact with a large language model.

Overview

A Slack chat bot written in Rust that allows the user to interact with a large language model.

screenshot

Creating an App on Slack, first steps

  • Go to https://api.slack.com/apps and create a new app from scratch.

  • Navigate to "OAuth & Permissions" (https://api.slack.com/apps/YOURAPPID/oauth). Go to section "Bot Token Scopes", click on "Add an Oauth Scope", select scopes "app_mentions:read", "chat:write", "files:write", "im:history". Then click on "install to Workspace". You will obtain the "Bot User OAuth Token" on this page then.

  • Navigate to "Basic Information" (https://api.slack.com/apps/YOURAPPID/general). Here you will obtain the "Signing secret".

  • Now you need to deploy your app following the steps of the next section before continuing with the Slack app configuration.

Configuring, compiling and running

Generate a token from Hugging Face at (https://huggingface.co/settings/tokens).

Create an .env file at the root of the repository (same folder as the Cargo.toml file) with:

    SLACK_OAUTH_TOKEN="bot_user_oauth_token_from_previous_step"
    SLACK_SIGNING_SECRET="signing_secret_from_previous_step"
    LLM_API_TOKEN="api_key_from_huggingface"
    DATABASE_URL="sqlite://db/db.sqlite3"

and run without Docker compose:

docker compose build && docker compose up

or with Docker, but without Docker compose:

docker build . -t rust-slackbot-llm && docker run --rm -it -v $(pwd)/.env:/app/.env rust-slackbot-llm

or with plain cargo:

cargo run

Public IP address

When you run the App, it's exposed via port 51005 and on HTTP only, therefore, it's recommend that install Nginx and add the following configuration (probably at /etc/nginx/sites-available/default) to:

    server {
        server_name your_domain_here.com;
        location / {
            proxy_pass http://127.0.0.1:51005;
            proxy_set_header Host $host;
        }
        listen 80;
    }

And then (after pointing your DNS to your domain) run sudo certbot --nginx.

If you don't own a domain, you might wanna try your luck with https://nip.io/.

You also need to have a reacheable IP address for Slack to deliver the payloads to your bot. Sadly this is not possible with many residential internet ISPs which now use carrier grade NAT, so as a work around you can get a simple machine on a cloud provider (e.g.: AFAIK, Google Cloud has a always free tier, use at your own risk) and run the app there or run at your local machine and redirect the port to cloud machine using SSH ssh your_domain_here.com -R 127.0.0.1:51005:127.0.0.1:51005.

Concluding the deployment of your Slack app

  • Navigate to "Event Subscriptions" (https://api.slack.com/apps/YOURAPPID/event-subscriptions). On the requested URL section, fill in https://your_domain_here.com/v1/slack_events and if everything was properly configured in the previous step, you should receive a "verified" status.

  • On "Subscribe to bot events", add scopes "app_mention" and "message.im" and click on "Save changes".

  • A yellow upper box will show up requesting you the reinstall the App, proceed with that.

  • Go to App Home (https://api.slack.com/apps/YOURAPPID/app-home) and check the box "Allow users to send Slash commands and messages from the messages tab".

An extra: plotting

If configured everything correctly, you should have you also have support for plotting out of the box. Just send plot as message to chat bot to get an example:

screenshot
You might also like...
Raw C Shell: interact with your operating system using raw C code, because why not?
Raw C Shell: interact with your operating system using raw C code, because why not?

rcsh Raw C Shell is a minimalist shell with no built in commands. You write entirely in C code and use return; to execute your code. Unlike that silly

Mafa is a command-line tool that helps people interact with online websites in a terminal(tty).
Mafa is a command-line tool that helps people interact with online websites in a terminal(tty).

Table of Contents A Small Demo Installation Prerequisite Option 1: Cargo install (recommended) Option 2: Build from source Option 3: Prebuilt binaries

Mafa is a command-line tool that helps people interact with online websites in a terminal(tty).
Mafa is a command-line tool that helps people interact with online websites in a terminal(tty).

A Small Demo Installation Prerequisite Option 1: Cargo install (recommended) Option 2: Build from source Option 3: Prebuilt binaries Mafa is for me? W

 (Pre-Release Software) Secure, Encrypted, P2P chat written atop Warp, IPFS, LibP2P, Dioxus and many more awesome projects and protocols.
(Pre-Release Software) Secure, Encrypted, P2P chat written atop Warp, IPFS, LibP2P, Dioxus and many more awesome projects and protocols.

Uplink Privacy First, Modular, P2P messaging client built atop Warp. Uplink is written in pure Rust with a UI in Dioxus (which is also written in Rust

ChatGPT-Code-Review is a Rust application that uses the OpenAI GPT-3.5 language model to review code

ChatGPT-Code-Review is a Rust application that uses the OpenAI GPT-3.5 language model to review code. It accepts a local path to a folder containing code, and generates a review for each file in the folder and its subdirectories.

A rust crate for rendering large text to the terminal using font8x8 and ratatui.
A rust crate for rendering large text to the terminal using font8x8 and ratatui.

tui-big-text tui-big-text is a rust crate that renders large pixel text as a ratatui widget using the glyphs from the font8x8 crate. Installation carg

An ultra-fast CLI app that fixes JSON files in large codebase or folders

minosse An ultra fast CLI app that fixes json files in large codebase or folders USAGE: minosse [OPTIONS] input-dir FLAGS: -h, --help Prints

Codemod - Codemod is a tool/library to assist you with large-scale codebase refactors that can be partially automated but still require human oversight and occasional intervention

Codemod - Codemod is a tool/library to assist you with large-scale codebase refactors that can be partially automated but still require human oversight and occasional intervention. Codemod was developed at Facebook and released as open source.

Framework for large distributed pipelines
Framework for large distributed pipelines

Rain Rain is an open-source distributed computational framework for processing of large-scale task-based pipelines. Rain aims to lower the entry barri

Owner
Marco Inacio
Marco Inacio
Tight Model format is a lossy 3D model format focused on reducing file size as much as posible without decreasing visual quality of the viewed model or read speeds.

What is Tight Model Format The main goal of the tmf project is to provide a way to save 3D game assets compressed in such a way, that there are no not

null 59 Mar 6, 2023
Attempt to summarize text from `stdin`, using a large language model (locally and offline), to `stdout`

summarize-cli Attempt to summarize text from stdin, using a large language model (locally and offline), to stdout. cargo build --release target/releas

null 4 Aug 23, 2023
Cloud Native Buildpack that builds an OCI image with Ollama and a large language model.

Ollama Cloud Native Buildpack This buildpack builds an OCI image with Ollama and a large language model. Configure your model by an Ollama Modelfile o

Manuel Fuchs 3 Mar 19, 2024
This is a simple command-line interface tool that allows you to interact with ChatGPT from OpenAI or Azure.

HeyGPT This is a simple command-line interface tool that allows you to interact with ChatGPT from OpenAI or Azure. You can use it to: Chat with ChatGP

Philip 5 Mar 28, 2023
๐Ÿ”” CLI utility to send notifications to Slack via integration webhooks

Slack notifier Just a simple CLI tool to send notifications to Slack. Please note that this project is just a playground to start learning Rust, it is

Green.Mod 2 May 21, 2022
auto-rust is an experimental project that aims to automatically generate Rust code with LLM (Large Language Models) during compilation, utilizing procedural macros.

Auto Rust auto-rust is an experimental project that aims to automatically generate Rust code with LLM (Large Language Models) during compilation, util

Minsky 6 May 14, 2023
๐Ÿฆ€Rust + Large Language Models - Make AI Services Freely and Easily. Inspired by LangChain

llmchain: Modern Data Transformations with LLM ?? + Large Language Models, inspired by LangChain. Features Models: LLMs & Chat Models & Embedding Mode

Shafish Labs 63 Jun 22, 2023
A rust library to interact with the Vyper compiler!

vyper-rs A rust library to interact with the Vyper compiler! Dependencies Please ensure that the Vyper compiler is installed and added to PATH! To ins

crypdough.eth 21 Jul 24, 2023
Yet another command-line chat GPT frontend written in Rust.

gpterm Yet another command-line chat GPT frontend written in Rust. Features Stream output with typing effect Store chat messages/history Context aware

Makis Christou 22 May 4, 2023
๐Ÿ’ป Interact with Hop in your terminal

Hop CLI The Hop CLI allows you to interface with Hop services through your command line. It can be used as a replacement for the Console. Installation

Hop 56 Dec 15, 2022