Zapier: How to skip a step in multi-step zaps - zapier

I'm looking for a way to skip steps (but not abort the Zap altogether) in a multi-stage Zap. For example, if one of the trigger event's values are a certain value, it doesn't need to run Step 2 (which might have been a creation or deletion step), but should continue on to Step 3.
I believe I can do this by using the Code by Zapier service to call a separate Webhook by Zapier Zap and optionally calling (before that one) another such webhook if it meets a criteria. But that's incredibly hacky.

Zapier now supports branch logic, called Paths. This is currently the best non-code method. It doesn't loop back into a common endpoint, but one could work around that by having them all end with a Webhook POST to a common Webhook receiver that ties up the end portion of the Zap.

Zapier does also support code steps. Obviously, this kind of defeats the purpose of using zapier to avoid coding, but if the step was simple (or maintaining two zaps was hard), you could write out the request and surround it in an if block
if (doThisStep) {
const payload = { name: 'Bob' };
fetch('http://some.example/', { method: 'POST', body: JSON.stringify(payload) })
.then((res) => callback(null, res.json())
.catch(callback);
} else {
// Don't forget the callback if you skip the step!
callback(null, { skipped: true });
}

Zapier now has support for Custom Filters (https://zapier.com/learn/how-to-use-zapier/custom-filters/).
You can setup a filter based on the previous steps that essentially says - "Only proceed to the next step of this Zap if xxx conditions are met".

Related

Power Automate - How to create Azure DevOps work items only once when the trigger is a work item update?

Context
I want to create a Power-Automate flow that automatically creates a sub-task in Azure DevOps when the Effort of a PBI is set.
When the Effort field goes from blank to a positive value, the task should be added (using the newly set Effort value as the task's Original Estimate and Remaining Work).
I managed to create a flow that does that using When a work item is update trigger.
Problem
The flow runs too often (whenever the work item changes, as long as the Effort is > 0).
Question
What would be the best way to ensure this flow runs only once per PBI?
Thoughts
Perhaps check for the presence of child tasks?
Perhaps set a hidden property when adding the task the first time and check that property afterwards?
You could add a trigger condition to the settings of your trigger action. Use the following expression:
#greater(triggerOutputs()?['body/fields/Microsoft_VSTS_Scheduling_Effort'], 0)
Add a Send an HTTP request action directly after the trigger. Use the following URI:
YourProjectName/_apis/wit/workItems/#{triggerOutputs()?['body/id']}/updates?api-version=6.0
Add a Filter Array. Use this expression for the From
body('Send_an_HTTP_request_to_Azure_DevOps')['value']
In the where of the Filter Array use the following expression which you add via the advanced mode:
#greater(length(string(item()?['fields']?['Microsoft.VSTS.Scheduling.Effort']?['newValue'])), 0)
In a condition check if the Filter Array returns no results. If it does, the value of Effort has not been changed in the past and you can safely create your new task
length(body('Filter_array'))
is equal to 1

More information about successful tests?

How can I provide additional information about a passing test?
console.log doesn't work as the output gets overwritten as the tool logs it's own information about tests. (Perhaps this is a bug?) Ultimately we cannot depend on any output making it to the final screen unless the test fails. Ideally, I want to push an object (and perhaps screenshots) to something that is designed to collect information about the test, then associate it with the test and be accessible with the output of the test.
Building a custom object doesn't work as there are internal features with playwright, such as retry'ing a test.
Here is a typical scenario: While accessing a website, a record may be created (a work order id, or a purchase order number, and various other information may be encountered along the way).
Ideally I'm looking for some object like:
test.addInfo( someObject )
Perhaps at the end of the test, this is dumped out, or available to a reporting tool.
This is possible out-of-the-box. See https://playwright.dev/docs/api/class-testinfo#test-info-annotations
There is an optional second parameter specifically for this. The reporter would have to work with this (json works however list, dot etc.. would not).
test("Some test", async ({ page }, testInfo) => {
// ^ add this object
// Add arbitrary infomation like this:
let someObject = ({ additionalTestInformation: "here" })
testInfo.annotations.push({type:"info", description: someObject });
// Add screenshots or other files as well:
testInfo.attachments.push({ name: "screenshot", path, contentType: "image/png"})
});

Get Email From Hunter.io user Zapier Code Step

I'm trying to use Zapier to call the Hunter.io API and return the first email. Since Zapier is pretty linear I need to be able to return individual emails. When I run this I get the following error "We had trouble sending your test through. Please try again. Error:
You must return a single object or array of objects." I realize I put my API key in there - its only linked to a free version so don't go wild :-).
Any help is appreciated.
fetch('https://api.hunter.io/v2/domain-search?domain=' + inputData.website + '&api_key=11b44ca200c3b3ac0b5cf08091bce3346acd2ed3')
  .then(function(res) {
    return res.json();
  })
  .then(function(json) {
    console.log(json);
    callback(null, json.emails);
  })
  .catch(callback);
David here, from the Zapier Platform team.
Luckily this is an easy fix - it looks like the json that comes back has top-level data and meta keys, the former of which has the emails, you're looking for. If you change your successful callback to
callback(null, json.data.emails)
you should be good to go. Note that subsequent steps will run for each email returned during each run of the zap and no deduplication happens. Make sure whatever's downstream of this can happen a lot without consequences!
Also you'll definitely want to regenerate your API Key once this is resolved. Definitely not something you want floating around. :)

Use Jenkins REST API to resume a paused pipeline?

I have a Jenkins declarative pipeline with an input prompt.
stage('Approval') {
when {
branch "qa"
}
input {
message "Approve release?"
ok "Yes"
parameters {
string(name: 'IS_APPROVED', defaultValue: 'Yes', description: 'Approve?')
}
}
steps {
echo "Commit to master"
}
}
I have a 3rd party app that abstracts the use of Jenkins from business domain users. I want a button in the 3rd party app that when clicked, will approve the build for production release.
Is there a Jenkins REST API that I can call to provide the stage with input parameters and resume the build.
Disclaimer: IMHO, this feature is poorly documented. I figured most of this out from a bunch of SO questions with partial answers and several blog articles, and very little from actual Jenkins docs. However, it seems to work nicely on Jenkins 2.73.2.
First, I think you need to add an id attribute to your input.
Then, you can send a POST request to one of these:
http://yourjenkins/job/${YOUR_PROJECT}/${BUILD_NUMBER}/input/${INPUT_ID}/abort
This will cancel your job and ignore any parameter.
http://yourjenkins/job/${YOUR_PROJECT}/${BUILD_NUMBER}/input/${INPUT_ID}/proceedEmpty
This will resume your job and ignore any parameter.
http://yourjenkins/job/${YOUR_PROJECT}/${BUILD_NUMBER}/input/${INPUT_ID}/submit
This will resume your job, and you can send parameters. But:
You will need to send a proceed parameter with the caption of the 'Proceed' button.
You will need to send a json parameter with a URL-encoded JSON document with the form {"parameter":[{"name":"param1","value":"valueOfParam1"},{"name":"param2","value":"valueOfParam2"}]}, these will be your actual input parameters.
If you fail to send a valid json parameter, your job will continue anyway, it just won't get any parameter.
On success, this will return a '302 Found' and a redirection to user interface, which might interfere with your code and/or cause error handling issues.
http://yourjenkins/job/${YOUR_PROJECT}/${BUILD_NUMBER}/wfapi/inputSubmit
This seems to be the right way. You need to send inputId and json (see previous point). On success, this will return a '200 OK' with an empty response. You can also check out /wfapi and /wfapi/nextPendingInputAction on a paused job for more information.
Keep in mind that you will need to send authentication credentials and CSRF token for each request. Also, for the use case you describe, you probably wouldn't need parameters for your input, but just the proceed/abort built-in action.

add confirmation entity in dialogflow (api.ai)

I need to add a confirmation entity so I get a 'Yes' or a 'Cancel' in the parameters of a certain operation in dialogflow (api.ai).
Say a user is purchasing a coffee, I'd ask details about the coffee and the quantity and finally i need a confirmation, what entity should i apply for that? any tutorial that refers to the same will also be helpful.
DialogFlow has a concept called a follow-up intent that you could use in a case like this:
You would create a "yes" follow-up to capture if the user wants to proceed, a "no" to cancel, and a "fallback" to explain to the user what is happening and what are acceptable answers.
If you are working with Actions on Google, you could also use askForConfirmation which is done completely from within your webhook code.
You can choose the most appropriate way depending on how your code is structured.
The other way would be to create a confirmation entity and prompt for it in your intent.
Create entty: Create 2 rows, one for yes and another for no, with the appropriate synonyms.
Adding it as a parameter with the entity you just created, and add the appropriate prompt.
An answer for who jump here trying to obtain this confirmation behavior with Actions on Google.
You can take a look at the documentation for Confirmation helper of Actions SDK for Node.js.
The solution is to setup an intent with the actions_intent_CONFIRMATION event in DialogFlow in order to retrieve the user response. My advice is to check how you configured your intents and use this method, otherwise be sure to create the follow-up intents with the desired context lifespan.
Example from documentation:
app.intent('Default Welcome Intent', conv => {
conv.ask(new Confirmation('Are you sure you want to do that?'))
})
// Create a Dialogflow intent with the `actions_intent_CONFIRMATION` event
app.intent('Get Confirmation', (conv, input, confirmation) => {
if (confirmation) {
conv.close(`Great! I'm glad you want to do it!`)
} else {
conv.close(`That's okay. Let's not do it now.`)
}
})
See also this question.

Resources