2021-09-03 18:36:00 +02:00
|
|
|
const fetch = require("node-fetch")
|
2021-09-07 18:31:54 +02:00
|
|
|
const { getFetchResponse } = require("./utils")
|
2021-09-03 18:36:00 +02:00
|
|
|
|
2021-09-06 18:53:02 +02:00
|
|
|
exports.definition = {
|
2021-09-03 18:36:00 +02:00
|
|
|
name: "Integromat Integration",
|
|
|
|
tagline: "Trigger an Integromat scenario",
|
|
|
|
description:
|
|
|
|
"Performs a webhook call to Integromat and gets the response (if configured)",
|
|
|
|
icon: "ri-shut-down-line",
|
|
|
|
stepId: "integromat",
|
|
|
|
type: "ACTION",
|
|
|
|
inputs: {},
|
|
|
|
schema: {
|
|
|
|
inputs: {
|
|
|
|
properties: {
|
|
|
|
url: {
|
|
|
|
type: "string",
|
|
|
|
title: "Webhook URL",
|
|
|
|
},
|
|
|
|
value1: {
|
|
|
|
type: "string",
|
|
|
|
title: "Input Value 1",
|
|
|
|
},
|
|
|
|
value2: {
|
|
|
|
type: "string",
|
|
|
|
title: "Input Value 2",
|
|
|
|
},
|
|
|
|
value3: {
|
|
|
|
type: "string",
|
|
|
|
title: "Input Value 3",
|
|
|
|
},
|
|
|
|
value4: {
|
|
|
|
type: "string",
|
|
|
|
title: "Input Value 4",
|
|
|
|
},
|
|
|
|
value5: {
|
|
|
|
type: "string",
|
|
|
|
title: "Input Value 5",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
required: ["url", "value1", "value2", "value3", "value4", "value5"],
|
|
|
|
},
|
|
|
|
outputs: {
|
|
|
|
properties: {
|
|
|
|
success: {
|
|
|
|
type: "boolean",
|
|
|
|
description: "Whether call was successful",
|
|
|
|
},
|
2021-09-07 18:31:54 +02:00
|
|
|
httpStatus: {
|
|
|
|
type: "number",
|
|
|
|
description: "The HTTP status code returned",
|
|
|
|
},
|
2021-09-03 18:36:00 +02:00
|
|
|
response: {
|
|
|
|
type: "object",
|
|
|
|
description: "The webhook response - this can have properties",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
required: ["success", "response"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-09-06 18:53:02 +02:00
|
|
|
exports.run = async function ({ inputs }) {
|
2021-09-03 18:36:00 +02:00
|
|
|
const { url, value1, value2, value3, value4, value5 } = inputs
|
|
|
|
|
|
|
|
const response = await fetch(url, {
|
|
|
|
method: "post",
|
|
|
|
body: JSON.stringify({
|
|
|
|
value1,
|
|
|
|
value2,
|
|
|
|
value3,
|
|
|
|
value4,
|
|
|
|
value5,
|
|
|
|
}),
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2021-09-07 18:31:54 +02:00
|
|
|
const { status, message } = await getFetchResponse(response)
|
2021-09-03 18:36:00 +02:00
|
|
|
return {
|
2021-09-07 18:31:54 +02:00
|
|
|
httpStatus: status,
|
|
|
|
success: status === 200,
|
|
|
|
response: message,
|
2021-09-03 18:36:00 +02:00
|
|
|
}
|
|
|
|
}
|