workflows.fit
Back to n8n workflows
n8n templateFreeBy Kirill Zolygin

Telegram chatbot with voice recognition and message batching using OpenAI

This Telegram workflow batches rapid-fire messages from the same user into one prompt (20–30s debounce), then sends a single AI reply. It uses two Google Sheets: - Message Retention (date | userid | message) — queues ...

Data & StorageProductivityCommunicationHITLDevelopmentCore NodesAILangchain
Loading interactive preview...

Template notes

This Telegram workflow batches rapid-fire messages from the same user into one prompt (20–30s debounce), then sends a single AI reply.

It uses two Google Sheets: - Message Retention (date | userid | message) — queues incoming messages. - Message Checkup (userid | iswaiting | lastupdated) — debounces per user.

Flow per message: 1. Log to Message Retention. 2. Read Message Checkup for that userid. If empty, synthesize { iswaiting:false }. 3. IF (OR): - lastupdated is older than 30s, or - iswaiting is false → Start wait window: set iswaiting=true, update lastupdated, Wait (e.g., 30s). 4. After Wait: fetch all queued messages for the user, merge them, delete those rows, send one AI answer to Telegram, then clear the Waiting row. 5. If a new message arrives while waiting, we only refresh lastupdated (extend the window) — we do not start another wait.

Copy/paste: - Older-than-30s: {{ new Date(Date.now() - 30000).toISOString() }} - “No Rows” normalizer (Code node) ensures the IF always has data to check.

Supports text and voice (voice via Whisper). Works reliably on Telegram once the webhook is registered and Sheets are shared with the service account.