Build a learning Telegram AI agent with memory and external tools
Workflow Description
Automation that transforms Telegram into an intelligent agent platform powered by OpenAI, retains conversation context via Redis, and integrates with Twitter/X for enhanced interactions. The agent learns from user behavior and executes tailored actions with persistent memory across sessions.
How it works
- 1.Receive messages from Telegram and classify the request type
- 2.Process messages through OpenAI agent with Redis-backed conversation memory
- 3.Execute appropriate action: generate intelligent response, query Twitter, or invoke custom tools
- 4.Send generated response back to user through Telegram
Use cases
- Create a conversational assistant that handles complex queries and recalls previous interactions
- Enforce dynamic rules and agent behavior constraints based on user type or topic
- Integrate Telegram with Twitter to search topics or publish updates directly from chat
Requirements
- Telegram bot token and active bot account
- OpenAI API key with sufficient quota
- Redis instance for persistent context storage
Service Value
Ideal as a smart automation service combining integrations and AI to produce ready-to-use results.
Apps Used
Details
How to Use
- 1.Click "Download Template"
- 2.Open your n8n dashboard
- 3.Go to Workflows > Import from File
- 4.Select downloaded file and configure credentials
Nodes Used (39)
Human Handoff using Send and Wait
Set
Set Interaction to Bot
Redis
Set Interaction to Human
Redis
Get Interaction State
Redis
Model
OpenAI
Memory
Memory Redis Chat
Handoff Subworkflow
Execute Workflow Trigger
Telegram Trigger
Set
Send Response
Set
Switch Interaction
Switch
Information Extractor
Information Extractor
OpenAI Chat Model
OpenAI
With Defaults
Code
Has All Criteria?
If
Onboarding Agent
Agent
Get Onboarding Chat History
Redis
After Sales Agent
Agent
Memory1
Memory Redis Chat
Model1
OpenAI
Handoff Tool
Tool Workflow
Sticky Note
Sticky Note
Sticky Note1
Sticky Note
Sticky Note2
Sticky Note
Handoff Subworkflow1
Execute Workflow
Sticky Note3
Sticky Note
Sticky Note4
Sticky Note
Sticky Note5
Sticky Note
Sticky Note6
Sticky Note
Sticky Note7
Sticky Note
Send Response2
Set
Memory2
Memory Redis Chat
Update Agent Memory
Memory Manager
Send Response3
Set
Get Canned Response
Set
Notify user
Set
Sticky Note8
Sticky Note
Memory3
Memory Redis Chat
Update Agent Memory1
Memory Manager
Continue Conversation
Set