AI Agent + Chat Trigger only works for first message in editor test chat

Hi,

I’m testing a simple workflow using the editor chat UI:

When chat message received
      ↓
AI Agent
      ↓
OpenAI Chat Model

In the AI Agent node:

  • Source for Prompt: Define below

  • Prompt: {{$json.chatInput}}

What happens:

  1. Click Execute workflow

  2. Send first message (hello)

  3. AI Agent responds correctly

  4. Send second message (how are you)

  5. AI Agent fails with:

No prompt specified

Inspecting the node shows the input is:

[ {} ]

so chatInput is missing.

Strangely, if I deactivate and reactivate the nodes, the workflow works again for one message, but then fails again on the next message.

So effectively the workflow only works once per node reset.

Has anyone seen this behaviour with Chat Trigger + AI Agent in editor test mode? Is there something I’m missing, or could this be an editor session issue? Please help as I am feel that I am loosing my mind after four days of seemingly

trying everything!!

workflow code below:

{
“name”: “My workflow”,
“nodes”: [
{
“parameters”: {
“pollTimes”: {
“item”: [
{
“mode”: “everyMinute”
}
]
},
“triggerOn”: “specificFolder”,
“folderToWatch”: {
“__rl”: true,
“value”: “1nSmFTttv7ml1G1ImHb2ZfOSUeTj1MpeQ”,
“mode”: “list”,
“cachedResultName”: “n8n_demo”,
“cachedResultUrl”: “https://drive.google.com/drive/folders/1nSmFTttv7ml1G1ImHb2ZfOSUeTj1MpeQ”
},
“event”: “fileCreated”,
“options”: {}
},
“type”: “n8n-nodes-base.googleDriveTrigger”,
“typeVersion”: 1,
“position”: [
-1504,
-256
],
“id”: “e1644b5c-ced1-48bd-8d1c-876fde82bf1e”,
“name”: “Google Drive Trigger”,
“credentials”: {
“googleDriveOAuth2Api”: {
“id”: “BDdaqU7W1KtXkQ2z”,
“name”: “Google Drive OAuth2 API”
}
}
},
{
“parameters”: {
“operation”: “download”,
“fileId”: {
“__rl”: true,
“value”: “={{ $json.id }}”,
“mode”: “id”
},
“options”: {}
},
“type”: “n8n-nodes-base.googleDrive”,
“typeVersion”: 3,
“position”: [
-1312,
-256
],
“id”: “9c9153ed-188f-4774-995c-5ae95530c59f”,
“name”: “Download file”,
“credentials”: {
“googleDriveOAuth2Api”: {
“id”: “BDdaqU7W1KtXkQ2z”,
“name”: “Google Drive OAuth2 API”
}
}
},
{
“parameters”: {
“mode”: “insert”,
“pineconeIndex”: {
“__rl”: true,
“value”: “demo4”,
“mode”: “list”,
“cachedResultName”: “demo4”
},
“options”: {
“pineconeNamespace”: “FAQ”
}
},
“type”: “@n8n/n8n-nodes-langchain.vectorStorePinecone”,
“typeVersion”: 1.3,
“position”: [
-1104,
-256
],
“id”: “3e26a8d5-b23a-4041-9d4b-e73bd88a02c1”,
“name”: “Pinecone Vector Store”,
“credentials”: {
“pineconeApi”: {
“id”: “znnSRT2QGe3OvBAr”,
“name”: “Demo4”
}
}
},
{
“parameters”: {
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.embeddingsOpenAi”,
“typeVersion”: 1.2,
“position”: [
-1136,
-48
],
“id”: “ff35c7cd-9da1-4afa-94c9-c903b830f57b”,
“name”: “Embeddings OpenAI”,
“credentials”: {
“openAiApi”: {
“id”: “grQsMqhepgwvfwCc”,
“name”: “n8n free OpenAI API credits”
}
}
},
{
“parameters”: {
“dataType”: “binary”,
“textSplittingMode”: “custom”,
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.documentDefaultDataLoader”,
“typeVersion”: 1.1,
“position”: [
-960,
-48
],
“id”: “d7a783b4-087b-4c44-a813-edfaea941182”,
“name”: “Default Data Loader”
},
{
“parameters”: {
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter”,
“typeVersion”: 1,
“position”: [
-1264,
176
],
“id”: “4699c0c6-6676-4ad6-a57b-ea0289b604ca”,
“name”: “Recursive Character Text Splitter”
},
{
“parameters”: {
“promptType”: “define”,
“text”: “={{$json.chatInput}}”,
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.agent”,
“typeVersion”: 3.1,
“position”: [
-144,
-96
],
“id”: “78080068-cbbe-4652-b7c9-453d7c78a889”,
“name”: “AI Agent”
},
{
“parameters”: {
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.chatTrigger”,
“typeVersion”: 1.4,
“position”: [
-336,
-80
],
“id”: “edc485ea-fe37-4bbd-80f5-bcf2106d3267”,
“name”: “When chat message received”,
“webhookId”: “996b8699-ba59-4563-bb2a-2b54ca29c9ee”
},
{
“parameters”: {
“model”: {
“__rl”: true,
“value”: “gpt-4o-mini”,
“mode”: “list”,
“cachedResultName”: “gpt-4o-mini”
},
“builtInTools”: {},
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.lmChatOpenAi”,
“typeVersion”: 1.3,
“position”: [
-176,
160
],
“id”: “d97971cf-afbc-472b-bace-c5a3835ef1eb”,
“name”: “OpenAI Chat Model”,
“credentials”: {
“openAiApi”: {
“id”: “grQsMqhepgwvfwCc”,
“name”: “n8n free OpenAI API credits”
}
}
}
],
“pinData”: {},
“connections”: {
“Google Drive Trigger”: {
“main”: [
[
{
“node”: “Download file”,
“type”: “main”,
“index”: 0
}
]
]
},
“Download file”: {
“main”: [
[
{
“node”: “Pinecone Vector Store”,
“type”: “main”,
“index”: 0
}
]
]
},
“Embeddings OpenAI”: {
“ai_embedding”: [
[
{
“node”: “Pinecone Vector Store”,
“type”: “ai_embedding”,
“index”: 0
}
]
]
},
“Default Data Loader”: {
“ai_document”: [
[
{
“node”: “Pinecone Vector Store”,
“type”: “ai_document”,
“index”: 0
}
]
]
},
“Recursive Character Text Splitter”: {
“ai_textSplitter”: [
[
{
“node”: “Default Data Loader”,
“type”: “ai_textSplitter”,
“index”: 0
}
]
]
},
“When chat message received”: {
“main”: [
[
{
“node”: “AI Agent”,
“type”: “main”,
“index”: 0
}
]
]
},
“OpenAI Chat Model”: {
“ai_languageModel”: [
[
{
“node”: “AI Agent”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
}
},
“active”: false,
“settings”: {
“executionOrder”: “v1”,
“binaryMode”: “separate”,
“availableInMCP”: false
},
“versionId”: “d3879151-720d-4a3f-a4f6-26bb13f5f371”,
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “d4a0bffc8c3932b0483d55b8dad47b7eb1002dc8762da094d201464692427a06”
},
“id”: “i63jEz20gRRXMWtI”,
“tags”: [
{
“updatedAt”: “2026-03-05T16:55:15.318Z”,
“createdAt”: “2026-03-05T16:55:15.318Z”,
“id”: “GxhO7fjtX0B6itoi”,
“name”: “MyFirstWorkFlow”
}
]
}

Thanks.

1 Like

Hi @Ajit_Rai Welcome!
Consider using some expression which uses first chat input for the AI agent input, like something like this would work
{{ $('When chat message received').first().json.chatInput }}
instead of your regular {{$json.chatInput}}

hey @Ajit_Rai

The fix might be just to hit Publish. Once the workflow is active, the Chat Trigger registers its production webhook permanently and conversations work correctly. The data is empty because the webhook isn’t registered at all,

Try this and let me know ! :crossed_fingers:

I too faced the same issue and after wrapping my head for a long time, I just decided to copy the nodes to a new workflow and it worked there.

I suspect it could be an n8n bug when there are multiple triggers in the same workflow.

hi @jitesh , did you copy the triggers in one workflow or each trigger in a separate one ?

Sorry, I accidently missed the following from my main question, does this help? “Tested in n8n Cloud editor chat. First message works but all subsequent messages fail unless nodes are manually toggled off/on.“ thanks in advance for your help!

This is a known quirk with the Chat Trigger + AI Agent combo in the editor test chat. The root cause: in test mode, the Chat Trigger generates a new sessionId for each execution run rather than maintaining a consistent one across messages in the same chat window. When the AI Agent tries to retrieve conversation history on the second message, the memory buffer either returns empty (no matching session) or the chatInput binding resolves to {} because the data pipeline reset.

A few things to check:

1. Are you using a memory sub-node?
If yes – Simple Buffer Memory or Window Buffer Memory – these use sessionId as the lookup key. In test mode that key changes between clicks of “Execute workflow”, which wipes the context. This is expected/by-design behavior in test mode only. In production (webhook), the sessionId persists properly across a conversation.

2. The “Define below” prompt binding issue:
When Source for Prompt is set to “Define below” and the input is [{}], the {{$json.chatInput}} expression evaluates to empty string. The Agent node then throws “No prompt specified” because it treats empty string as no input. Try switching Source to “Auto-detect input” instead – it pulls from the triggering node automatically and is more resilient to the session reset.

3. Quick test to confirm:
Switch your AI Agent to “Auto-detect input” and re-run. If the second message works, it was the expression binding. If it still fails, the issue is session/memory related and you can safely ignore it in test mode – it will work correctly once deployed.

This one trips up a lot of people because the test chat UI looks like it should maintain state. It does not – each “Execute workflow” click is a fresh execution context. Real webhook deployments handle this correctly.

the fix is in how the prompt source is set. when you use Source for Prompt: Define below with {{$json.chatInput}}, it only works on the first execution — after that the data path breaks in test mode.

change Source for Prompt to ”Connected Chat Trigger node” in the AI Agent settings. the agent then pulls the input directly from the trigger instead of relying on $json.chatInput, and it works for every message.