First of all, we need to create a new Zap in Zapier​
Trigger
In order to have an access to request headers, we need to create "Catch Raw Hook" trigger. It comes with a disadvantage that request payload will be provided as a string and we will need to parse it to the JSON.
It will provide us a Webhook url, were we can send requests:
Now we need to create a Webhook in Snyk via API with provided url.
Let's create another action, to parse a payload from string to something Zapier can understand.
We need to create the same JS Action:
"Code by Zapier" → "Run Javascript", with the following field mapping:
And the following JS snippet:
1
try {
2
output = JSON.parse(inputData.body);
3
} catch (err) {
4
output = { err: err.message };
5
}
Copied!
That will parse a request payload and map it to Zap's variables.
Action (format issues)
New issues are provided as a list of objects, unfortunately, Zapier doesn't understand that format well, rather it likes a list of strings. So We need to format newIssues to string[].
Let's create one more JS Action:
"Code by Zapier" → "Run Javascript", and paste the following snippet:
1
function formatIssue({ pkgName, pkgVersions, issueData }) {
Now with all fields provided, we can decide whatever we want to do anything with an event or not.
To filter, we need to create "Filter by Zapier" app:
Now you will be able to choose how you want it to be filtered.
Action (send a notification)
With the actions above, we are able to access all necessary fields, and we can build a notification template. In my case, I choose to send an email. But it can be anything else.