diff --git a/packages/cli/src/WebhookHelpers.ts b/packages/cli/src/WebhookHelpers.ts index 9342a97cda..eafec28133 100644 --- a/packages/cli/src/WebhookHelpers.ts +++ b/packages/cli/src/WebhookHelpers.ts @@ -256,6 +256,10 @@ export async function executeWebhook( // Prepare everything that is needed to run the workflow const additionalData = await WorkflowExecuteAdditionalData.getBase(); + if (executionId) { + additionalData.executionId = executionId; + } + // Get the responseMode const responseMode = workflow.expression.getSimpleParameterValue( workflowStartNode, @@ -359,6 +363,7 @@ export async function executeWebhook( additionalData, NodeExecuteFunctions, executionMode, + runExecutionData ?? null, ); Container.get(WorkflowStatisticsService).emit('nodeFetchedData', { workflowId: workflow.id, diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index f9e27cc15c..cf677ba5bd 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -4212,8 +4212,9 @@ export function getExecuteWebhookFunctions( mode: WorkflowExecuteMode, webhookData: IWebhookData, closeFunctions: CloseFunction[], + runExecutionData: IRunExecutionData | null, ): IWebhookFunctions { - return ((workflow: Workflow, node: INode) => { + return ((workflow: Workflow, node: INode, runExecutionData: IRunExecutionData | null) => { return { ...getCommonWorkflowFunctions(workflow, node, additionalData), getBodyData(): IDataObject { @@ -4274,10 +4275,21 @@ export function getExecuteWebhookFunctions( fallbackValue?: any, options?: IGetNodeParameterOptions, ): NodeParameterValueType | object => { - const runExecutionData: IRunExecutionData | null = null; const itemIndex = 0; const runIndex = 0; - const connectionInputData: INodeExecutionData[] = []; + + let connectionInputData: INodeExecutionData[] = []; + let executionData: IExecuteData | undefined; + + if (runExecutionData?.executionData !== undefined) { + executionData = runExecutionData.executionData.nodeExecutionStack[0]; + + if (executionData !== undefined) { + connectionInputData = executionData.data.main[0]!; + } + } + + const additionalKeys = getAdditionalKeys(additionalData, mode, runExecutionData); return getNodeParameter( workflow, @@ -4288,8 +4300,8 @@ export function getExecuteWebhookFunctions( parameterName, itemIndex, mode, - getAdditionalKeys(additionalData, mode, null), - undefined, + additionalKeys, + executionData, fallbackValue, options, ); @@ -4336,5 +4348,5 @@ export function getExecuteWebhookFunctions( }, nodeHelpers: getNodeHelperFunctions(additionalData, workflow.id), }; - })(workflow, node); + })(workflow, node, runExecutionData); } diff --git a/packages/workflow/src/Interfaces.ts b/packages/workflow/src/Interfaces.ts index ea31b06fef..39b4d06b47 100644 --- a/packages/workflow/src/Interfaces.ts +++ b/packages/workflow/src/Interfaces.ts @@ -466,6 +466,7 @@ export interface IGetExecuteWebhookFunctions { mode: WorkflowExecuteMode, webhookData: IWebhookData, closeFunctions: CloseFunction[], + runExecutionData: IRunExecutionData | null, ): IWebhookFunctions; } diff --git a/packages/workflow/src/Workflow.ts b/packages/workflow/src/Workflow.ts index 3c74480b38..ef0539db28 100644 --- a/packages/workflow/src/Workflow.ts +++ b/packages/workflow/src/Workflow.ts @@ -1237,6 +1237,7 @@ export class Workflow { additionalData: IWorkflowExecuteAdditionalData, nodeExecuteFunctions: INodeExecuteFunctions, mode: WorkflowExecuteMode, + runExecutionData: IRunExecutionData | null, ): Promise { const nodeType = this.nodeTypes.getByNameAndVersion(node.type, node.typeVersion); if (nodeType === undefined) { @@ -1258,6 +1259,7 @@ export class Workflow { mode, webhookData, closeFunctions, + runExecutionData, ); return nodeType instanceof Node ? await nodeType.webhook(context)