Using ActiveCampain work flows, I have a pipeline in which I want to execute code conditionally based on the output of a jq command.
For example, I want to execute and !http
and !jq
command if .status == "event-created"
.
JSON
{
"id":1,
"firstname": "Nj",
"lastname": "Bhanushali",
"email": "[email protected]",
"title":"Call with new lead",
"status":"event-created"
}
Code
"!pipe": [
{
"!jq": ".status"
},
//call this jq if .status == "event-created"
{
"!http": {
"method": "GET",
"path": "/contact/fields"
}
},
{
"!jq": "${piped_content::1}"
},
]
A quick look at the docs suggest there's a
!switch
"command" you can use.Notes:
I don't know if it's acceptable to have an empty hash for one of the cases. Maybe you have to use
null
? Maybe you have to omit it? If you omit it, maybe you have to useif .status == "event-created" then 0 else empty end
? If that works, that would be the cleanest solution. Adjust as necessary.I don't know if
${piped_content::1}
is still correct with the changes I've made. Adjust as necessary.