I'm encountering an issue with a workflow that uses an AI Agent. This agent is supposed to call a sub-workflow and pass it information from a preceding sub-workflow. When I initiate an execution, the information is indeed provided in the request to the sub-workflow, but the sub-workflow doesn't seem to be receiving it.
The sub-workflow that consistently fails is the very last tool, named cold_outreach_message
.
My agent workflow:
{
“nodes”: [
{
“parameters”: {
“promptType”: “define”,
“text”: “=You are a helpful assistant for Lead Generation in a company specialized in AI Automation.
## Your Task:
Process the following request:
{{ $json.message.text }}
—
## Action Required:
1. Scrape Leads Tool
- Always call the Scrape Leads tool first.
- Run it only once and wait until it has finished before proceeding.
- Capture the `Sheet_ID` from the tool’s output – this is required for the following steps.
2. Decision Process:
- If the prompt requires, proceed with the following:
a) Search LinkedIn Profiles Tool
- Only call this tool if necessary.
- Use the `Sheet_ID` from the Scrape Leads tool.
- Wait until it is finished before moving to the next step.
b) Cold Outreach Message Tool
- Only call this tool if necessary.
- Use the `Sheet_ID` from the Scrape Leads tool in your request.
- Wait until it is finished before moving to the next step.
3. Telegram Notification:
- Always send a Telegram notification when the request is processed—successful or failed.
- Provide the user’s first name: `{{ $json.message.from.first_name }}`
- Include the chat_id: `{{ $json.message.chat.id }}`
- This step is mandatory and should only be performed once.
—
## Execution Order (Strictly Follow This Sequence):
1. Scrape Leads Tool (Always required)
2. Search LinkedIn Profiles Tool (If applicable)
3. Cold Outreach Message Tool (If applicable)
4. Telegram Response (Always required)
—
## Execution Rules (Non-Negotiable):
- Call each tool exactly once.
- Wait for each tool to fully complete before calling the next one.
- Never run two tools at the same time.
- Always call Scrape Leads and Telegram Response – they are mandatory.
—
## Telegram Response Format (VERY IMPORTANT!):
✅ Successful Request:
```json
{
"message": "The request was generated successfully. First name: {{ $json.message.from.first_name }}, chat_id: {{ $json.message.chat.id }}"
}
❌ Failed Request:
json
Kopieren
Bearbeiten
{
"message": "The request failed. Please try again. First name: {{ $json.message.from.first_name }}, chat_id: {{ $json.message.chat.id }}"
}
Error Handling:
If any tool fails:
Stop the process immediately.
Notify the user via the Telegram Response tool.
If Scrape Leads fails, do not proceed to other tools.
Always provide clear, user-friendly error messages.
The number one most important thing you have to keep in mind is, that you wait until a tool responds with "done", before you take any further action.”,
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.agent”,
“typeVersion”: 1.7,
“position”: [
440,
0
],
“id”: “dd2311bb-4cd4-4851-8772-b44b22f3523b”,
“name”: “AI Agent”
},
{
“parameters”: {
“model”: {
“__rl”: true,
“mode”: “list”,
“value”: “gpt-4o-mini”
},
“options”: {
“maxTokens”: 500
}
},
“type”: “@n8n/n8n-nodes-langchain.lmChatOpenAi”,
“typeVersion”: 1.2,
“position”: [
300,
240
],
“id”: “bdceee87-5cdf-4c2e-aafa-ff05db1c2dbf”,
“name”: “OpenAI Chat Model”,
“credentials”: {
“openAiApi”: {
“id”: “0X52sLLNhTOwyF3Y”,
“name”: “OpenAi account”
}
}
},
{
“parameters”: {
“sessionIdType”: “customKey”,
“sessionKey”: “={{ $json.message.text }}”
},
“type”: “@n8n/n8n-nodes-langchain.memoryBufferWindow”,
“typeVersion”: 1.3,
“position”: [
460,
240
],
“id”: “800179e0-d14d-48ed-8b31-eaac7fbac080”,
“name”: “Window Buffer Memory”
},
{
“parameters”: {
“name”: “Scrape_Leads”,
“description”: “Use this tool to find the leads and put them into a google sheet. Execute it only once, wait until it has finished before taking further action.”,
“workflowId”: {
“__rl”: true,
“value”: “jNzhhmmrBdTkGdPM”,
“mode”: “list”,
“cachedResultName”: “Scrape Leads”
},
“workflowInputs”: {
“mappingMode”: “defineBelow”,
“value”: {
“query”: “={{ $fromAI(‘query’, , 'string') }}" },
“matchingColumns”: [],
“schema”: [
{
“id”: “query”,
“displayName”: “query”,
“required”: false,
“defaultMatch”: false,
“display”: true,
“canBeUsedToMatch”: true,
“type”: “string”,
“removed”: false
}
],
“attemptToConvertTypes”: false,
“convertFieldsToString”: false
}
},
“type”: “@n8n/n8n-nodes-langchain.toolWorkflow”,
“typeVersion”: 2,
“position”: [
600,
240
],
“id”: “6d869b02-7246-4afb-b548-63584b91aa8c”,
“name”: “Call n8n Workflow Tool”
},
{
“parameters”: {
“updates”: [
“message”
],
“additionalFields”: {}
},
“type”: “n8n-nodes-base.telegramTrigger”,
“typeVersion”: 1.1,
“position”: [
180,
0
],
“id”: “b96bcf91-7b3b-4cf6-bc5b-ead6976acdb0”,
“name”: “Telegram Trigger”,
“webhookId”: “77a7f566-2d8d-4e54-81d6-1f9208860bdb”,
“credentials”: {
“telegramApi”: {
“id”: “icpYMfUB7VD3Ieuo”,
“name”: “Telegram account”
}
}
},
{
“parameters”: {
“name”: “Telegram_response_tool”,
“description”: “Call this tool to let the user know wether their request was successfull. “,
“workflowId”: {
“__rl”: true,
“value”: “CkEHeca37bANBM0Q”,
“mode”: “list”,
“cachedResultName”: “Telegram Response Tool”
},
“workflowInputs”: {
“mappingMode”: “defineBelow”,
“value”: {
“query”: “={{ $fromAI('query', , ‘string’) }}
chat_ID: {{ $json.message.chat.id }}
first_name: {{ $json.message.from.first_name }}”
},
“matchingColumns”: [
“query”
],
“schema”: [
{
“id”: “query”,
“displayName”: “query”,
“required”: false,
“defaultMatch”: false,
“display”: true,
“canBeUsedToMatch”: true,
“type”: “string”,
“removed”: false
}
],
“attemptToConvertTypes”: false,
“convertFieldsToString”: false
}
},
“type”: “@n8n/n8n-nodes-langchain.toolWorkflow”,
“typeVersion”: 2,
“position”: [
760,
240
],
“id”: “95e9d617-1b63-456f-a33b-208377b01356”,
“name”: “Call n8n Workflow Tool1”
},
{
“parameters”: {
“name”: “Search_LinkedIn_Profiles”,
“description”: “Call this tool to search the LinkedIn Profiles for key information on the lead.”,
“workflowId”: {
“__rl”: true,
“value”: “ONZpigKtSfpYJRs4”,
“mode”: “list”,
“cachedResultName”: “Search LinkedIn Profiles”
},
“workflowInputs”: {
“mappingMode”: “defineBelow”,
“value”: {},
“matchingColumns”: [
“query”
],
“schema”: [
{
“id”: “query”,
“displayName”: “query”,
“required”: false,
“defaultMatch”: false,
“display”: true,
“canBeUsedToMatch”: true,
“type”: “string”,
“removed”: false
}
],
“attemptToConvertTypes”: false,
“convertFieldsToString”: false
}
},
“type”: “@n8n/n8n-nodes-langchain.toolWorkflow”,
“typeVersion”: 2,
“position”: [
920,
240
],
“id”: “f5ec8b72-a2a0-4bcd-86c4-1520b8895d01”,
“name”: “Call n8n Workflow Tool2”
},
{
“parameters”: {
“name”: “Cold_outreach_message”,
“description”: “Call this tool to write cold outreach messages for each lead.”,
“workflowId”: {
“__rl”: true,
“value”: “XOyBxLLfgKcegnhe”,
“mode”: “list”,
“cachedResultName”: “Personalized Outreach message”
},
“workflowInputs”: {
“mappingMode”: “defineBelow”,
“value”: {
“query”: “=”
},
“matchingColumns”: [
“query”
],
“schema”: [
{
“id”: “query”,
“displayName”: “query”,
“required”: false,
“defaultMatch”: false,
“display”: true,
“canBeUsedToMatch”: true,
“type”: “string”,
“removed”: false
}
],
“attemptToConvertTypes”: false,
“convertFieldsToString”: false
}
},
“type”: “@n8n/n8n-nodes-langchain.toolWorkflow”,
“typeVersion”: 2,
“position”: [
1080,
240
],
“id”: “70a95c4b-6a34-4061-8f3b-69ff92d2a644”,
“name”: “Call n8n Workflow Tool3”
}
],
“connections”: {
“OpenAI Chat Model”: {
“ai_languageModel”: [
[
{
“node”: “AI Agent”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“Window Buffer Memory”: {
“ai_memory”: [
[
{
“node”: “AI Agent”,
“type”: “ai_memory”,
“index”: 0
}
]
]
},
“Call n8n Workflow Tool”: {
“ai_tool”: [
[
{
“node”: “AI Agent”,
“type”: “ai_tool”,
“index”: 0
}
]
]
},
“Telegram Trigger”: {
“main”: [
[
{
“node”: “AI Agent”,
“type”: “main”,
“index”: 0
}
]
]
},
“Call n8n Workflow Tool1”: {
“ai_tool”: [
[
{
“node”: “AI Agent”,
“type”: “ai_tool”,
“index”: 0
}
]
]
},
“Call n8n Workflow Tool2”: {
“ai_tool”: [
[
{
“node”: “AI Agent”,
“type”: “ai_tool”,
“index”: 0
}
]
]
},
“Call n8n Workflow Tool3”: {
“ai_tool”: [
[
{
“node”: “AI Agent”,
“type”: “ai_tool”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “7cc94d9d5a5a99feab1d7267c120a791ba9d6ff1a180bcd3c7bdf253d1018966”
}
}
My sub-workflow:
{
“nodes”: [
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “43fe0561-67eb-40b1-9f6e-6fb626bd6ee1”,
“name”: “response”,
“value”: “done”,
“type”: “string”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
1800,
-80
],
“id”: “cf62f656-db73-4690-9c3a-12231d1c0230”,
“name”: “Edit Fields”
},
{
“parameters”: {
“options”: {}
},
“type”: “n8n-nodes-base.splitInBatches”,
“typeVersion”: 3,
“position”: [
600,
0
],
“id”: “77772621-fc33-4b25-b218-eca76c4b1aa2”,
“name”: “Loop Over Items”
},
{
“parameters”: {
“modelId”: {
“__rl”: true,
“value”: “gpt-4”,
“mode”: “list”,
“cachedResultName”: “GPT-4”
},
“messages”: {
“values”: [
{
“content”: “Task:
Write a short, natural-sounding, and effective cold outreach message based on:
The recipient’s LinkedIn profile URL ({{linkedInUrl}}).
A few key sentences with relevant details about them ({{keyInformation}}).
Important Rules:
Extract the recipient’s first name from either {{linkedInUrl}} or {{keyInformation}}.
✅ Use the first name only if it appears to be real (not a username or handle).
❌ If no real first name is found, start the message with a general friendly opening.
Avoid robotic or awkward phrasing—make it sound natural.
Keep it under 80 words—concise and engaging.
Make the opening relevant by referencing something from {{keyInformation}} (e.g., their role, achievements, or interests).
Clearly state how Automation Intelligence can add value based on the provided details.
End with a simple, low-pressure call to action, like requesting a quick chat. This call to action should not be a question, but instead a polite request.
Message Structure:
If first name is found:
Hi [FirstName],
If no first name is found:
Hi there,
I came across your LinkedIn profile and was really impressed by your work in [mention relevant field from key info]. At Automation Intelligence, we specialize in helping professionals like you streamline workflows and boost productivity.
Let's have a quick chat next week to explore how our solutions could fit your needs [This part should not be formulated as a question, but instead as a demand, still friendly though, don´t use any weird formulations, keep it simple and normal language]. Let me know when you’re available!
Best,
Nicolas
Assistant, Automation Intelligence
[stay as close to this message at possible, while still personalizing it]
Be aware that this message is for LinkedIn direct messages, so do not include a subject line, just the message itself.
Also make sure that your sound is casual but still professional.
”,
“role”: “system”
},
{
“content”: “=LinkedIn url: {{ $json[‘LinkedIn URLs’] }}
Key information: {{ $json[‘key information’] }}”
}
]
},
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.openAi”,
“typeVersion”: 1.8,
“position”: [
820,
100
],
“id”: “3fa90dbb-485b-43c7-b9fb-c2f9d24f9b29”,
“name”: “OpenAI”,
“credentials”: {
“openAiApi”: {
“id”: “0X52sLLNhTOwyF3Y”,
“name”: “OpenAi account”
}
}
},
{
“parameters”: {
“operation”: “update”,
“documentId”: {
“__rl”: true,
“value”: “15mvxI614stCy0ipBd0mT1lHawVS8k0TRhTIfbAhn_8E”,
“mode”: “list”,
“cachedResultName”: “Lead Generation”,
“cachedResultUrl”: “ https://docs.google.com/spreadsheets/d/15mvxI614stCy0ipBd0mT1lHawVS8k0TRhTIfbAhn_8E/edit?usp=drivesdk”
},
“sheetName”: {
“__rl”: true,
“value”: “={{ $(‘Code’).item.json.number }}”,
“mode”: “id”
},
“columns”: {
“mappingMode”: “defineBelow”,
“value”: {
“LinkedIn_url”: “={{ $(‘Loop Over Items’).item.json.LinkedIn_url }}”,
“Cold_outreach”: “={{ $json.content }}”
},
“matchingColumns”: [
“LinkedIn_url”
],
“schema”: [
{
“id”: “LinkedIn_url”,
“displayName”: “LinkedIn_url”,
“required”: false,
“defaultMatch”: false,
“display”: true,
“type”: “string”,
“canBeUsedToMatch”: true,
“removed”: false
},
{
“id”: “Key_information”,
“displayName”: “Key_information”,
“required”: false,
“defaultMatch”: false,
“display”: true,
“type”: “string”,
“canBeUsedToMatch”: true
},
{
“id”: “Cold_outreach”,
“displayName”: “Cold_outreach”,
“required”: false,
“defaultMatch”: false,
“display”: true,
“type”: “string”,
“canBeUsedToMatch”: true
},
{
“id”: “row_number”,
“displayName”: “row_number”,
“required”: false,
“defaultMatch”: false,
“display”: true,
“type”: “string”,
“canBeUsedToMatch”: true,
“readOnly”: true,
“removed”: true
}
],
“attemptToConvertTypes”: false,
“convertFieldsToString”: false
},
“options”: {}
},
“type”: “n8n-nodes-base.googleSheets”,
“typeVersion”: 4.5,
“position”: [
1420,
100
],
“id”: “d4fbcf44-8d33-4e8e-8e7e-eaa8e8350a43”,
“name”: “Google Sheets1”,
“credentials”: {
“googleSheetsOAuth2Api”: {
“id”: “Tiuc7BAomIakw1eJ”,
“name”: “Google Sheets account”
}
}
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “247c0f80-4fdd-4167-8fad-916c0ceaf8b8”,
“name”: “content”,
“value”: “={{ $json.message.content }}”,
“type”: “string”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
1180,
100
],
“id”: “bb065090-bf3c-4ee5-b5f1-30d159cc5b86”,
“name”: “Edit Fields1”
},
{
“parameters”: {
“documentId”: {
“__rl”: true,
“value”: “15mvxI614stCy0ipBd0mT1lHawVS8k0TRhTIfbAhn_8E”,
“mode”: “list”,
“cachedResultName”: “Lead Generation”,
“cachedResultUrl”: “ https://docs.google.com/spreadsheets/d/15mvxI614stCy0ipBd0mT1lHawVS8k0TRhTIfbAhn_8E/edit?usp=drivesdk”
},
“sheetName”: {
“__rl”: true,
“value”: “={{ $json.number }}”,
“mode”: “id”
},
“options”: {}
},
“type”: “n8n-nodes-base.googleSheets”,
“typeVersion”: 4.5,
“position”: [
280,
0
],
“id”: “f90b7289-86cf-4c61-a0bc-f77350c4d45d”,
“name”: “Google Sheets”,
“credentials”: {
“googleSheetsOAuth2Api”: {
“id”: “Tiuc7BAomIakw1eJ”,
“name”: “Google Sheets account”
}
}
},
{
“parameters”: {
“inputSource”: “jsonExample”,
“jsonExample”: “{
"query": "Ecommerce from France, Sheet_ID: 345223553"
}”
},
“type”: “n8n-nodes-base.executeWorkflowTrigger”,
“typeVersion”: 1.1,
“position”: [
-180,
0
],
“id”: “de4bf6ca-d004-4e7d-ad3d-073e5967a707”,
“name”: “When Executed by Another Workflow”
},
{
“parameters”: {
“jsCode”: “// Input data from previous node
const input = $input.first().json.query; // e.g., "Sheet_ID: 440618878"
// Extract number using regular expression
const extractedNumber = input.match(/d+/)[0];
// Return the extracted number
return [
{
number: extractedNumber
}
];
”
},
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
60,
0
],
“id”: “cd6edb6d-24af-49d3-9e7e-ccdf845566c2”,
“name”: “Code”
}
],
“connections”: {
“Edit Fields”: {
“main”: [
]
},
“Loop Over Items”: {
“main”: [
[
{
“node”: “Edit Fields”,
“type”: “main”,
“index”: 0
}
],
[
{
“node”: “OpenAI”,
“type”: “main”,
“index”: 0
}
]
]
},
“OpenAI”: {
“main”: [
[
{
“node”: “Edit Fields1”,
“type”: “main”,
“index”: 0
}
]
]
},
“Google Sheets1”: {
“main”: [
[
{
“node”: “Loop Over Items”,
“type”: “main”,
“index”: 0
}
]
]
},
“Edit Fields1”: {
“main”: [
[
{
“node”: “Google Sheets1”,
“type”: “main”,
“index”: 0
}
]
]
},
“Google Sheets”: {
“main”: [
[
{
“node”: “Loop Over Items”,
“type”: “main”,
“index”: 0
}
]
]
},
“When Executed by Another Workflow”: {
“main”: [
[
{
“node”: “Code”,
“type”: “main”,
“index”: 0
}
]
]
},
“Code”: {
“main”: [
[
{
“node”: “Google Sheets”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “7cc94d9d5a5a99feab1d7267c120a791ba9d6ff1a180bcd3c7bdf253d1018966”
}
}
Information on your callin.io setup:
callin.io version: 1.78.0
Database (default: SQLite): SQLite
callin.io EXECUTIONS_PROCESS setting (default: own, main): main
Running callin.io via (Docker, npm, callin.io cloud, desktop app): docker
Operating system: AWS Lightsail with Easypanel
I hope I added the code correctly with json
, if not, how do I add such a code field in my topic?
This is all the information I could retrieve from your code.
Could you please share the specific section that is causing the error?
Please use a code block like this:
Your JSON code here
If you configure it correctly, you should be able to see your workflow displayed like this:
My agent workflow:
My sub-workflow:
Is it just me, or is the query field empty in that last tool you mentioned? Perhaps try explicitly entering the ‘fromAI’ placeholder there. If that doesn't resolve the issue, try inputting some dummy data, similar to the pinned data in the subflow execution you provided, to determine if the agent is not populating the query correctly. You may need to add a placeholder description for the tool's query field to guide the AI on what information to include.
Hello,
Your tools seem to be missing descriptions for the $fromAI
function. You need to specify what you want for each field.
Here's an example:
{{ $fromAI("message","The outreach message you are going to send", "string") }}
If my response answers your question, please consider marking it as a solution.
The third tool also lacks mapping in the query field and is configured identically, yet it functions correctly. I will test your proposed solution.
I wasn't aware that functionality existed, thank you! I'll test it out right away.
This thread was automatically closed 7 days following the last response. New replies are no longer permitted.