Skip to content
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

fix: Do not trigger sendAndWait response on bot visit if response type is approval #13792

Merged
merged 5 commits into from
Mar 11, 2025
Merged
Changes from 1 commit
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
10 changes: 9 additions & 1 deletion packages/nodes-base/utils/sendAndWait/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import isbot from 'isbot';
import {
NodeOperationError,
SEND_AND_WAIT_OPERATION,
Expand Down Expand Up @@ -324,11 +325,18 @@ const getFormResponseCustomizations = (context: IWebhookFunctions) => {
export async function sendAndWaitWebhook(this: IWebhookFunctions) {
const method = this.getRequestObject().method;
const res = this.getResponseObject();
const req = this.getRequestObject();

const responseType = this.getNodeParameter('responseType', 'approval') as
| 'approval'
| 'freeText'
| 'customForm';

if (responseType === 'approval' && isbot(req.headers['user-agent'])) {
res.send('');
return { noWebhookResponse: true };
}

if (responseType === 'freeText') {
if (method === 'GET') {
const { formTitle, formDescription, buttonLabel } = getFormResponseCustomizations(this);
Expand Down Expand Up @@ -424,7 +432,7 @@ export async function sendAndWaitWebhook(this: IWebhookFunctions) {
}
}

const query = this.getRequestObject().query as { approved: 'false' | 'true' };
const query = req.query as { approved: 'false' | 'true' };
const approved = query.approved === 'true';
return {
webhookResponse: ACTION_RECORDED_PAGE,
Expand Down
Loading