Skip to content

update: add type param to the webhook #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 40 additions & 19 deletions nodes/Lowcoder/Lowcoder.node.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


import {
INodeType,
INodeTypeDescription,
Expand Down Expand Up @@ -50,10 +48,9 @@ export class Lowcoder implements INodeType {
name: 'default',
httpMethod: '={{$parameter["httpMethod"]}}',
isFullPath: true,
responseCode: '200',
responseMode: 'onReceived',
responseData: 'allEntries',
responseContentType: '={{$parameter["options"]["responseContentType"]}}',
responseData: '={{$parameter["options"]["responseData"] || "Workflow Resumed!"}}',
responseContentType: '={{$parameter["options"]["responseContentType"] || "application/json"}}',
responsePropertyName: '={{$parameter["options"]["responsePropertyName"]}}',
responseHeaders: '={{$parameter["options"]["responseHeaders"]}}',
path: '={{$parameter["appId"] || ""}}',
Expand All @@ -75,7 +72,14 @@ export class Lowcoder implements INodeType {
default: '',
},
httpMethodsProperty,
optionsProperty
optionsProperty,
{
displayName: 'Response Code',
name: 'responseCode',
type: 'number',
default: 200,
description: 'The HTTP response code to return',
},
],
};

Expand Down Expand Up @@ -113,6 +117,7 @@ export class Lowcoder implements INodeType {
ignoreBots: boolean;
rawBody: Buffer;
responseData?: string;
responseCode?: number;
};
const req = this.getRequestObject();
const resp = this.getResponseObject();
Expand All @@ -122,27 +127,43 @@ export class Lowcoder implements INodeType {
throw new NodeApiError(this.getNode(), {}, { message: 'Authorization data is wrong!' });
}
} catch (error) {
resp.writeHead(error.responseCode, { 'WWW-Authenticate': 'Basic realm="Webhook"' });
resp.writeHead(error.responseCode || 401, { 'WWW-Authenticate': 'Basic realm="Webhook"' });
resp.end(error.message);
return { noWebhookResponse: true };
}
const body = typeof req.body != 'undefined' ? req.body : {};
const returnItem: INodeExecutionData = {
binary: {},
json: {
headers: req.headers,
params: req.params,
query: req.query,
body: body,
},
};
return { workflowData: [[returnItem]] };

const type = req.query.type;
if (type === 'resume') {
// Resume workflow as before
const body = typeof req.body != 'undefined' ? req.body : {};
const returnItem: INodeExecutionData = {
binary: {},
json: {
headers: req.headers,
params: req.params,
query: req.query,
body: body,
},
};
const responseCode = options.responseCode || 200;
resp.statusCode = responseCode;
return { workflowData: [[returnItem]] };
} else {
// Return input data, and don't resume
const staticData = this.getWorkflowStaticData('node');
const previousData = staticData.previousNodeData || [];
resp.statusCode = 200;
resp.setHeader('Content-Type', 'application/json');
resp.end(JSON.stringify({ message: 'Static response: workflow not resumed', type, previousData }));
return { noWebhookResponse: true };
}
}

async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {

let waitTill = new Date(WAIT_TIME_UNLIMITED);

const staticData = this.getWorkflowStaticData('node');
staticData.previousNodeData = this.getInputData().map(item => item.json);
await this.putExecutionToWait(waitTill);
return [this.getInputData()];
}
Expand Down