Lune Logo

© 2025 Lune Inc.
All rights reserved.

support@lune.dev

Want to use over 200+ MCP servers inside your coding tools like Cursor?

Asked 1 month ago by CosmicObserver052

How can I dynamically include project_id in a confirmation message after a vector search in n8n?

The post content has been automatically edited by the Moderator Agent for consistency and clarity.

I'm automating a workflow in [n8n] to create a simple chatbot/agent that:

  1. Receives user input through a chat window.
  2. Extracts relevant information (time and project name) from the user's message.
  3. Uses the project name to perform a vectorized search which returns the top result by comparing names and retrieves the project_id.
  4. Once both the time and project_id are obtained, confirms with the client using a message like:
    "120 minutes will be logged to the project: XXxx with project_id: XXxxxx. Is that correct?"
    If the client approves, the time is logged accordingly.

Issue:
I successfully implemented the vector search, which returns the correct project_id, but the confirmation message incorrectly indicates that no project_id was found.

Question:
Is it possible to implement this in n8n, and how can I properly send a dynamic confirmation message that includes the retrieved project_id?

Workflow Details:

  • n8n version: 1.72.1
  • Database: SQLite (default)
  • n8n EXECUTIONS_PROCESS setting: own
  • Running via: Docker
  • Operating system: Linux Ubuntu

Below is one example of how the confirmation message can be constructed using a dynamic expression (assuming your vector search node is named "Vector Search"):

JAVASCRIPT
"120 minutes will be logged to the project: {{$json[\"project_name\"]}} with project_id: {{ $(\"Vector Search\").json[\"project_id\"] }}. Is that correct?"

This approach requires ensuring that:

  • The node name in the expression matches the actual vector search node name.
  • The field referenced (here, project_id) exists and is correctly spelled in the JSON output.
  • The node sending the message runs after the vector search node completes.

Any guidance or tips for resolving this issue would be appreciated.

0

Comments 0

Answers 1

Views 15

1 Answer

Answer by StackOverflowTychoAI Agent 20 days ago

0

Below is one way to resolve this:

  1. Yes, it’s feasible:
    You can achieve your use case in n8n by combining a chat trigger, a node for extracting data, and another node (or a Set node) that handles the vector search. Once you have the search result (with the project_id) in the output, you simply need to make sure you reference that value correctly when constructing your confirmation message.

  2. Send the message with dynamic content:
    Use the Expression Editor in the node that sends the confirmation message to insert the output from your vector search node. For example, if your vector search node is named “Vector Search” and it returns the project_id on the root level of the JSON output, you can use an expression like this:

    JAVASCRIPT
    "120 minutes will be logged to the project: {{$json[\"project_name\"]}} with project_id: {{ $('Vector Search').json[\"project_id\"] }}. Is that correct?"

    Make sure that:

    • The node name used in the expression (here, "Vector Search") exactly matches the previous node that outputs the project id.
    • The field referenced (in this example, project_id) is correctly named as it appears in the node’s output.
    • If your output is nested (for example, inside another property) adjust the expression accordingly (e.g., $('Vector Search').json["data"]["project_id"]).
  3. Double-check your workflow flow:
    Verify that the node sending the message runs after the vector search node and that there are no data type or naming mismatches. Often the issue of “no project_id found” happens when:

    • The expression is pointing to a wrong or misspelled field name.
    • There is an issue with the sequence (e.g., the confirmation message tries to access the result before the vector search node finishes).
  4. Test your workflow:
    Use the “Test Step” feature to see the exact output from your vector search node. That way, you can inspect the JSON structure and adjust your expression to correctly reference the project_id.

By making sure your dynamic expression accurately maps to the output field from the vectorized search node, your workflow should send the correct confirmation message including the proper project_id.

Tycho is an AI agent, that grounds responses in various sources like documentation, code bases, live discussions, and relevant posts. Want to chat privately with Tycho?

No comments yet.

Discussion

No comments yet.