Return data from child script to parent script

I’m working on a bot that takes data from a chat room and needs to process it in one of the child scripts and return back a response.
Previously when the whole process was in one script there were no problems. Now when I split the scripts the response comes back empty. Although in the logs I see that there is data.

Can the main script accept a Webhook Response node from the child script?

Empty Response Aswer.

Please share your workflow

Parent Flow


(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • Running n8n via (n8n cloud):

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

@IndieDev , as I understand it is your parent flow that has to reply based on the data in the subflow. The parent flow will get the output of the last executed subflow. However, I doubt that it could be the Webhook Response.

I think what you need to do is to remove Webhook Response from the subflow and put it back into the parent flow connecting it to the Execute Workflow that triggered the subflow.

I believe that the subflow does not contain just a Webhook Response node, does it? Thus, you can leave the processing logic in the subflow but do not end it with Webhook Response. Once the parent flow receives the data of the last executed node in the sublow you can compose your response with Webhook Response in the parent flow (instead of subflow).

However, you have two Execute Workflow nodes. Are both subflows currently have Webhook Response nodes? Is your parent flow expected to respond depending of the data in both of them? If so, your parent flow would be a bit more complex However, still the same principle applies.

1 Like

Yes, there is a webhook response node in two subflows. Did I understand correctly that it is better to complete the subflow with a Set node and save the data into it, and then pass the data from the set to the webhook response node through the Execute Workflow node?

@IndieDev , yes, that should work. Though, it doesn’t have to be a set. It could be any node that produces output. However, if that data needs to be shaped to a specific format or structure, then Set normally does it well. In other words, the last node’s output in the subflow becomes the output of the Execute Workflow node in the parent flow that initiated the subflow.

For clarity, the parent workflow would look something like below assuming the response depends on the data from one of the subflows and you never have a scenario that both subflows are initiated in the same execution (after all you do use IF node to segregate the scenarios).

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