I built this out of pure laziness — I was tired of formatting my messages manually every single time, so I automated it into my slack workspace ;). (Will be working on context of previous chats in a session soon.)
Local Slack bot that reformats messages into your personal tone, running entirely on-device using MLX and a quantized Mistral 7B model.
- Personal tone rewriter: Takes any Slack message and rewrites it to match your configured style.
- Two entry points:
/fmtslash command (ephemeral response).- DM the bot directly and it replies with a reformatted version.
- Local-only LLM: Uses
mlx-community/Mistral-7B-Instruct-v0.3-4bitviamlx-lm. - Configurable style: Tune persona, tone, and examples in
config/style.yaml.
src/slack_tone_bot/— bot code (LLM wrapper, formatter, Slack Bolt app, entrypoint).config/style.yaml— tone/style configuration (persona, sliders, guidelines, examples)..env— Slack credentials and optional overrides (not committed; use.env.exampleas a template).
Entrypoint:
- CLI script:
slack-tone-bot(viapyproject.toml). - Module:
python -m slack_tone_bot.main
- Python 3.11+
- macOS with Apple Silicon recommended (for MLX performance)
- Slack app with:
- Bot token (
SLACK_BOT_TOKEN) - App-level token (
SLACK_APP_TOKEN, with connections:write for Socket Mode)
- Bot token (
Python dependencies are managed via pyproject.toml and include:
slack-bolt,slack-sdkmlx-lmpydanticPyYAMLpython-dotenv
git clone <your-repo-url> slack-tone-bot
cd slack-tone-bot
python -m venv .venv
source .venv/bin/activatepip install --upgrade pip
pip install -e .For src/ layout projects like this one, using pip install -e . ensures slack_tone_bot is importable without manually tweaking PYTHONPATH.
Create a .env file in the project root (you can copy .env.example):
cp .env.example .envThen fill in at least:
SLACK_BOT_TOKEN=xoxb-...
SLACK_APP_TOKEN=xapp-...Optional overrides:
MODEL_NAME— MLX model name (default:mlx-community/Mistral-7B-Instruct-v0.3-4bit)STYLE_CONFIG_PATH— path to a custom style YAML (default:config/style.yaml)
Edit config/style.yaml to match your personal style:
- persona — short description of how you communicate.
- tone — sliders for formality, warmth, humor, energy, emoji usage, capitalization, sentence style.
- guidelines — bullet rules like “keep messages short”, “avoid jargon”.
- examples — input/output pairs the model should mimic.
Activate your virtualenv (if not already):
source .venv/bin/activateThen start the bot:
python -m slack_tone_bot.mainOn first run, MLX will download the model weights and initialize the tokenizer, which can take 10–20 seconds.
If the Slack tokens or style config path are missing/invalid, the process will log an error and exit.
-
Slash command: In any channel or DM where the bot is installed, run:
/fmt I think we should maybe delay the deploy a bit until we understand the metrics betterThe bot replies ephemerally with a reformatted version in your tone.
-
Direct messages: DM the bot any text, and it will respond with a rewritten version:
hey can we sync on this later this week→ reformatted reply in your configured style.
- The system prompt is built from
config/style.yamlviabuild_system_promptand combined with the user message before sending to the LLM. - Inference is done through a small
LocalLLMwrapper (mlx_lm.load+mlx_lm.generate) with a per-instance lock for basic thread safety. - The Slack app runs in Socket Mode via
slack_bolt’sSocketModeHandler, with:/fmtcommand for explicit rewrites.messageevent handler for DMs.
-
Imports fail (
ModuleNotFoundError: slack_tone_bot)- Ensure you ran
pip install -e .inside the virtualenv. - Or, as a quick check:
PYTHONPATH=src python -c "from slack_tone_bot.config import load_style_config; print('ok')"
- Ensure you ran
-
Bot exits with “Missing SLACK_BOT_TOKEN or SLACK_APP_TOKEN”
- Verify
.envexists at the project root and the variables are set.
- Verify
-
Slow first run
- Model download and initialization are expected to be slow the first time. Subsequent runs should be faster.
-
Activate the venv and run:
source .venv/bin/activate python -m slack_tone_bot.main -
To quickly verify that imports and config loading work:
python -c "from slack_tone_bot.config import load_style_config; print('ok')"