I use n8n since somes weeks and what a great piece of software !
Now that I moved all my automations from other sites to my n8n, I want to go further:
An automation I want to make needs a user input (basically “yes”/“no”) and I want to make it with Telegram if possible (I already use it to send messages in other automations).
Here is the workflow I want to make:
Here is the problem: I know how to send the question with the expected answers but I don’t know how to get the user’s answer. I see there is a lot of Telegram nodes but I don’t found a suitable one…
I think the Wait node is a great approach for such a use case.
In your Telegram node you could send a message including the $execution.resumeUrl generated by the Wait node, then attach a parameter indicating the user response. This answercould work for example like so:
This approach can also be transferred to services other than Telegram (anything capable of displaying links), so is quite flexible. The only downside is that you don’t see the response in real-time on your n8n canvas when building your workflow but have to switch to the execution view instead:
Hi @CodeRider883, using the inline keyboard would also work, but is a bit more complicated.
You’d need to set up the Telegram trigger node which is quite restrictive. It would use webhooks under the hood and Telegram allows exactly one active webhook at a time. So you can’t have multiple workflows using the Telegram trigger node, and you also can’t have an active workflow and execute it manually at the same time.
It also means you can’t access the data from your current execution, as each button press would start a new workflow execution.
If you’d still like to use the keyboard, your first workflow could look like so:
Your second workflow (handling the inline button actions and everything else coming from Telegram) could look like so:
While I understand cons and limitations of this second method, I will save it as a template if I need to use it.
I will probably use more often the first method for automations where I am the only recipient but maybe the second method with one or two automations where other people are in the chat.
A question comes to my mind: let’s say I have two workflows that use method 2, I should have two other workflows to handle answers.
How can I do to redirect to the good answer workflow ? Should I use another callback name in each buttons and add an “if” block at the start of these workflows to verify the callback name ? So when an answer is send, it will trigger all answer workflows ?
Ok so even if I have two question workflows with really different subjects, I have to process their answers in only one answer workflow ? Maybe on “big answer workflow” which acts as a switch that starts related question “answser workflow” by passing data… I will try.
The downside with the first method is that when you click on the answer link, Telegram asks you if you want to open the link and opens it’s internal browser to show a webpage with json saying “Workflow was started”. To me it’s ok but for my wife or other persons, they will be afraid…
Thank you for your help, I now see what I can do !
You can also consider creating multiple different Telegram bots for different purposes - this might be easier to implement from a workflow perspective, but might be slightly more confusing for your users.
As for the webhook message, you can customize the Response behaviour on the Wait node: