I have a webhook flow > lookup > http request (create a complete chat) > set. The flow works but the lookup is not coming into play. It must be some parameter or code that I can’t figure out, if someone can help me please.
Hey @Diego_mischiatti_cav hope all is well. Welcome to the community.
I am trying to understand your flow and have some questions:
- What is the lookup - is that a node? What does it do?
- What do you mean when you say it “can’t connect”? Is there an error? Something you can share with us? An output, a screenshot?
- When you say “chat compltium”, are you talking about some sort of AI completion endpoint/service/api?
- Can you share what you are trying to do instead of how you are trying to achieve that, maybe we can figure out a different way.
I’m working on a project to apply for an internship at a company. I need to use n8n to create an AI agent that can read and edit data from a spreadsheet table.
I’m a beginner, so I apologize if I’m not providing all the necessary details.
With this goal in mind, I’m building a flow like this:
Webhook > OpenAI (Create Chat Completion) > Google Sheets (Lookup Row) > Set (to format the response)
I’m testing this approach, but I’m not sure if it’s the best way, since I can’t seem to get OpenAI to access the data from Google Sheets — it might be due to incorrect parameters.
Do you think it would be better to use a simpler method? It seems like a relatively straightforward project.
Sure, if I understand correctly, what you want to do is make a conversation AI use tools, like spreadsheet, for instance, right?
Here is a short example for you:
This is the most basic example of how to allow the AI Agent (in this case based on OpenAI chat model) use spread sheet to get information.
The dialog looks like this:
- [me] What is 11th letter in the alphabet?
- [ai] The 11th letter in the alphabet is "k".
- [me] What is the position of the letter "c"?
- [ai] The position of the letter "c" in the English alphabet is 3.
- [me] Which index is letter z?
- [ai] The letter "z" is at index 26 in the alphabet.
All provided answer were gathered from the sheet and were not based on AI’s own knowledge .
And the spreadsheet looks like this:
Sheet content
Letter | Number |
---|---|
a | 1 |
b | 2 |
c | 3 |
d | 4 |
e | 5 |
f | 6 |
g | 7 |
h | 8 |
i | 9 |
j | 10 |
k | 11 |
l | 12 |
m | 13 |
n | 14 |
o | 15 |
p | 16 |
q | 17 |
r | 18 |
s | 19 |
t | 20 |
u | 21 |
v | 22 |
w | 23 |
x | 24 |
y | 25 |
z | 26 |
From this point you can add other things - like adding information, adding memory to the conversation etc.
the project
You must create an AI Agent (using n8n only) that is capable of:
- Reading and editing data in a spreadsheet dynamically (by ID, city, skill, etc.).
- Updating records based on commands (e.g., “The person with ID 202 changes their car to ‘Honda’”).
- Filtering data (e.g., “Which people have knowledge in JavaScript and live in São Paulo?”).
- Adding or removing skills (e.g., “Add Excel for Amanda”, “Remove Zapier from everyone”).
This is the project. I’m having a lot of difficulty because it’s my first project, and the recruiters encouraged us to ask for help in the n8n community.
The spreadsheet they provided to work with
- n8n running locally via Docker
- Real webhook with authentication
- OpenAI node (Create Chat Completion)
- Google Sheets spreadsheet
- Integration via Google Cloud OAuth2
- Google Sheets node (Lookup rows in sheet)
- Set node to structure the data
This is the point where I stopped. I’ve used these nodes, but I don’t know if this is the best path for my project. I had help from ChatGPT to create it.
Problem in node ‘Code’
User command not found. [line 21]
Output:
{
“errorMessage”: “Comando do usuário não encontrado. [line 21]”,
“errorDetails”: {},
“n8nDetails”: {
“nodeName”: “Code”,
“nodeType”: “n8n-nodes-base.code”,
“nodeVersion”: 2,
“n8nVersion”: “1.100.1 (Self Hosted)”,
“binaryDataMode”: “default”,
“stackTrace”: [
“Error: Comando do usuário não encontrado.”,
" at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/dist/nodes/Code:21:9",
" at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/dist/nodes/Code:64:2",
" at VM2 Wrapper.apply (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@[email protected]/node_modules/@n8n/vm2/lib/bridge.js:490:11)“,
" at NodeVM.run (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@[email protected]/node_modules/@n8n/vm2/lib/nodevm.js:497:23)”,
" at JavaScriptSandbox.runCodeAllItems (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/nodes/Code/JavaScriptSandbox.ts:73:36)“,
" at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/nodes/Code/Code.node.ts:155:28)”,
" at WorkflowExecute.runNode (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@[email protected][email protected][email protected][email protected]_/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1193:32)“,
" at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@[email protected][email protected][email protected][email protected]_/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1542:38”,
" at processTicksAndRejections (node:internal/process/task_queues:105:5)“,
" at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@[email protected][email protected][email protected][email protected]_/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:2108:11”
]
}
}
Based on the error, you are trying to run something that isn’t available…
// Get inputs
const sheetInput = $input.all(0);
const webhookInput = $input.all(1);
// Safety checks
if (!sheetInput || !Array.isArray(sheetInput)) {
throw new Error(“Sheet input is not an array.”);
}
if (!webhookInput || webhookInput.length === 0) {
throw new Error(“Webhook input not found.”);
}
// Get user’s command
const command = webhookInput[0].json.body?.comando || webhookInput[0].json.comando;
if (!command) {
throw new Error(“User command not found.”);
}
// Build sheet data text
const sheetText = sheetInput.map(item => {
const d = item.json;
return ${d.ID} | ${d.Name} | ${d.Car} | ${d["City of Origin"]} | ${d.Skills}
;
}).join(“\n”);
// Build final prompt
const prompt = `These are the spreadsheet
this is my code
created this workflow with the help of AI, but my actual need is simply to read and update data in a spreadsheet, and have the AI respond in a friendly way. However, with this current workflow, I haven’t been able to move forward — I’ve already spent almost 20 hours on the same problem without solving it. The AI keeps giving me solutions that just lead to new errors.
Do you think that, since it’s a simple project, I should just start over from scratch, following an easier path?
If you need more information about my project, please let me know.
I think you need to take another look at the example i sent before and start expanding it. It already includes the ai portion and the spreadsheet portion.
Hey! It sounds like the Lookup node isn’t getting the right input. I’d suggest checking if the key you’re using to match (like an ID or email) is actually being passed from the webhook. You can add a Set node before the Lookup to inspect what data is coming through. Let me know what your Lookup settings are — happy to help troubleshoot!