art by Yookie
Summarize recent messages sent in a group chat.
Defaults to a neutral style, but a custom style can be provided:
/summarize_chat
as a script for a podcast hosted by talking dogs
Attempts to summarize the main content of a web page.
Defaults to a neutral style, but a custom style can be provided:
/summarize_url
https://example.com/news_articleas though it's being presented as evidence in a court case
EXHIBIT A: E. coli Outbreak Linked to McDonald's Quarter Pounders
SUMMARY OF KEY FINDINGS
- Outbreak Overview: An E. coli outbreak linked to McDonald's Quarter Pounders has led to at least 49 illnesses across 10 states, including one death.
- Source of Contamination: A specific ingredient has not been confirmed as the source of the outbreak,
...
Analyze chat members' moods
• Summit: 💻 📊 🤖 / inquisitive, methodical, redundant
• SomeUser: 😍 ✨ 💖 / enamored, zealous, effusive
• AnotherUser: 😩 📉 😒 / despondent, lethargic, irritable
•...
Translates the text to requested language, or English by default.
Alternatively, just reply to any message from the chat and type /translate to translate that message.
Supported languages (using suggested model Aya-23):
Arabic, Chinese (simplified & traditional), Czech, Dutch, English, French, German, Greek, Hebrew, Hindi, Indonesian, Italian, Japanese, Korean, Persian, Polish, Portuguese, Romanian, Russian, Spanish, Turkish, Ukrainian, and Vietnamese
Print statistics about the chat (only knows about stuff that's happened since bot was added to room)
📊 Chat Stats
• Total Messages: 100
• Last 2 days: 40 (40%)
🗣 Top Yappers - 2 days
1. SomeUser / 30 msgs (75%)
2. Summit / 10 msgs (25%)
⭐ Top Yappers - all time
1. Summit / 70 msgs (70%)
2. SomeUser / 30 msgs (30%)
- LLM chatroom summarization
- Aware of reply threads
- Aware of media presence (photo/video/etc) & captions on media
- Aware of current date/time and times of chat messages
- "Vibe check" summary of users' moods
- Translate messages & replied messages between different languages
- Summarize URLs
- If
/summarize_urlcommand is followed by a URL - or
/summarize_urlcommand is a reply to another msg containing a URL
- If
- Talk to the bot - send a message tagging bot using
@itsUsername- Aware of current date/time and times of chat messages
- Nightly auto-delete of all chat data > 2 days old
- Automatically transcribe all voice messages sent in the chat & translate to English
- User settings/personalization
- Allow users to add a very short "bio" to be included with their messages in prompts so LLM functions use correct pronouns etc.
- Jannie features
- Granular authorization: only admins/mods can execute commands, etc.
- Customizable old-message-deletion timeframe
All settings live in encrypted rails credentials (example: credentials.sample.yml):
config/credentials.yml.enc(key:config/master.key) is for dev & testconfig/credentials/production.yml.enc(key:config/credentials/production.key) is for production only
Use separate bot tokens for dev & prod, otherwise the dev env will steal the prod bot's messages.
Works with any OpenAI-compatible LLM API provider (openai.uri_base).
The flake exports a NixOS module (nixosModules.default, see nix/module.nix) that runs the bot in webhook mode:
telegram-dogbot.service- puma server receiving telegram webhooks (runsrails db:prepareon start)telegram-dogbot-data-purge.timer- runsrails nightly_data_purgedaily, deleting messages & other data older than 2 days- A
dogbotpostgres role & system user (the DB is accessed via unix socket w/ peer auth)
Telegram only sends webhooks to https URLs on ports 443, 80, 88, or 8443, so put a TLS-terminating reverse proxy in front of it, and set host_url in the production credentials to its public hostname (just edit-creds-prod).
# flake.nix inputs
telegram-dogbot.url = "github:SummitCollie/telegram-dogbot";
telegram-dogbot.inputs = {
nixpkgs.follows = "nixpkgs";
# Only used by the dev shell, not the NixOS module
bundix.follows = "";
process-compose.follows = "";
services-flake.follows = "";
};The empty follows keep the dev-only inputs out of your flake.lock. If another flake in your config already pins bob-ruby or ruby-nix, you can also point those at its copies (e.g. bob-ruby.follows = "other-flake/bob-ruby";), as long as that pin still has the Ruby version from .ruby-version.
{ config, inputs, ... }:
{
imports = [ inputs.telegram-dogbot.nixosModules.default ];
# Should contain RAILS_MASTER_KEY=<contents of config/credentials/production.key>
age.secrets.telegram-dogbot-env.file = ../secrets/telegram-dogbot-env.age;
services.telegram-dogbot = {
enable = true;
port = 3001;
railsEnvFile = config.age.secrets.telegram-dogbot-env.path;
};
}See nix/module.nix for all options (puma workers/threads, data purge schedule, etc).
- Logs:
journalctl -fu telegram-dogbot - Run purge now:
sudo systemctl start telegram-dogbot-data-purge - DB shell:
sudo -u dogbot psql dogbot_production
- Install Nix (with flakes enabled) and direnv + nix-direnv.
direnv allow(ornix develop) - provides ruby, all gems, postgres client, bundix, etc.- Configure dev credentials with
just edit-creds-dev(see Configuration).
-
just runaka
-
nix run .#devenv
Starts a process-compose TUI running postgres (port 5434, data in .postgres/) and the bot poller (rails telegram:bot:poller, after rails db:prepare).
To debug with binding.pry, stop the bot-poller process in the TUI and run rails telegram:bot:poller in a separate terminal instead.
Only use this if you want to locally test the webhooks mode used in production for some reason (requires ngrok).
- Add your
ngrok_urlandtelegram_secret_tokento rails development credentials. - Start postgres with
just runand stop thebot-pollerprocess. - Start server with
rails s(andjust start-ngrok). - After you're done, run
Telegram.bot.delete_webhookin arails cconsole to delete the webhook so poll mode works again.
Requires postgres to be running (just run).
-
just test(aka
rubocopandrspecin parallel)
Gems are provided by nix (via ruby-nix), not bundle install. After changing the Gemfile, update Gemfile.lock and regenerate gemset.nix with the bundle-* recipes in the justfile, e.g.:
just bundle-add some-gemjust bundle-install-and-lock
