Hi all,
I am damn new to coding and pack making so bear with me
As I have seen various packs that are able to trigger a webhook (Make.com, Zapier, etc.). As I know that Coda can connect only to one allowed domain I setup a Digital Ocean droplet to host N8N on a subdomain I control.
I tried making a private pack that connects only to the domain with the pack code being the one below:
// Coda Pack SDK setup and formula definition
import * as coda from "@codahq/packs-sdk";
export const pack = coda.newPack();
pack.addNetworkDomain("my-domain"); // Authorize only your n8n domain
pack.addFormula({
name: "TriggerWebhook",
description: "Triggers a configurable n8n webhook.",
parameters: [
coda.makeParameter({
type: coda.ParameterType.String,
name: "webhookUrl",
description: "The full URL of the n8n webhook to trigger.",
}),
coda.makeParameter({
type: coda.ParameterType.String,
name: "payload",
description: "JSON payload to send with the request, can be empty.",
optional: true,
}),
],
execute: async function ([webhookUrl, payload], context) {
let response = await context.fetcher.fetch({
method: "POST",
url: webhookUrl, // Using the full URL directly
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(payload ? JSON.parse(payload) : {}),
});
return response.body; // Return the response body for display or processing in Coda
},
resultType: coda.ValueType.String, // Or adjust based on what type of response you expect
});
As I only want to trigger a wokflow using a webhook in n8n the payload will be empty.
I am getting things such as:
Formula TriggerWebhook returned a prior result from the cache
Just now
Overview: Formula TriggerWebhook returned a prior result from the cache
User ID
2632793
Pack Version
6
Pack ID
30657
Request ID
b0bb54f5-f0de-40fb-9a31-137f1f5612fe
Created at
Apr 28, 2024 @ 16:26:13
Request type
invokeFormulaRequest
Invocation source
Coda UI
Cache hit
true
Duration
24ms
Although I canât see the output in n8n. I think I am missing many things here that eventually I will get right but I am just trying to learn it.