-
Notifications
You must be signed in to change notification settings - Fork 13k
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
feat: WhatsApp Business Cloud Node - new operation sendAndWait #12941
base: master
Are you sure you want to change the base?
Conversation
…whatsapp-sendandwait-operation
Codecov ReportAttention: Patch coverage is 📢 Thoughts on this report? Let us know! |
…whatsapp-sendandwait-operation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whatsapp sendAndWait functionality works as expected 🎉 , not sure about the DeclarativeRunException
implementation.
}, | ||
declarativeRunExceptions: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to instead fall back to execute
when a resource/operation has no routing info?
…whatsapp-sendandwait-operation
} else if (nodeType.webhook && !nodeType.description.requestDefaults) { | ||
// Check if the node have requestDefaults(RoutingNode), | ||
// else for webhook nodes always simply pass the data through | ||
// as webhook method would be called by WebhookService | ||
return { data: inputData.main as INodeExecutionData[][] }; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ivov
having RoutingNode
as a fallback seems to be wrong, should webhook
branch be the last one or having return { data: inputData.main as INodeExecutionData[][] };
in else branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite follow you here, let's discuss tomorrow!
packages/workflow/src/Interfaces.ts
Outdated
@@ -1643,6 +1643,13 @@ export interface INodeType { | |||
[method in WebhookSetupMethodNames]: (this: IHookFunctions) => Promise<boolean>; | |||
}; | |||
}; | |||
nonRoutingOperations?: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming-wise I prefer to avoid negatives, plus they're still inside the routing node. What about customOperations
with a docline on top explaining what this is?
packages/workflow/src/Interfaces.ts
Outdated
[resource: string]: { | ||
[operation: string]: ( | ||
context: IExecuteFunctions, | ||
) => Promise<INodeExecutionData[][] | NodeExecutionWithMetadata[][] | null>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type is repeated and a bit obscure. Would it be clearer to have and use type NodeOutput = INodeExecutionData[][] | NodeExecutionWithMetadata[][] | null
?
const operation = context.getNodeParameter('operation', 0) as string; | ||
const returnData: INodeExecutionData[] = []; | ||
|
||
if (resource === 'message' && operation === SEND_AND_WAIT_OPERATION) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we have resource and operation on the key and function name, and also inside the function body. Can we simplify by having this function be specific to the resource + operation pair that's already specified?
@@ -986,6 +989,21 @@ export class WorkflowExecute { | |||
return workflowIssues; | |||
} | |||
|
|||
private getRoutingNodeExecuteFunction(node: INode, type: INodeType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private getRoutingNodeExecuteFunction(node: INode, type: INodeType) { | |
private getCustomOperation(node: INode, type: INodeType) { |
return type.nonRoutingOperations[resource][operation] as ( | ||
context: IExecuteFunctions, | ||
) => Promise<INodeExecutionData[][] | NodeExecutionWithMetadata[][] | null>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we dig into why we need to assert the type here? This was already typed in the workflow package.
Also another option:
private getCustomOperation(node: INode, type: INodeType) {
const { resource, operation } = node.parameters;
if (typeof resource !== 'string' || typeof operation !== 'string') return;
return type.nonRoutingOperations?.[resource]?.[operation];
}
let connectionInputData: INodeExecutionData[] = []; | ||
if (nodeType.execute || (!nodeType.poll && !nodeType.trigger && !nodeType.webhook)) { | ||
if ( | ||
nodeType.execute || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it simplify the implementation if we override nodeType.execute
with this custom function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could not do that, it will causes issue for other node's operations
…whatsapp-sendandwait-operation
…whatsapp-sendandwait-operation
Summary
New operation
sendAndWait
declarativeRunExceptions
for declarative nodesRelated Linear tickets, Github issues, and Community forum posts
https://linear.app/n8n/issue/NODE-2296/whatsapp-sendandwait-operation