Why is the Workflow Invocation Sometimes Returning the Message: '$.respond() not called for this invocation'?

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…

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

Do these options resonate with your workflow?

I think the last situation will apply although I have both

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,`_
    `})`
`}`

},
})

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

Hmmm… I need the value that is processed within the workflow

Hence why I put it at the end

The $.respond won’t terminate the workflow, it’ll just respond the HTTP request

This part might be the cause:

    if (steps.trigger.event.method.toLowerCase() !== "get") {
      return;
    }

It wont… Cos the workflow that calls this one will send a get request

Another WF calls it with a post, but based on my tracing, the issue is on the ‘get’ workflow

The $.respond won’t terminate the workflow, it’ll just respond the HTTP request
But do you understand that having the step that calls $.respond in the beginning of the workflow will not affect the values that you process later?

Hmm… I see… So you are saying it will still send the values I process even though it is at the beginning?

Yes, the values from steps.trigger.event will not be mutated

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?

Ah gotcha, yeah it’ll need to be after updateHubSpotId

So this the config and this is the ans

Ahh I see two HTTP triggers there

Could the other one not be configured with custom response?