Telegram bot (webhook & responses + AI-agent

Hi,

I’m new to n8n and have started building a prototype Telegram bot focused on the stock market. As an end user of the bot, you’ll be able to request information about a stock, view technical analysis (e.g., EUR/USD), and more. The bot should be functional for multiple users. I have a few questions regarding this setup:

  1. Since multiple users will be using the bot, I’d prefer not to use GET requests to retrieve Telegram user data (due to cost inefficiency with workflow executions). Instead, I want to trigger a webhook from Telegram to an n8n endpoint.
    Is the Telegram Trigger (On Message) in n8n equivalent to a webhook, or does it continuously poll the Telegram channel and trigger workflows?

  2. The bot will support various commands like /chart, /analyse, etc.
    When a user sends a command, and the webhook is triggered in n8n, I want to respond with a follow-up question like:
    “Which ticker are you interested in? For example: EUR/USD”*
    Which node in n8n should I use to handle this kind of dynamic interaction?

  3. Following up on question 2: Can I use a single AI agent to handle different commands, or is it better to create separate flows for each command?

n8n Setup:
Running on n8n Cloud

Thanks in advance!

1 Like

Sounds like a fun project,

so in telegram u can use trigger node, which use post, u call this endpoint with the data.

u can also then if u wanted call different webhooks in that flow, for /chart or /analyse, or use a switch node or filter node, so it processes down a certain action flow,

u can have multi agent in one flow, call other workflows that do it, sure ai agent could its very flexible in n8n.

just depends how unique you want it and the format you want to present it.

hope this helps

Thanks for your quick response and solutions! The telegram webhook is done and the telegram trigger in n8n also, but a few more additional questions:

1.When I send a command from the bot, I have to manually click “Test Workflow” in n8n before the data is retrieved. Why doesn’t this happen automatically?**

  1. If a user can choose from five predefined actions in the Telegram bot (e.g., command 1, command 2, etc.), a response should be sent back to Telegram indicating which stock it concerns (e.g., EUR/USD). After the user replies, the workflow should continue.
    In this case, which node is most appropriate to use: Split, Switch, Filter, or IF? The workflow should follow a specific path based on the selected command.

  2. When the Telegram bot and n8n workflow are running in production but I still want to continue development, how can I safely test iterations while the workflow is live?

Again thanks for feedback!

I would use a switch, and define each command, and in terms of multi-step questions, I used slack but implemented a wait and check if reply count increased, then continue once replied, I think in telegram, u can use userid, or similar message timestamp maybe?

This is my flow for multistep questions

u could have logic for anycommand using if, to filter a flow for commands that don’t exist etc, but I think telegram handles it anyway.

I would test on a separate telegram channel maybe? one for prod, one for dev, merge changes over to prod once developed and tested on the test channel maybe? as the URL differ.