Menu

Build a free Telegram AI bot on Netlify with Gemini + Groq
📰

Build a free Telegram AI bot on Netlify with Gemini + Groq

DEV Community: serverless·Nima·about 17 hours ago
#nwe7GvOG
#devtoserverless#devto#dev#gemini#telegram
Long article (597 words) — no AI summary yet.
Reading 0:00
15s threshold

Most "build an AI chatbot" tutorials end with a server you pay for every month. This one doesn't. We'll put an AI assistant in Telegram using three free tiers: Netlify Functions to host it, Google Gemini to answer, and Groq as a backup when Gemini is busy. There's no server, no database and no npm packages. The whole bot is one JavaScript file.

We'll use the open-source template telegram-ai-bot-lite (MIT).

How it works

Telegram can push each message to a URL of your choice (a webhook). Our URL is a Netlify Function:

Telegram ──POST update──▶ Netlify Function (index.mjs) │ checks secret header ├─▶ Gemini ──(error/empty)──▶ Groq ◀── answer Telegram ◀──sendMessage──────┘

Enter fullscreen mode

Exit fullscreen mode

The function does four things: it checks Telegram's secret-token header, sends the text to Gemini, tries Groq if Gemini fails or returns nothing, and replies with sendMessage . A request without the right secret is rejected.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.