Skip to content

omarperezr/SmarttyBot

Repository files navigation

SmarttyBot

The smartest multiplatform bot

Go Report Card CI Maintainability

SmarttyBot is a multiplatform assistant that relays messages between Discord, Telegram, Slack and Email, and acts on natural language (via Groq) when you address it — running GitLab reports, sending email, cross-posting, and more.

  • Set up all your accounts and get the API tokens
  • Get a free Groq API key for the natural-language assistant
  • Let SmarttyBot make your life easier

Features

  • Assistant-first: @mention the bot, reply to it, or call it by name on any platform and it decides what to do — no magic prefixes needed (legacy prefix commands still work)
  • Conversation memory: keeps short per-chat context so follow-up questions work ("and the in-progress ones?")
  • Natural-language tools parsed by Groq (OpenAI-compatible tool calling): gitlab reports, send email, cross-post, toggle sync
  • Two-way channel sync: opt-in mirroring of a Telegram/Discord/Slack channel to its same-named peers
  • Discord slash commands (/answer, /register, /send-email, /sync, …) alongside the classic prefixes
  • Push delivery: Slack via Socket Mode (no public endpoint) and email via IMAP IDLE (instant, no polling)
  • Every channel is optional: run any subset (Telegram, Discord, Slack, Email) — each enables itself only when configured
  • Persistent state in an embedded SQLite database (no external DB required)
  • Graceful shutdown, structured logging, and a /healthz + /metrics endpoint
  • The only limit is your imagination

Architecture

cmd/smartty_bot        entrypoint: config, wiring, signal-based shutdown
internal/config        env loading + SQLite database + persisted stores
internal/store         generic, mutex-safe, SQLite-backed maps
internal/assistant     the LLM brain: Groq tool calling, memory, addressed-trigger
internal/hub           cross-platform router (cross-post + opt-in sync)
internal/telegram      Telegram client, commands, callbacks
internal/discord       Discord client, prefix + slash commands
internal/slack         Slack client via Socket Mode
internal/email         SMTP send + IMAP IDLE inbox listener
internal/gitlab        GitLab API client (replaces the old Python script)
internal/gitlabreport  formats GitLab data into replies
internal/health        /healthz + /metrics HTTP server

Using the assistant

On any platform, address the bot to trigger the LLM:

  • @mention it, reply to one of its messages, or start your message with its name (BOT_NAME, default smartty).
  • e.g. @smartty gitlab report for webapp, or smartty email alice@x.com subject "hi" body "...".

Plain, un-addressed messages are never sent to the LLM (keeps API usage low). In a synced channel they are mirrored to the paired channels instead.

Commands (legacy prefixes still supported)

Telegram: -m/-mention <text>, -p/-parse <text>, -r/-register @TelegramUser discordUser, -sync on|off

Discord (prefix or slash): -a/-answer (/answer), -r (/register), -rm (/register-email), -m/-send-email (/send-email), -sync (/sync)

Tutorial

Every channel is optional. Configure only the platforms you want — the bot enables each one solely based on whether its tokens are set, and starts fine with any subset (or none). An unconfigured channel is skipped; a misconfigured one logs its own error without affecting the others.

Step 1: Groq (natural language) setup

The natural-language module uses Groq's free, OpenAI-compatible API:

GROQ_API_KEY="gsk_..."
GROQ_MODEL="llama-3.3-70b-versatile"

The supported actions (tools) are defined in internal/assistant/tools.go; add new ones there and dispatch them in internal/assistant/assistant.go.

Step 2: GitLab setup

The report actions talk to the GitLab API directly (no Python needed):

GITLAB_TOKEN="glpat-..."
GITLAB_URL="https://gitlab.com/"

Step 3: Telegram setup

TELEGRAM_API_KEY="123456TELEGRAMMMMMMAPI"

Step 4: Discord setup

Follow https://discordpy.readthedocs.io/en/stable/discord.html to create a bot, then:

  • Go to 'Bot', select 'Reset token', copy it into .env
DISCORD_API_KEY="DDDIIISSSCCCOOORRRRDDDAAAAPPPIII"

Step 5: Email setup

EMAIL_ACCOUNT="gmailaccount@gmail.com"
EMAIL_PASWORD="emailPassword"
SMTP_SERVER="smtp.gmail.com"
SMTP_PORT=587
IMAP_SERVER="imap.gmail.com"
IMAP_PORT=993

Incoming mail is delivered via IMAP IDLE (instant push); servers without IDLE fall back to polling automatically.

Step 6: Slack setup (optional)

Slack uses Socket Mode, so no public endpoint is required. In your Slack app config: enable Socket Mode, add an app-level token with connections:write, subscribe to the app_mention (and optionally message.channels) events, and install the bot. Then:

SLACK_APP_TOKEN="xapp-..."   # app-level token
SLACK_BOT_TOKEN="xoxb-..."   # bot token

Slack stays disabled unless both tokens are set.

See .exampleenv for the full set of variables (including BOT_NAME, PORT and LOG_LEVEL).

Installation & Execution

SmarttyBot requires Go v1.23+ to run.

git clone https://github.com/omarperezr/SmarttyBot
cd SmarttyBot
cp .exampleenv .env   # then fill in your tokens
go build ./cmd/smartty_bot
./smartty_bot

State is stored in data/smartty.db (SQLite), created automatically on first run.

Run with Docker

docker compose up --build

The .env file supplies the configuration and a named volume persists data/.

Development

go build ./...
go vet ./...
go test -race ./...

CI runs formatting, vet, race tests, golangci-lint and a Docker build on every push and pull request.

Donate

Want to contribute?

Kofi

License

GNU General Public License v3.0

Free Software, Hell Yeah!

About

A really smart bot that connects with your email, discord, telegram and gitlab

Topics

Resources

License

Stars

6 stars

Watchers

1 watching

Forks

Releases

No releases published

Sponsor this project

Packages

 
 
 

Contributors

Languages