I have a Custom Webhook node that defines multiple webhooks:
webhooks: [ { name: 'voice', httpMethod: 'GET', responseMode: 'lastNode', responseContentType: 'text/xml', responsePropertyName: 'data', path: '={{$parameter["path"]}}', }, { name: 'message', httpMethod: 'POST', responseMode: 'lastNode', responseContentType: 'application/xml', path:'={{$parameter["path"]}}', }, { name: 'external', httpMethod: 'PATCH', responseMode: 'lastNode', responseContentType: 'application/xml', path:'={{$parameter["path"]}}-custom', }, ],
I am looking to âswitchâ output within the webhook depending on method called. Since
async webhook(this: IWebhookFunctions)
should return IWebhookResponseData
with a âworkflowâ property of INodeExecutionData[][]
, I hoped to add multiple outputs like i do in other nodes by updating my Webhookâs description property with:
outputs: ['main', 'main', 'main'],
outputNames: ['Call Process', 'Message Process', 'External Data'],
Testing with this as the webhook execution method:
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const returnCall: INodeExecutionData[] = [];
const returnMessage: INodeExecutionData[] = [];
const returnExternal: INodeExecutionData[] = [];
const req = this.getRequestObject();
const response: INodeExecutionData = {
json: {
body: this.getBodyData(),
headers: this.getHeaderData(),
query: this.getQueryData(),
}
};
let hookType = (req.method.toLowerCase() === 'get' ? 'call' :
(req.method.toLowerCase() === 'post' ? 'message' : 'external'));
if (hookType === 'call'){
returnCall.push(response);
console.log('Adding to calls');
}else if (hookType === 'message'){
returnMessage.push(response);
console.log('Adding to messages');
}else if (hookType === 'external'){
returnExternal.push(response);
console.log('Adding to externals');
}
console.log([returnCall, returnMessage, returnExternal]);
return {
workflow:[returnCall, returnMessage, returnExternal]
};
}
results only ever send the data to the first output âCall Processâ. It doesnt complain about anything, I just never see either of the other outputs hit when using the additional webhook methods.
My console logging shows that the different methods are hit and the final workflow array value has only one of the three subarrays populated with any objects.