SandAI is a Khmer-first Telegram community manager bot for the Sand AI Builder Project group.
- Khmer welcome message for new members with inline buttons.
- Group rules and project information button handlers.
- Anti-spam and anti-scam link scanning with warning counts.
- Three warnings can trigger temporary mute or ban.
- Member reputation upvotes through inline buttons.
- Daily tech summary from tracked discussion topics.
- Local FAQ quick replies for common setup questions.
- OpenAI API-backed SandAI replies when members mention
SandAIor reply to the bot. - Multi-group settings isolation by Telegram
group_id. - Private-chat admin dashboard for welcome text, rules, and official URL.
- Analytics view for tracked topics and blocked spam.
- Security gatekeeper for Telegram join requests.
- Voice command transcript support through
[VOICE_COMMAND]. - Guest query fallback through
[GUEST_QUERY ...]frames.
- Create and activate a virtual environment:
python -m venv .venv
.venv\Scripts\activate- Install dependencies:
python -m pip install -r requirements.txt- Copy
.env.exampleto.envand set your values:
copy .env.example .envSet OPENAI_API_KEY, OPENAI_MODEL, and OPENAI_MAX_OUTPUT_TOKENS to enable AI replies.
- Run the bot:
python -m sandai_botUse a Web Service so Render exposes an HTTPS URL that UptimeRobot can ping. The bot still runs Telegram polling; the web service only adds a lightweight health endpoint.
This repo includes render.yaml, so Render Blueprint deploy can create the service and persistent disk automatically.
Required environment variables:
BOT_TOKENADMIN_IDSOPENAI_API_KEY
Recommended environment variables:
STATE_FILE=/data/sandai_state.jsonOFFICIAL_DOMAIN,OFFICIAL_WEBSITE,PROJECT_INFO_URL,RULES_URL,DOCS_URLBOT_INVITE_URL
Manual Render settings:
- Runtime: Python
- Build Command:
pip install --upgrade pip && pip install -r requirements.txt - Start Command:
python -m sandai_bot - Health Check Path:
/healthz - Disk Mount Path:
/data - Disk Size:
1 GB
Do not deploy .env; configure secrets in your hosting provider dashboard.
After Render deploys, create an UptimeRobot HTTP monitor:
- Monitor Type:
HTTP(s) - URL:
https://YOUR-RENDER-SERVICE.onrender.com/healthz - Interval:
5 minutes - Keyword monitoring: optional, expected text is
ok
Each Telegram group has isolated settings stored by group_id in STATE_FILE.
Group owners/admins should:
- Add SandAI to their Telegram group.
- Send any normal message in the group so SandAI can verify admin ownership.
- Open a private chat with SandAI.
- Select the group and update settings through inline buttons only.
- Welcome message
- Group rules
- Official group URL
- Security Gatekeeper
- Group analytics
The bot uses the current group's URL for link moderation. Settings from one group are never reused in another group. Configuration changes are intentionally handled in private chat, not in the public group. Navigation is strictly button-driven; public groups are reserved for moderation and service replies.
- Join requests are handled by
ChatJoinRequestHandler. Enable Gatekeeper in the private dashboard to require DM verification. - Voice transcripts prefixed with
[VOICE_COMMAND]can update settings when the owner manages exactly one group. - Guest frames prefixed with
[GUEST_QUERY ...]get a one-message Khmer answer plus an add-bot button.