How to output to ai agent from subwork flow

Describe the problem/error/question

my ai agent tool connect getArea_tool, but getArea_tool subwork flow no return field to choose. How make the subwork flow display return output field?

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

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

how to show subworkflow no Field to Return? Or get data from subwork flow?

Hi @tytom2003

I copied and pasted your workflow and noticed that the company_area field is set to “Fixed”
Could you please change it to “Expression” and try again?

It should return the expected result if the AI agent calls it.

i change to expression. But i is no return to field show.

Okay, can the AI agent in the first place call the sub-workflow?

And if it can call it but there are no outputs, maybe you could share the sub-workflow so we can check if the error is coming from there..

Hello @tytom2003 ,
The reason getArea_tool shows no return fields is because your sub-workflow (idenfityAddress) isn’t sending any structured output. n8n only exposes fields if the sub-workflow ends with a Return Data (or Respond to Webhook) node.

Fix:

  1. Open your sub-workflow.

  2. Add a Return Data node at the end. For example:

    {
      "collection_day": "Wednesday",
      "area": "Green Street"
    }
    
    
  3. Save it, then go back to your main workflow. Now getArea_tool will display those fields for mapping.

Always return structured JSON from sub-workflows so parent workflows (and your AI Agent) can use the fields easily.

 

{
“nodes”: [
{
“parameters”: {
“promptType”: “define”,
“text”: “={{ $json.area }}”,
“messages”: {
“messageValues”: [
{
“message”: “=You are an address recognition assistant. Based on the input Hong Kong address, identify which district it belongs to. Use keywords like ‘Wan Chai’ for Wai Chai, ‘Mong Kok’ for Yau Tsim Mong District, and ‘Sha Tin’ for Sha Tin District, and reply with the district name directly.”
}
]
},
“batching”: {}
},
“type”: “@n8n/n8n-nodes-langchain.chainLlm”,
“typeVersion”: 1.7,
“position”: [
-80,
-144
],
“id”: “393853ae-4c0a-409e-9027-1e08f3ba648c”,
“name”: “Basic LLM Chain”
},
{
“parameters”: {
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.lmChatGoogleGemini”,
“typeVersion”: 1,
“position”: [
-128,
64
],
“id”: “6c04e2e3-1744-4222-a5d8-0d8641fad4ed”,
“name”: “Google Gemini Chat Model”,
“credentials”: {
“googlePalmApi”: {
“id”: “swfJscUV5Ki1dH8U”,
“name”: “Google Gemini(PaLM) Api account”
}
}
},
{
“parameters”: {
“workflowInputs”: {
“values”: [
{
“name”: “company_area”
}
]
}
},
“type”: “n8n-nodes-base.executeWorkflowTrigger”,
“typeVersion”: 1.1,
“position”: [
-336,
-144
],
“id”: “b56ace32-93f5-487b-835e-6d739eede271”,
“name”: “When Executed by Another Workflow”,
“alwaysOutputData”: true
},
{
“parameters”: {
“documentId”: {
“__rl”: true,
“value”: “1pWheh5i4vpFiWfy1VkH3fp4s_bZEnuOSbZsM35frhSc”,
“mode”: “list”,
“cachedResultName”: “area”,
“cachedResultUrl”: “https://docs.google.com/spreadsheets/d/1pWheh5i4vpFiWfy1VkH3fp4s_bZEnuOSbZsM35frhSc/edit?usp=drivesdk”
},
“sheetName”: {
“__rl”: true,
“value”: “gid=0”,
“mode”: “list”,
“cachedResultName”: “area”,
“cachedResultUrl”: “https://docs.google.com/spreadsheets/d/1pWheh5i4vpFiWfy1VkH3fp4s_bZEnuOSbZsM35frhSc/edit#gid=0”
},
“filtersUI”: {
“values”: [
{
“lookupColumn”: “area”,
“lookupValue”: “={{ $json.text }}”
}
]
},
“combineFilters”: “OR”,
“options”: {}
},
“type”: “n8n-nodes-base.googleSheets”,
“typeVersion”: 4.6,
“position”: [
240,
-144
],
“id”: “95880024-7118-431a-ab52-7d0edb34292d”,
“name”: “Get row(s) in sheet”,
“credentials”: {
“googleSheetsOAuth2Api”: {
“id”: “3Ydzd3RIDC8Y4NZE”,
“name”: “Google Sheets account”
}
}
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “fd75baee-e29e-4ded-a502-d0e77e12ec7f”,
“name”: “day”,
“value”: “={{ $json.day }}”,
“type”: “string”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
432,
-144
],
“id”: “90a6b7a4-e602-4e0e-9abe-87a35a6f0d06”,
“name”: “Edit Fields”,
“alwaysOutputData”: true,
“onError”: “continueRegularOutput”
}
],
“connections”: {
“Basic LLM Chain”: {
“main”: [
[
{
“node”: “Get row(s) in sheet”,
“type”: “main”,
“index”: 0
}
]
]
},
“Google Gemini Chat Model”: {
“ai_languageModel”: [
[
{
“node”: “Basic LLM Chain”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“When Executed by Another Workflow”: {
“main”: [
[
{
“node”: “Basic LLM Chain”,
“type”: “main”,
“index”: 0
}
]
]
},
“Get row(s) in sheet”: {
“main”: [
[
{
“node”: “Edit Fields”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “04695fa805d662a7ca811a5d9568e6cc080c07e6ec9f81360f8146eccb701cc6”
}
}

no Return Data node in my n8n.

Thanks for sharing, i can see there is an error in the Basic LLM Chain “Prompt”
image

this should be:

{{ $json.company_area }}

Please double-check the other nodes as well and try again..

i input wrong data. so, i change “Prompt (User Message)“ in LLM Agent. My subwork flow can get output data. Thank you very much.

1 Like

Glad it works now @tytom2003 :tada: :saluting_face:, can you please mark my post as the solution :white_check_mark:, thanks :heart:

your Return Data node is replaced by Respond to Webhook. To make your getArea_tool sub-workflow return fields:

  1. Open your sub-workflow (idenfityAddress).

  2. Add a Respond to Webhook node at the end.

  3. Configure it to send back JSON

  4. Save the workflow, then recheck the getArea_tool in your main workflow — you should now see those fields available.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.