Quick overview
This workflow turns a Telegram bot into a conversational assistant that answers incoming chat messages using an OpenAI chat model, with optional tool use for Perplexity web search, Wikipedia lookups, and calculations, while keeping short-term per-chat memory.
How it works
- Triggers when a new Telegram message is received by your bot.
- Loads the assistant configuration (system prompt, OpenAI model, Perplexity model, memory window, and max reply length) and continues only if the message contains text.
- Sends the user’s text to an OpenAI-powered agent that can call Perplexity for real-time web search, Wikipedia for background info, and a calculator for arithmetic while using per-chat memory.
- Truncates the generated answer if it exceeds the configured maximum length.
- Sends the final reply back to the same Telegram chat with web previews disabled.
Setup
- Create a Telegram bot with @BotFather and add its token as a Telegram credential used by both the Telegram Trigger and Send Reply steps.
- Add an OpenAI API credential and select the model you want to use in the configuration values.
- Add a Perplexity API credential and select the Perplexity model for web search.
- Review and edit the system prompt, memory context window size, and maximum reply length in the Configuration step to match your preferred behavior.
Additional info
Answer Telegram messages with an AI agent using GPT-5, Perplexity and Wikipedia
Need help customizing?
Contact me for consulting and support : Linkedin
MY NEW YOUTUBE CHANNEL
👉 Subscribe to my new YouTube channel. Here I'll share videos and Shorts with practical tutorials and FREE templates for n8n.
