n8n-nodes-formbricks-new 1.0.3 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,7 +41,7 @@ For an unpublished local build, create a tarball from this repository and instal
41
41
  npm run build
42
42
  npm pack
43
43
  cd ~/.n8n/nodes
44
- npm install /path/to/n8n-nodes-formbricks-new-1.0.3.tgz
44
+ npm install /path/to/n8n-nodes-formbricks-new-1.0.6.tgz
45
45
  ```
46
46
 
47
47
  Restart n8n after installing the local tarball.
@@ -59,6 +59,32 @@ The credential test calls:
59
59
  GET /api/v2/me
60
60
  ```
61
61
 
62
+ ## Required Permissions
63
+
64
+ Formbricks API keys are organization-level keys with separate organization and workspace permissions.
65
+
66
+ This node uses these Formbricks API v2 endpoints:
67
+
68
+ - `GET /api/v2/me` to test credentials and load the workspace list
69
+ - `GET /api/v2/management/webhooks` to check for an existing webhook
70
+ - `POST /api/v2/management/webhooks` to register the n8n production webhook
71
+ - `DELETE /api/v2/management/webhooks/{id}` to remove the webhook when the workflow is deactivated
72
+
73
+ It also uses `GET /api/v1/management/surveys` to load survey choices in n8n because the current public API v2 documentation does not expose a survey list endpoint.
74
+
75
+ Recommended permissions for the full n8n trigger lifecycle:
76
+
77
+ - **Organization access**: Read
78
+ - **Selected workspace access**: Manage
79
+
80
+ Lower workspace permissions have limited behavior:
81
+
82
+ - **Read**: Credentials and workspace loading can work, but webhook creation fails.
83
+ - **Write**: Webhook creation can work, but webhook deletion during workflow deactivation can fail.
84
+ - **Manage**: Webhook creation, lookup, and deletion can all work.
85
+
86
+ The credential test only verifies `GET /api/v2/me`, so it can confirm the API key and Organization Read access. It does not prove that the selected workspace has Write or Manage access; that is checked later when n8n activates or deactivates the workflow.
87
+
62
88
  ## Workspace Selection
63
89
 
64
90
  Workspace is selected in the **Formbricks** trigger node, not in the credential.
@@ -69,14 +95,14 @@ The node loads available workspaces from the current Formbricks API v2:
69
95
  curl -H "x-api-key: <API_KEY>" https://form.example.com/api/v2/me
70
96
  ```
71
97
 
72
- It uses the returned `workspaces[]` array. The option label is based on `projectName`, and the option value is `workspaceId`.
98
+ It uses the returned `workspaces[]` array. It also supports Formbricks responses that expose the same data as `workspacePermissions[]`. The option label is based on `projectName` or `workspaceName`, includes the permission level when returned by Formbricks, and the option value is `workspaceId`.
73
99
 
74
100
  ## Usage
75
101
 
76
102
  1. Add the **Formbricks** trigger node to an n8n workflow.
77
103
  2. Select the workspace that should receive the webhook.
78
104
  3. Select one or more events, for example **Response Finished**.
79
- 4. Optionally enter comma-separated Survey IDs. Leave the field empty to trigger for all surveys in the workspace.
105
+ 4. Optionally select surveys. Leave **Survey IDs** empty to trigger this node for all surveys in the workspace.
80
106
  5. Save and activate the workflow.
81
107
 
82
108
  When the workflow is activated, n8n creates a production webhook URL and the node registers it in Formbricks with:
@@ -143,7 +169,7 @@ Publishing is optional for local use. It requires an npm account logged in on th
143
169
 
144
170
  This package is based on the upstream Formbricks n8n node and was updated to register webhooks through the Formbricks API v2 management webhook endpoints.
145
171
 
146
- Formbricks API v2 currently exposes webhook management under `/api/v2/management/webhooks`. A v2 management survey list endpoint is not exposed in the current public docs/source, so Survey IDs are entered manually.
172
+ Formbricks API v2 currently exposes webhook management under `/api/v2/management/webhooks`. Survey choices are loaded through `/api/v1/management/surveys` until an API v2 survey list endpoint is available.
147
173
 
148
174
  ## Resources
149
175
 
@@ -16,7 +16,7 @@ class FormbricksApi {
16
16
  {
17
17
  displayName: "API Key",
18
18
  name: "apiKey",
19
- description: 'Your Formbricks organization API-Key. You can create a new API-Key in the Organization Settings. Please read our <a href="https://formbricks.com/docs/api/api-key-setup">API Key Docs</a> for more details.',
19
+ description: 'Your Formbricks organization API-Key. Credential testing and workspace loading require Organization Read access. Full webhook lifecycle requires Manage access for the selected workspace. Please read our <a href="https://formbricks.com/docs/api/api-key-setup">API Key Docs</a> for more details.',
20
20
  type: "string",
21
21
  typeOptions: { password: true },
22
22
  default: "",
@@ -35,6 +35,22 @@ class FormbricksApi {
35
35
  baseURL: "={{$credentials.host}}/api/v2",
36
36
  url: "=/me",
37
37
  },
38
+ rules: [
39
+ {
40
+ type: "responseCode",
41
+ properties: {
42
+ value: 401,
43
+ message: "Authentication failed. Check the Host/API Key and make sure the key has Organization Read access.",
44
+ },
45
+ },
46
+ {
47
+ type: "responseCode",
48
+ properties: {
49
+ value: 403,
50
+ message: "The API key is valid but lacks permission. Organization Read access is required to test credentials and load workspaces.",
51
+ },
52
+ },
53
+ ],
38
54
  };
39
55
  }
40
56
  }
@@ -1 +1 @@
1
- {"version":3,"file":"FormbricksApi.credentials.js","sourceRoot":"","sources":["../../credentials/FormbricksApi.credentials.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAa;IAA1B;QACE,SAAI,GAAG,eAAe,CAAC;QACvB,gBAAW,GAAG,gBAAgB,CAAC;QAC/B,eAAU,GAAsB;YAC9B;gBACE,WAAW,EAAE,MAAM;gBACnB,IAAI,EAAE,MAAM;gBACZ,WAAW,EACT,kMAAkM;gBACpM,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,4BAA4B;aACtC;YACD;gBACE,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,6MAA6M;gBAC/M,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;aACZ;SACF,CAAC;QAEF,iBAAY,GAAyB;YACnC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,WAAW,EAAE,0BAA0B;iBACxC;aACF;SACF,CAAC;QACF,SAAI,GAAuC;YACzC,OAAO,EAAE;gBACP,OAAO,EAAE,+BAA+B;gBACxC,GAAG,EAAE,MAAM;aACZ;SACF,CAAC;IACJ,CAAC;CAAA;AArCD,sCAqCC"}
1
+ {"version":3,"file":"FormbricksApi.credentials.js","sourceRoot":"","sources":["../../credentials/FormbricksApi.credentials.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAa;IAA1B;QACE,SAAI,GAAG,eAAe,CAAC;QACvB,gBAAW,GAAG,gBAAgB,CAAC;QAC/B,eAAU,GAAsB;YAC9B;gBACE,WAAW,EAAE,MAAM;gBACnB,IAAI,EAAE,MAAM;gBACZ,WAAW,EACT,kMAAkM;gBACpM,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,4BAA4B;aACtC;YACD;gBACE,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,uSAAuS;gBACzS,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;aACZ;SACF,CAAC;QAEF,iBAAY,GAAyB;YACnC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,WAAW,EAAE,0BAA0B;iBACxC;aACF;SACF,CAAC;QACF,SAAI,GAAuC;YACzC,OAAO,EAAE;gBACP,OAAO,EAAE,+BAA+B;gBACxC,GAAG,EAAE,MAAM;aACZ;YACD,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,cAAc;oBACpB,UAAU,EAAE;wBACV,KAAK,EAAE,GAAG;wBACV,OAAO,EACL,mGAAmG;qBACtG;iBACF;gBACD;oBACE,IAAI,EAAE,cAAc;oBACpB,UAAU,EAAE;wBACV,KAAK,EAAE,GAAG;wBACV,OAAO,EACL,0HAA0H;qBAC7H;iBACF;aACF;SACF,CAAC;IACJ,CAAC;CAAA;AAvDD,sCAuDC"}
@@ -1,9 +1,10 @@
1
1
  import { IHookFunctions, INodeType, INodeTypeDescription, IWebhookFunctions, IWebhookResponseData } from "n8n-workflow";
2
- import { getWorkspaces } from "./GenericFunctions";
2
+ import { getSurveys, getWorkspaces } from "./GenericFunctions";
3
3
  export declare class Formbricks implements INodeType {
4
4
  description: INodeTypeDescription;
5
5
  methods: {
6
6
  loadOptions: {
7
+ getSurveys: typeof getSurveys;
7
8
  getWorkspaces: typeof getWorkspaces;
8
9
  };
9
10
  };
@@ -45,7 +45,7 @@ class Formbricks {
45
45
  {
46
46
  displayName: "Workspace Name or ID",
47
47
  name: "workspaceId",
48
- description: 'Workspace where the webhook should be registered. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
48
+ description: 'Workspace where the webhook should be registered. Manage access is recommended so n8n can create and delete webhooks. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
49
49
  type: "options",
50
50
  typeOptions: {
51
51
  loadOptionsMethod: "getWorkspaces",
@@ -80,14 +80,19 @@ class Formbricks {
80
80
  {
81
81
  displayName: "Survey IDs",
82
82
  name: "surveyIds",
83
- description: "Optional comma-separated survey IDs. Leave empty to trigger this node for all surveys in the workspace.",
84
- type: "string",
85
- default: "",
83
+ description: 'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
84
+ type: "multiOptions",
85
+ typeOptions: {
86
+ loadOptionsMethod: "getSurveys",
87
+ },
88
+ options: [],
89
+ default: [],
86
90
  },
87
91
  ],
88
92
  };
89
93
  this.methods = {
90
94
  loadOptions: {
95
+ getSurveys: GenericFunctions_1.getSurveys,
91
96
  getWorkspaces: GenericFunctions_1.getWorkspaces,
92
97
  },
93
98
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Formbricks.node.js","sourceRoot":"","sources":["../../../nodes/Formbricks/Formbricks.node.ts"],"names":[],"mappings":";;;AAAA,+CAOsB;AAEtB,yDAA+D;AAE/D,SAAS,cAAc,CAAC,SAA4B;IAClD,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,SAAS;SACb,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CA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Q,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAEpC,OAAO;YACL,YAAY,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;SACvD,CAAC;IACJ,CAAC;CACF;AAtLD,gCAsLC"}
@@ -1,3 +1,4 @@
1
1
  import { IDataObject, IExecuteFunctions, IHookFunctions, IHttpRequestMethods, ILoadOptionsFunctions, INodePropertyOptions } from "n8n-workflow";
2
- export declare function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: IHttpRequestMethods, resource: string, body: object, query?: IDataObject, option?: IDataObject): Promise<any>;
2
+ export declare function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: IHttpRequestMethods, resource: string, body: object, query?: IDataObject, option?: IDataObject, apiVersion?: string): Promise<any>;
3
3
  export declare function getWorkspaces(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
4
+ export declare function getSurveys(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
@@ -2,11 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.apiRequest = apiRequest;
4
4
  exports.getWorkspaces = getWorkspaces;
5
+ exports.getSurveys = getSurveys;
5
6
  const n8n_workflow_1 = require("n8n-workflow");
6
- async function apiRequest(method, resource, body, query = {}, option = {}) {
7
+ async function apiRequest(method, resource, body, query = {}, option = {}, apiVersion = "v2") {
7
8
  const credentials = await this.getCredentials("formbricksApi");
8
9
  let options = {
9
- baseURL: `${credentials.host}/api/v2`,
10
+ baseURL: `${credentials.host}/api/${apiVersion}`,
10
11
  method,
11
12
  body,
12
13
  qs: query,
@@ -27,15 +28,53 @@ async function apiRequest(method, resource, body, query = {}, option = {}) {
27
28
  }
28
29
  }
29
30
  async function getWorkspaces() {
30
- var _a;
31
+ var _a, _b, _c, _d;
31
32
  const responseData = await apiRequest.call(this, "GET", "/me", {});
32
- const workspaces = responseData.workspaces || ((_a = responseData.data) === null || _a === void 0 ? void 0 : _a.workspaces);
33
+ const workspaces = responseData.workspaces ||
34
+ ((_a = responseData.data) === null || _a === void 0 ? void 0 : _a.workspaces) ||
35
+ responseData.workspacePermissions ||
36
+ ((_b = responseData.data) === null || _b === void 0 ? void 0 : _b.workspacePermissions) ||
37
+ responseData.environments ||
38
+ ((_c = responseData.data) === null || _c === void 0 ? void 0 : _c.environments) ||
39
+ responseData.environmentPermissions ||
40
+ ((_d = responseData.data) === null || _d === void 0 ? void 0 : _d.environmentPermissions);
33
41
  if (!Array.isArray(workspaces)) {
34
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), "No workspaces got returned");
42
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), "No Formbricks workspaces got returned from GET /api/v2/me");
43
+ }
44
+ const returnData = workspaces
45
+ .filter((workspace) => workspace.workspaceId)
46
+ .map((workspace) => {
47
+ const workspaceName = workspace.projectName || workspace.workspaceName || workspace.workspaceId;
48
+ const permission = workspace.permissions || workspace.permission;
49
+ const permissionLabel = typeof permission === "string"
50
+ ? ` (${permission.charAt(0).toUpperCase()}${permission.slice(1)})`
51
+ : "";
52
+ return {
53
+ name: `${workspaceName}${permissionLabel}`,
54
+ value: workspace.workspaceId,
55
+ };
56
+ });
57
+ if (returnData.length === 0) {
58
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), "No Formbricks workspaces with workspaceId got returned from GET /api/v2/me");
59
+ }
60
+ return returnData;
61
+ }
62
+ async function getSurveys() {
63
+ var _a;
64
+ const workspaceId = (_a = this.getCurrentNodeParameter("workspaceId")) === null || _a === void 0 ? void 0 : _a.trim();
65
+ if (!workspaceId) {
66
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Select a Formbricks workspace first");
67
+ }
68
+ const responseData = await apiRequest.call(this, "GET", "/management/surveys", {}, {}, {}, "v1");
69
+ const surveys = responseData.data;
70
+ if (!Array.isArray(surveys)) {
71
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), "No Formbricks surveys got returned from GET /api/v1/management/surveys");
35
72
  }
36
- return workspaces.map((workspace) => ({
37
- name: workspace.projectName || workspace.workspaceName || workspace.workspaceId,
38
- value: workspace.workspaceId,
73
+ return surveys
74
+ .filter((survey) => survey.workspaceId === workspaceId)
75
+ .map((survey) => ({
76
+ name: survey.name || survey.id,
77
+ value: survey.id,
39
78
  }));
40
79
  }
41
80
  //# sourceMappingURL=GenericFunctions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GenericFunctions.js","sourceRoot":"","sources":["../../../nodes/Formbricks/GenericFunctions.ts"],"names":[],"mappings":";;AAgBA,gCAmCC;AAKD,sCAYC;AApED,+CAWsB;AAKf,KAAK,UAAU,UAAU,CAE9B,MAA2B,EAC3B,QAAgB,EAChB,IAAY,EACZ,QAAqB,EAAE,EACvB,SAAsB,EAAE;IAExB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;IAE/D,IAAI,OAAO,GAAwB;QACjC,OAAO,EAAE,GAAG,WAAW,CAAC,IAAI,SAAS;QACrC,MAAM;QACN,IAAI;QACJ,EAAE,EAAE,KAAK;QACT,GAAG,EAAE,QAAQ;QACb,OAAO,EAAE;YACP,WAAW,EAAE,WAAW,CAAC,MAAM;SAChC;KACF,CAAC;IAEF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QAC/B,OAAO,OAAO,CAAC,EAAE,CAAC;IACpB,CAAC;IAED,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7C,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,6BAA6B,CAAC,IAAI,CAC1D,IAAI,EACJ,eAAe,EACf,OAAO,CACR,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,2BAAY,CAAC,IAAI,CAAC,OAAO,EAAE,E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,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,iCAAkB,CAC1B,IAAI,CAAC,OAAO,EAAE,EACd,wEAAwE,CACzE,CAAC;IACJ,CAAC;IAED,OAAO,OAAO;SACX,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,KAAK,WAAW,CAAC;SACtD,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,EAAE;QAC9B,KAAK,EAAE,MAAM,CAAC,EAAE;KACjB,CAAC,CAAC,CAAC;AACR,CAAC"}
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-formbricks-new",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
4
4
  "description": "A n8n node to connect Formbricks and send survey data to hundreds of other apps.",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-formbricks-new",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
4
4
  "description": "A n8n node to connect Formbricks and send survey data to hundreds of other apps.",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",