ENGINEERING
A Telegram bot answered by your own gateway
Just activated iSol API? Your key lives in the customer portal, isollm.ai/account → API keys (the portal shows the raw sk-… value; store it in your secret manager). The endpoint for every guide on this blog is https://tokens.4clouders.com/v1, and per-key spend updates live on the same portal page. That is all you need to follow along.
Why Telegram + your own gateway
Telegram is where half the company already answers questions, so it is the cheapest place to put a private assistant. The bot below needs no webhook, no public URL and no framework: long-polling from any machine with outbound internet. Every message is answered by your gateway, on infrastructure you control, with the same per-key budget and audit log as every other tool in this series.
Step 1: Create the bot (2 minutes)
- In Telegram, talk to @BotFather →
/newbot→ pick a name and a handle. - BotFather replies with the bot token, that is your
TELEGRAM_BOT_TOKEN.
Step 2: The whole bot
import os, requests
TG = f"https://api.telegram.org/bot{os.environ['TELEGRAM_BOT_TOKEN']}"
ISOL = "https://tokens.4clouders.com/v1/chat/completions"
KEY = os.environ["ISOL_API_KEY"]
def ask_isol(text: str) -> str:
r = requests.post(ISOL, timeout=60,
headers={"Authorization": f"Bearer {KEY}"},
json={"model": "isol-4.9", "messages": [
{"role": "system", "content": "You are the company's private assistant. Be brief."},
{"role": "user", "content": text}]})
r.raise_for_status()
return r.json()["choices"][0]["message"]["content"]
def main():
offset = None
while True:
upds = requests.get(f"{TG}/getUpdates",
params={"timeout": 50, "offset": offset}, timeout=60).json()
for u in upds.get("result", []):
offset = u["update_id"] + 1
msg = u.get("message") or {}
if "text" in msg:
requests.post(f"{TG}/sendMessage", json={
"chat_id": msg["chat"]["id"],
"text": ask_isol(msg["text"])})
if __name__ == "__main__":
main()
Step 3: Prove the brain works before wiring the token
The function every message goes through is ask_isol(), and you can run it before touching Telegram at all. This is it, executed live against our gateway:

Then: export TELEGRAM_BOT_TOKEN=…, python3 telegram_isol_bot.py, and message your bot.
Gotchas we hit running this for real
- Long-polling beats webhooks for a first deploy, no TLS certificate, no public URL, works from behind NAT. Move to webhooks only when volume demands it.
- One gateway key per bot. When the bot goes viral internally, its budget is its own, not your CI key's.
- Set
timeout=60on the model call, long answers on long context can pass 30s, and the default requests timeout is none (hang) not some (fail fast).
Same gateway, rest of your stack: every guide with real sessions
The pattern: one gateway, every tool
WhatsApp
GitHub Actions
Teams
Claude Code
Cursor
VS Code
aider
OpenCode
n8n
Zapier
Power Automate
Power BI
Google Sheets
Website chatbot
Hermes Agent
Try it on ours
Our gateway (iSol API) runs exactly this setup on sovereign infrastructure, US$ 99/month, 14-day trial.