n8n-nodes-formbricks-new 1.0.2 → 1.0.5

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.2.tgz
44
+ npm install /path/to/n8n-nodes-formbricks-new-1.0.5.tgz
45
45
  ```
46
46
 
47
47
  Restart n8n after installing the local tarball.
@@ -51,29 +51,57 @@ Restart n8n after installing the local tarball.
51
51
  Create Formbricks API credentials in n8n with:
52
52
 
53
53
  - **Host**: your Formbricks base URL, for example `https://form.example.com`
54
- - **API Key**: your Formbricks API key
55
- - **Workspace ID**: the workspace ID returned by Formbricks
54
+ - **API Key**: your Formbricks organization API key
56
55
 
57
- To get the Workspace ID from the current Formbricks API v2:
56
+ The credential test calls:
58
57
 
59
- ```sh
60
- curl -H "x-api-key: <API_KEY>" https://form.example.com/api/v2/me
58
+ ```text
59
+ GET /api/v2/me
61
60
  ```
62
61
 
63
- Use the `workspaceId` value from the returned `workspaces` array.
62
+ ## Required Permissions
64
63
 
65
- The credential test still calls:
64
+ Formbricks API keys are organization-level keys with separate organization and workspace permissions.
66
65
 
67
- ```text
68
- GET /api/v2/me
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
+ Recommended permissions for the full n8n trigger lifecycle:
74
+
75
+ - **Organization access**: Read
76
+ - **Selected workspace access**: Manage
77
+
78
+ Lower workspace permissions have limited behavior:
79
+
80
+ - **Read**: Credentials and workspace loading can work, but webhook creation fails.
81
+ - **Write**: Webhook creation can work, but webhook deletion during workflow deactivation can fail.
82
+ - **Manage**: Webhook creation, lookup, and deletion can all work.
83
+
84
+ 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.
85
+
86
+ ## Workspace Selection
87
+
88
+ Workspace is selected in the **Formbricks** trigger node, not in the credential.
89
+
90
+ The node loads available workspaces from the current Formbricks API v2:
91
+
92
+ ```sh
93
+ curl -H "x-api-key: <API_KEY>" https://form.example.com/api/v2/me
69
94
  ```
70
95
 
96
+ 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`.
97
+
71
98
  ## Usage
72
99
 
73
100
  1. Add the **Formbricks** trigger node to an n8n workflow.
74
- 2. Select one or more events, for example **Response Finished**.
75
- 3. Optionally enter comma-separated Survey IDs. Leave the field empty to trigger for all surveys in the workspace.
76
- 4. Save and activate the workflow.
101
+ 2. Select the workspace that should receive the webhook.
102
+ 3. Select one or more events, for example **Response Finished**.
103
+ 4. Optionally enter comma-separated Survey IDs. Leave the field empty to trigger for all surveys in the workspace.
104
+ 5. Save and activate the workflow.
77
105
 
78
106
  When the workflow is activated, n8n creates a production webhook URL and the node registers it in Formbricks with:
79
107
 
@@ -16,19 +16,11 @@ class FormbricksApi {
16
16
  {
17
17
  displayName: "API Key",
18
18
  name: "apiKey",
19
- description: 'Your Formbricks API-Key. You can create a new API-Key in the Product 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: "",
23
23
  },
24
- {
25
- displayName: "Workspace ID",
26
- name: "workspaceId",
27
- type: "string",
28
- default: "",
29
- required: true,
30
- description: "可通过 GET /api/v2/me 的 workspaces[].workspaceId 获取。",
31
- },
32
24
  ];
33
25
  this.authenticate = {
34
26
  type: "generic",
@@ -43,6 +35,22 @@ class FormbricksApi {
43
35
  baseURL: "={{$credentials.host}}/api/v2",
44
36
  url: "=/me",
45
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
+ ],
46
54
  };
47
55
  }
48
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,2LAA2L;gBAC7L,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;aACZ;YACD;gBACE,WAAW,EAAE,cAAc;gBAC3B,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,mDAAmD;aACjE;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;AA7CD,sCA6CC"}
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,6 +1,12 @@
1
- import { INodeType, INodeTypeDescription, IWebhookFunctions, IWebhookResponseData, IHookFunctions } from "n8n-workflow";
1
+ import { IHookFunctions, INodeType, INodeTypeDescription, IWebhookFunctions, IWebhookResponseData } from "n8n-workflow";
2
+ import { getWorkspaces } from "./GenericFunctions";
2
3
  export declare class Formbricks implements INodeType {
3
4
  description: INodeTypeDescription;
5
+ methods: {
6
+ loadOptions: {
7
+ getWorkspaces: typeof getWorkspaces;
8
+ };
9
+ };
4
10
  webhookMethods: {
5
11
  default: {
6
12
  checkExists(this: IHookFunctions): Promise<boolean>;
@@ -42,6 +42,17 @@ class Formbricks {
42
42
  },
43
43
  ],
44
44
  properties: [
45
+ {
46
+ displayName: "Workspace Name or ID",
47
+ name: "workspaceId",
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
+ type: "options",
50
+ typeOptions: {
51
+ loadOptionsMethod: "getWorkspaces",
52
+ },
53
+ default: "",
54
+ required: true,
55
+ },
45
56
  {
46
57
  displayName: "Events",
47
58
  name: "events",
@@ -75,17 +86,20 @@ class Formbricks {
75
86
  },
76
87
  ],
77
88
  };
89
+ this.methods = {
90
+ loadOptions: {
91
+ getWorkspaces: GenericFunctions_1.getWorkspaces,
92
+ },
93
+ };
78
94
  this.webhookMethods = {
79
95
  default: {
80
96
  async checkExists() {
81
- var _a;
82
97
  const webhookData = this.getWorkflowStaticData("node");
83
98
  const webhookUrl = this.getNodeWebhookUrl("default");
99
+ const workspaceId = this.getNodeParameter("workspaceId").trim();
84
100
  const surveyIds = parseSurveyIds(this.getNodeParameter("surveyIds"));
85
- const credentials = await this.getCredentials("formbricksApi");
86
- const workspaceId = (_a = credentials.workspaceId) === null || _a === void 0 ? void 0 : _a.trim();
87
101
  if (!workspaceId) {
88
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Workspace ID is required to check for an existing Formbricks webhook.");
102
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Select a Formbricks workspace before activating this trigger.");
89
103
  }
90
104
  const endpoint = "/management/webhooks";
91
105
  const response = await GenericFunctions_1.apiRequest.call(this, "GET", endpoint, {}, { limit: 250 });
@@ -103,18 +117,16 @@ class Formbricks {
103
117
  return false;
104
118
  },
105
119
  async create() {
106
- var _a;
107
120
  const webhookData = this.getWorkflowStaticData("node");
108
121
  const webhookUrl = this.getNodeWebhookUrl("default");
122
+ const workspaceId = this.getNodeParameter("workspaceId").trim();
109
123
  const surveyIds = parseSurveyIds(this.getNodeParameter("surveyIds"));
110
124
  const events = this.getNodeParameter("events");
111
- const credentials = await this.getCredentials("formbricksApi");
112
- const workspaceId = (_a = credentials.workspaceId) === null || _a === void 0 ? void 0 : _a.trim();
113
125
  if (!Array.isArray(events) || events.length === 0) {
114
126
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Select at least one Formbricks event before activating this trigger.");
115
127
  }
116
128
  if (!workspaceId) {
117
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Workspace ID is required to create a Formbricks webhook.");
129
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Select a Formbricks workspace before activating this trigger.");
118
130
  }
119
131
  const body = {
120
132
  name: null,
@@ -1 +1 @@
1
- {"version":3,"file":"Formbricks.node.js","sourceRoot":"","sources":["../../../nodes/Formbricks/Formbricks.node.ts"],"names":[],"mappings":";;;AAAA,+CAOsB;AAEtB,yDAAgD;AAEhD,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,CAAC;SA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Request(this: IHookFunctions | IExecuteFunctions, method: IHttpRequestMethods, resource: string, body: object, query?: IDataObject, option?: IDataObject): Promise<any>;
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>;
3
+ export declare function getWorkspaces(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.apiRequest = apiRequest;
4
+ exports.getWorkspaces = getWorkspaces;
4
5
  const n8n_workflow_1 = require("n8n-workflow");
5
6
  async function apiRequest(method, resource, body, query = {}, option = {}) {
6
7
  const credentials = await this.getCredentials("formbricksApi");
@@ -25,4 +26,36 @@ async function apiRequest(method, resource, body, query = {}, option = {}) {
25
26
  throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
26
27
  }
27
28
  }
29
+ async function getWorkspaces() {
30
+ var _a, _b, _c, _d;
31
+ const responseData = await apiRequest.call(this, "GET", "/me", {});
32
+ const workspaces = responseData.workspaces ||
33
+ ((_a = responseData.data) === null || _a === void 0 ? void 0 : _a.workspaces) ||
34
+ responseData.workspacePermissions ||
35
+ ((_b = responseData.data) === null || _b === void 0 ? void 0 : _b.workspacePermissions) ||
36
+ responseData.environments ||
37
+ ((_c = responseData.data) === null || _c === void 0 ? void 0 : _c.environments) ||
38
+ responseData.environmentPermissions ||
39
+ ((_d = responseData.data) === null || _d === void 0 ? void 0 : _d.environmentPermissions);
40
+ if (!Array.isArray(workspaces)) {
41
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), "No Formbricks workspaces got returned from GET /api/v2/me");
42
+ }
43
+ const returnData = workspaces
44
+ .filter((workspace) => workspace.workspaceId)
45
+ .map((workspace) => {
46
+ const workspaceName = workspace.projectName || workspace.workspaceName || workspace.workspaceId;
47
+ const permission = workspace.permissions || workspace.permission;
48
+ const permissionLabel = typeof permission === "string"
49
+ ? ` (${permission.charAt(0).toUpperCase()}${permission.slice(1)})`
50
+ : "";
51
+ return {
52
+ name: `${workspaceName}${permissionLabel}`,
53
+ value: workspace.workspaceId,
54
+ };
55
+ });
56
+ if (returnData.length === 0) {
57
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), "No Formbricks workspaces with workspaceId got returned from GET /api/v2/me");
58
+ }
59
+ return returnData;
60
+ }
28
61
  //# sourceMappingURL=GenericFunctions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GenericFunctions.js","sourceRoot":"","sources":["../../../nodes/Formbricks/GenericFunctions.ts"],"names":[],"mappings":";;AAaA,gCAmCC;AAhDD,+CAQsB;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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U,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,iCAAkB,CAC1B,IAAI,CAAC,OAAO,EAAE,EACd,4EAA4E,CAC7E,CAAC;IACJ,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-formbricks-new",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
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.2",
3
+ "version": "1.0.5",
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",