user-1
(User 1)
February 7, 2024, 5:25pm
1
This topic was automatically generated from Slack. You can find the original thread here .
Hi,
Sorry, please another issue. I am calling another workflow and expecting the result… Sometimes it works, sometimes I get this message in my response data: '$.respond() not called for this invocation'
I’m confused cos it’s working sometimes…
user-1
(User 1)
February 7, 2024, 5:25pm
2
Hi , that’s possibly caused by branching (if/else) statements or if your $.respond
code is in the end of the workflow and exits early
user-1
(User 1)
February 7, 2024, 5:25pm
3
Do these options resonate with your workflow?
user-1
(User 1)
February 7, 2024, 5:25pm
4
I think the last situation will apply although I have both
user-1
(User 1)
February 7, 2024, 5:25pm
5
export
**default** defineComponent({
**async** run({ steps, $ }) {
`**function** hasNullMember(array) {`
`**return** array.some((item) => item === **null**);`
}
**if** (steps.trigger.event.method.toLowerCase() !== 'get')
{
return
}
**if** (steps.createCompany.$return_value.companyId !== **null**){
**await** $.respond({
status: 200,
headers: {},
// body: steps.updatePropertyInHubspot.$return_value.propertyUpdates,
})
`} **else** {`
`**await** $.respond({`
`status: 400,`
`headers: {},`
_`// body: steps.updatePropertyInHubspot.$return_value.propertyUpdates,`_
`})`
`}`
},
})
user-1
(User 1)
February 7, 2024, 5:25pm
6
Cool, so the recommendation is to put the step that calls $.respond
right after the trigger (or the webhook verification) and then continue with your workflow
user-1
(User 1)
February 7, 2024, 5:25pm
7
Hmmm… I need the value that is processed within the workflow
user-1
(User 1)
February 7, 2024, 5:25pm
8
Hence why I put it at the end
user-1
(User 1)
February 7, 2024, 5:25pm
9
The $.respond
won’t terminate the workflow, it’ll just respond the HTTP request
user-1
(User 1)
February 7, 2024, 5:25pm
10
This part might be the cause:
if (steps.trigger.event.method.toLowerCase() !== "get") {
return;
}
user-1
(User 1)
February 7, 2024, 5:25pm
11
It wont… Cos the workflow that calls this one will send a get request
user-1
(User 1)
February 7, 2024, 5:25pm
12
Another WF calls it with a post, but based on my tracing, the issue is on the ‘get’ workflow
user-1
(User 1)
February 7, 2024, 5:25pm
14
Hmm… I see… So you are saying it will still send the values I process even though it is at the beginning?
user-1
(User 1)
February 7, 2024, 5:25pm
15
Yes, the values from steps.trigger.event
will not be mutated
user-1
(User 1)
February 7, 2024, 5:25pm
16
I’m not returning values from steps.trigger.event…
Like my code sample above, I want to return values from another action… like steps.updateHubSpotId.
Are you saying, if I place this code at the beginning,(before updateHubSpotId) has been declared, there will be no issues?
user-1
(User 1)
February 7, 2024, 5:25pm
17
Ah gotcha, yeah it’ll need to be after updateHubSpotId
user-1
(User 1)
February 7, 2024, 5:25pm
18
So this the config and this is the ans
user-1
(User 1)
February 7, 2024, 5:25pm
19
Ahh I see two HTTP triggers there
user-1
(User 1)
February 7, 2024, 5:25pm
20
Could the other one not be configured with custom response?