Quick overview
This workflow turns a Telegram bot into an AI data assistant. Users ask questions in plain language and the agent answers with live data: weather (Open-Meteo), foreign exchange rates (Frankfurter), crypto prices (CoinGecko), gold price, Indonesian earthquakes, Bank Indonesia rates, Indonesian holidays, and Jakarta power supply (StudioAPI). Every query is logged to Google Sheets, and a weekly market briefing is sent to the owner every Monday.
How it works
- Triggers when a new message arrives at your Telegram bot.
- Normalizes the incoming message (text, chat ID, user name, and timestamp).
- A GPT-4o-mini agent keeps a short conversation memory and picks the right data tool for the question.
- Weather tool: current conditions from Open-Meteo (temperature, humidity, wind, and weather code) by latitude and longitude.
- FX Rates tool: reference exchange rates from Frankfurter. Gold Price tool: the current international gold price in USD per troy ounce.
- Crypto Prices tool: USD prices and 24-hour change for ten major coins from CoinGecko.
- Indonesian data from StudioAPI: latest earthquakes (BMKG), Bank Indonesia reference rates, national holidays, and Jakarta power supply status.
- /help and /start return a short menu of supported topics without calling a tool.
- The question and answer are logged to Google Sheets and the answer is sent back to the user in Telegram as a short, mobile-friendly reply.
- Every Monday at 07:00 a scheduled branch fetches crypto prices and writes a short market briefing (crypto highlights, gold price, and FX note) for the owner.
- If a node fails, the Error Trigger path replies in Telegram that the data service is temporarily unavailable, so failed lookups are not silently dropped.
Setup
- Create a Telegram bot with BotFather and add your Telegram credentials in n8n for the trigger and reply nodes.
- Connect your OpenAI credentials on the model nodes (gpt-4o-mini by default).
- Create a StudioAPI key and add an HTTP Header Auth credential (x-api-key). The earthquakes, BI rates, holidays, and power tools require it.
- Connect your Google Sheets credentials and set the spreadsheet and sheet used to log queries.
- Send a message to your bot to test, then adjust the system prompt if you want to change what the assistant can answer.