forked from tsai/budibase
6 changed files with 255 additions and 70 deletions
@ -0,0 +1,65 @@ |
|||||
|
const fetch = require("node-fetch") |
||||
|
|
||||
|
module.exports.definition = { |
||||
|
name: "Discord Message", |
||||
|
tagline: "Send a message to a Discord server", |
||||
|
description: "Send a message to a Discord server", |
||||
|
icon: "ri-discord-line", |
||||
|
stepId: "discord", |
||||
|
type: "ACTION", |
||||
|
inputs: { |
||||
|
username: "Budibase Automate", |
||||
|
avatar_url: "https://i.imgur.com/a1cmTKM.png", |
||||
|
}, |
||||
|
schema: { |
||||
|
inputs: { |
||||
|
properties: { |
||||
|
url: { |
||||
|
type: "string", |
||||
|
title: "Discord Webhook URL", |
||||
|
}, |
||||
|
username: { |
||||
|
type: "string", |
||||
|
title: "Bot Name", |
||||
|
}, |
||||
|
avatar_url: { |
||||
|
type: "string", |
||||
|
title: "Bot Avatar URL", |
||||
|
}, |
||||
|
content: { |
||||
|
type: "string", |
||||
|
title: "Message", |
||||
|
}, |
||||
|
}, |
||||
|
required: ["url", "content"], |
||||
|
}, |
||||
|
outputs: { |
||||
|
properties: { |
||||
|
httpStatus: { |
||||
|
type: "number", |
||||
|
description: "The HTTP status code of the request", |
||||
|
}, |
||||
|
}, |
||||
|
}, |
||||
|
}, |
||||
|
} |
||||
|
|
||||
|
module.exports.run = async function ({ inputs }) { |
||||
|
const { url, username, avatar_url, content } = inputs |
||||
|
|
||||
|
const response = await fetch(url, { |
||||
|
method: "post", |
||||
|
body: JSON.stringify({ |
||||
|
username, |
||||
|
avatar_url, |
||||
|
content, |
||||
|
}), |
||||
|
headers: { |
||||
|
"Content-Type": "application/json", |
||||
|
}, |
||||
|
}) |
||||
|
|
||||
|
return { |
||||
|
httpStatus: response.status, |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,90 @@ |
|||||
|
const fetch = require("node-fetch") |
||||
|
|
||||
|
module.exports.definition = { |
||||
|
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", |
||||
|
}, |
||||
|
response: { |
||||
|
type: "object", |
||||
|
description: "The webhook response - this can have properties", |
||||
|
}, |
||||
|
}, |
||||
|
required: ["success", "response"], |
||||
|
}, |
||||
|
}, |
||||
|
} |
||||
|
|
||||
|
module.exports.run = async function ({ inputs }) { |
||||
|
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", |
||||
|
}, |
||||
|
}) |
||||
|
|
||||
|
let data |
||||
|
if (response.status === 200) { |
||||
|
try { |
||||
|
data = await response.json() |
||||
|
} catch (err) { |
||||
|
data = {} |
||||
|
} |
||||
|
} else { |
||||
|
data = await response.text() |
||||
|
} |
||||
|
|
||||
|
return { |
||||
|
success: response.status === 200, |
||||
|
response: data, |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,88 @@ |
|||||
|
const fetch = require("node-fetch") |
||||
|
|
||||
|
module.exports.definition = { |
||||
|
name: "Zapier Webhook", |
||||
|
stepId: "zapier", |
||||
|
type: "ACTION", |
||||
|
description: "Trigger a Zapier Zap via webhooks", |
||||
|
tagline: "Trigger a Zapier Zap", |
||||
|
icon: "ri-flashlight-line", |
||||
|
schema: { |
||||
|
inputs: { |
||||
|
properties: { |
||||
|
url: { |
||||
|
type: "string", |
||||
|
title: "Webhook URL", |
||||
|
}, |
||||
|
value1: { |
||||
|
type: "string", |
||||
|
title: "Payload Value 1", |
||||
|
}, |
||||
|
value2: { |
||||
|
type: "string", |
||||
|
title: "Payload Value 2", |
||||
|
}, |
||||
|
value3: { |
||||
|
type: "string", |
||||
|
title: "Payload Value 3", |
||||
|
}, |
||||
|
value4: { |
||||
|
type: "string", |
||||
|
title: "Payload Value 4", |
||||
|
}, |
||||
|
value5: { |
||||
|
type: "string", |
||||
|
title: "Payload Value 5", |
||||
|
}, |
||||
|
}, |
||||
|
required: ["url"], |
||||
|
}, |
||||
|
outputs: { |
||||
|
properties: { |
||||
|
httpStatus: { |
||||
|
type: "number", |
||||
|
description: "The HTTP status code of the request", |
||||
|
}, |
||||
|
zapierStatus: { |
||||
|
type: "string", |
||||
|
description: "The result status from Zapier", |
||||
|
}, |
||||
|
}, |
||||
|
}, |
||||
|
}, |
||||
|
} |
||||
|
|
||||
|
module.exports.run = async function ({ inputs }) { |
||||
|
const { url, value1, value2, value3, value4, value5 } = inputs |
||||
|
|
||||
|
// send the platform to make sure zaps always work, even
|
||||
|
// if no values supplied
|
||||
|
const response = await fetch(url, { |
||||
|
method: "post", |
||||
|
body: JSON.stringify({ |
||||
|
platform: "budibase", |
||||
|
value1, |
||||
|
value2, |
||||
|
value3, |
||||
|
value4, |
||||
|
value5, |
||||
|
}), |
||||
|
headers: { |
||||
|
"Content-Type": "application/json", |
||||
|
}, |
||||
|
}) |
||||
|
|
||||
|
let data = null |
||||
|
if (response.status === 200) { |
||||
|
try { |
||||
|
data = await response.json() |
||||
|
} catch (err) { |
||||
|
data = null |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return { |
||||
|
httpStatus: response.status, |
||||
|
zapierStatus: data && data.status ? data.status : data, |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue