# Build a Telegram AI chatbot with Trilox and OpenAI: n8n workflow

> Started by an incoming Telegram message, and works across Telegram. It puts OpenAI behind a retrieval step, so answers are drawn from documents you supply...

Source: https://millionrounds.com/workflow/build-a-telegram-ai-chatbot-with-trilox-and-openai (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Chat assistants](https://millionrounds.com/workflows?category=Chat+assistants#library)

# Build a Telegram AI chatbot with Trilox and OpenAI

Started by an incoming Telegram message, and works across Telegram. It puts OpenAI behind a retrieval step, so answers are drawn from documents you supply rather than from the model alone. 29 steps, 5 branches: large, and worth reading before you trust it with anything live.

Large Calls a model: OpenAI Retrieval

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fbuild-a-telegram-ai-chatbot-with-trilox-and-openai)

**29 steps** Large: read it before trusting it with anything live

**5** Branches: places the flow splits

**0** Loops or waits

**1** Service it connects to

## The flow

Starts it 2 Model 5 Logic 12 Service 10

The steps in the order they run, from what starts it.

- 1 **OpenAI Chat Model** Lm Chat Open Ai *Model*
- 2 **Conversation Memory** Memory Buffer Window *Model*
- 3 **Structured Output Parser** Output Parser Structured *Model*
- 4 **Telegram Trigger** Telegram trigger *Starts it*
- 5 **Trilox Trigger (Agent Reply)** Trilox trigger *Starts it*
- 6 **AI Agent** Agent *Model*
- 7 **Message Type Router** Switch *Logic*
- 8 **Channel Router** Switch *Logic*
- 9 **Check Handler (Post-Bot)** Trilox *Service*
- 10 **Extract Text** Set *Logic*
- 11 **Download Voice File** Telegram *Service*
- 12 **Ignore Unsupported** No Op *Logic*
- 13 **Forward to Telegram** Telegram *Service*
- 14 **Other Channels (Placeholder)** No Op *Logic*
- 15 **Handler Status Router 2** Switch *Logic*
- 16 **Merge Text Input** Merge *Logic*
- 17 **Transcribe Voice Message** Open Ai *Model*
- 18 **Send Bot Reply** Telegram *Service*
- 19 **Suppress Bot Reply** No Op *Logic*
- 20 **Record Visitor Message** Trilox *Service*
- 21 **Record Bot Response** Trilox *Service*
- 22 **Check Handler (Pre-Bot)** Trilox *Service*
- 23 **Needs Human?** If *Logic*
- 24 **Handler Status Router** Switch *Logic*
- 25 **Escalate to Human** Trilox *Service*
- 26 **Done (No Escalation)** No Op *Logic*
- 27 **Send Awaiting Message** Telegram *Service*
- 28 **Bot Stays Silent** No Op *Logic*
- 29 **Record Awaiting Message** Trilox *Service*

## How it's built

- **Starts on:** An incoming Telegram message
- **Steps:** 29, with 5 branches
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Telegram
- **Model:** OpenAI
- **Retrieval:** Answers are drawn from documents you supply, not from the model alone

## Questions

What does it need to run?

An n8n account, plus your own Telegram account, and a key for OpenAI. You connect your own accounts after importing it; none are included.

What starts it?

It starts on an incoming Telegram message.

Does it use AI?

Yes. It calls OpenAI. Its answers draw on documents you give it, not on the model alone. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 29 steps it is large: read it before trusting it with anything live.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 29 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fbuild-a-telegram-ai-chatbot-with-trilox-and-openai)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[Telegram](https://millionrounds.com/workflows?service=Telegram#library)

## Workflows like it

Also chat assistants, with the same services where possible, closest in size first.

- [**Basic RAG system with Claude and OpenAI** 29 steps · calls a model · Google Drive, Supabase](https://millionrounds.com/workflow/basic-rag-system-with-claude-and-openai)
- [**Find and rank job listings from Adzuna and Remotive** 29 steps · calls a model · Google Sheets, Telegram](https://millionrounds.com/workflow/find-and-rank-job-listings-from-adzuna-and-remotive)
- [**Get Colombian peso to USD exchange rate with Telegram** 29 steps · calls a model · Telegram](https://millionrounds.com/workflow/get-colombian-peso-to-usd-exchange-rate-with-telegram)
- [**Score GeM tender compliance and draft bid responses** 29 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/score-gem-tender-compliance-and-draft-bid-responses)
- [**Telegram bot starter template setup & AI agent chatbot** 29 steps · calls a model · Google Sheets, Telegram](https://millionrounds.com/workflow/telegram-bot-starter-template-setup-and-ai-agent-chatbot)
- [**AI warehouse inventory cycle count bot with OpenAI** 28 steps · calls a model · Google Sheets, Telegram](https://millionrounds.com/workflow/ai-warehouse-inventory-cycle-count-bot-with-openai)
