Trigger specific node in other workflow? (Telegram bot)

Describe the issue/error/question

I’d like to make use of the Telegram Trigger node and built a Telegram bot and gave it a few commands. Now I want to trigger the command, which should take arguments via Telegram like this:

me: /command
bot: Tell me, what's Argument 1?
me: Argument 1

Then, the bot should do its magic. For that I figured something like this:

Setup

Workflow 1: Telegram Trigger > Check if message is /command > true: Execute Workflow 2

Workflow 2: Telegram Trigger > Get next message (the one after /command) and use it as argument in the next node

To keep Workflow 2 from triggering on every message, I set it to inactive and wondered, if I somehow can trigger the Telegram Trigger node in Workflow 2 from Workflow 1.

Conclusion

I have the feeling, I make this too complicated. Maybe someone has worked more with Telegram bots and the n8n nodes and has a nice simple solution to this problem.

Thank you very much in advance.
Best
Fabian

Hey @wohfab, you would not be able to programmatically have the Telegram trigger node to ignore some events I am afraid.

To build a workflow that is aware of previous commands (or any message) in a given chat you would need to remember these messages in a database in the first place (as you can’t query previous messages in a chat through the Telegram node) and then query the database when a native message is received. This probably is a bit over the top for most cases.

If your bot only accepts a limited number of responses, my suggestion would be to use the “inline keyboard” option in response to your command, e.g. like so:

This example would result in a bot message like this:
image

You can then configure the Telegram Trigger nodes to only listen for callback_query updates:
image

If you have multiple different callback queries, you could simply add an IF node afterwards to check whether the message text or data match what you expect, making filtering a lot easier to implement.

The workflow would, however, need to be active to receive any callback data.

Thank you very much @MutedJam.

I will definitely keep the “inline keyboard” in mind for the Telegram workflows, but unfortunately it’s not going to work for this specific problem, as I need a free text reply for this one.

Hi @wohfab, thanks for confirming. In this case you’d need to keep track of your entire conversation and implement the mapping logic yourself in order to always have the required context for free text messages. That’s quite a task tbh.