Advertisement
Guest User

Untitled

a guest
Feb 27th, 2022
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This import statement gives you access to all parts of the Coda Packs SDK.
  2. import * as coda from "@codahq/packs-sdk";
  3. // This line creates your new Pack.
  4. export const pack = coda.newPack();
  5.  
  6. // Here, we add a new formula to this Pack.
  7. pack.addFormula({
  8.   // This is the name that will be called in the formula builder.
  9.   // Remember, your formula name cannot have spaces in it.
  10.   name: "Integromat_Webhook",
  11.   description: "A button Action to trigger an Integromat webhook without opening a new window.",
  12.   isAction: true,
  13.  
  14.   // If your formula requires one or more inputs, you’ll define them here.
  15.   // Here, we're creating a string input called “name”.
  16.   parameters: [
  17.     coda.makeParameter({
  18.       type: coda.ParameterType.String,
  19.       name: "webhook",
  20.       description: "The full url of the webhook you want to trigger.",
  21.     }),
  22.   ],
  23.  
  24.   // The resultType defines what will be returned in your Coda doc. Here, we're
  25.   // returning a simple text string.
  26.   resultType: coda.ValueType.String,
  27.  
  28.   // Everything inside this execute statement will happen anytime your Coda
  29.   // formula is called in a doc. An array of all user inputs is always the 1st
  30.   // parameter.
  31.   execute: async function ([webhook], context) {
  32.     let response = await context.fetcher.fetch({ method: "POST", url: webhook });
  33.     // Return values are optional but recommended. Returning a URL or other
  34.     // unique identifier is recommended when creating a new entity.
  35.     return response.body;
  36.   },
  37. });
  38. pack.addNetworkDomain('integromat.com');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement