Building a Conditional Workflow in n8n for Dynamic User Selection and API Interaction

I am building a system using n8n and an API. I aim to create a process where, upon requesting bus location information via Telegram, the result is sent back to Telegram.

The current process I have developed is as follows:

  1. When a question is asked through chat,
  2. The AI agent analyzes the chat input and extracts it into a JSON format with “location” and “num_bus”.
  3. The extracted data is used in an HTTP request node to retrieve API results.
  4. A code node is utilized to extract only the necessary information for the second API query.

Problem:
If there is only one result, it can be easily inserted into the second API query to retrieve the results. However, if there are two or more results, a selection needs to be made. While I am using various nodes, what I am curious about is how to ask the user for input when multiple results are present, so that their response can trigger the execution of the corresponding node.

For example:

  1. Question: “More than one result was found. Which result would you like to proceed with?” Response: “Please run result number 2.”
  2. The second result is sent to the second API, and the output is then provided as a response via Telegram.

Is there a way to achieve this? Or do you have any ideas for a workaround?

Information on your n8n setup

  • n8n version: Version 1.65.2
  • Database: PostgreSQL
  • n8n EXECUTIONS_PROCESS setting: own
  • Running n8n via: Docker-starter kit
  • Operating system: Mac OS

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @da3hunny,

Welcome to the community! :ice_cream:

How about returning both results and updating the prompt, telling it that in case of multiple results, return both and ask the user which option they would like to continue with?