Skip to main content
A Telegram bot that answers legal questions via the Vaquill /ask API, renders markdown tables as PNG images, and surfaces case-law sources as tappable inline-keyboard buttons. Source code at github.com/Vaquill-AI/integrations/telegram-bot.

Features

  • Per-chat conversation history (last N exchanges, configurable)
  • Markdown tables rendered as styled PNG images using Pillow
  • Source citations shown inline and as inline-keyboard buttons that open PDFs
  • Telegram HTML sanitisation with plain-text fallback
  • Automatic chunking of long answers (4096-char limit)
  • Per-user rate limits (per-minute and per-day)
  • Optional user ID allowlist

Prerequisites

Platform setup

1

Open BotFather

Search for @BotFather in Telegram (or open t.me/botfather) and press Start.
2

Create the bot

Send /newbot. Provide a display name (e.g. Vaquill Legal AI), then a username ending in bot (e.g. vaquill_legal_bot). BotFather replies with your API token - copy it as TELEGRAM_BOT_TOKEN.
3

Register slash commands (optional)

Send /setcommands, choose your bot, and paste:
The bot also sets these on startup, but doing it manually makes them appear before the first run.
4

Description and avatar (optional)

/setdescription and /setabouttext set the text shown on the bot’s profile. /setuserpic sets the avatar (use a square image at least 512x512).

Quickstart

Local development uses polling mode - no public URL or HTTPS certificate required.
1

Clone and install

2

Configure

Fill in the two required values:
3

Run

Look for INFO - Vaquill Telegram bot starting (mode=standard). Open Telegram, search your bot by username, tap Start, and ask:
Create a separate test bot via BotFather for development so you do not disturb production users. Each token can only be polled by one process at a time.

Polling vs webhook

To switch to webhook mode, deploy behind HTTPS and register:
Verify with getWebhookInfo. Switch back to polling any time with deleteWebhook.

Configuration

Top env vars. Full list in the repo .env.example. To find your own Telegram user ID, message @userinfobot.

Commands

Any non-command message is treated as a legal question.

Deployment

Docker

The included Dockerfile uses python:3.11-slim and installs DejaVu fonts for table-image rendering.
Or with Compose:

Cloud hosts

Render

Deploy as a Background Worker (not Web Service) - polling does not need an HTTP port. render.yaml is included in the repo.

Railway

railway init && railway up. Add TELEGRAM_BOT_TOKEN and VAQUILL_API_KEY in the Variables tab.

VPS + systemd

Plain systemd unit with Restart=always. No reverse proxy needed.

Fly.io

fly launch, fly secrets set ..., fly deploy.
Example render.yaml:

Troubleshooting

WhatsApp

Twilio-based, comparable consumer-messenger surface.

Signal

Privacy-focused alternative.

Chatbots overview

Compare all six platforms.

Authentication

How Vaquill API keys work.