n8n-nodes-sendzen 1.0.0

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.
Files changed (44) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +359 -0
  3. package/dist/credentials/SendZenApi.credentials.d.ts +8 -0
  4. package/dist/credentials/SendZenApi.credentials.js +36 -0
  5. package/dist/credentials/SendZenApi.credentials.js.map +1 -0
  6. package/dist/nodes/SendZen/SendZen.node.d.ts +14 -0
  7. package/dist/nodes/SendZen/SendZen.node.js +610 -0
  8. package/dist/nodes/SendZen/SendZen.node.js.map +1 -0
  9. package/dist/nodes/SendZen/SendZen.node.json +20 -0
  10. package/dist/nodes/SendZen/SendZenTrigger.node.d.ts +5 -0
  11. package/dist/nodes/SendZen/SendZenTrigger.node.js +49 -0
  12. package/dist/nodes/SendZen/SendZenTrigger.node.js.map +1 -0
  13. package/dist/nodes/SendZen/sendzen.svg +1 -0
  14. package/dist/package.json +76 -0
  15. package/dist/shared/constants.d.ts +1 -0
  16. package/dist/shared/constants.js +5 -0
  17. package/dist/shared/constants.js.map +1 -0
  18. package/dist/shared/nodeProperties.d.ts +10 -0
  19. package/dist/shared/nodeProperties.js +187 -0
  20. package/dist/shared/nodeProperties.js.map +1 -0
  21. package/dist/shared/template/template.api.types.d.ts +328 -0
  22. package/dist/shared/template/template.api.types.js +3 -0
  23. package/dist/shared/template/template.api.types.js.map +1 -0
  24. package/dist/shared/template/template.builder.d.ts +17 -0
  25. package/dist/shared/template/template.builder.js +200 -0
  26. package/dist/shared/template/template.builder.js.map +1 -0
  27. package/dist/shared/type.d.ts +38 -0
  28. package/dist/shared/type.js +3 -0
  29. package/dist/shared/type.js.map +1 -0
  30. package/dist/shared/utils.d.ts +2 -0
  31. package/dist/shared/utils.js +15 -0
  32. package/dist/shared/utils.js.map +1 -0
  33. package/index.js +10 -0
  34. package/jest.config.js +22 -0
  35. package/n8n-nodes-sendzen-1.0.0.tgz +0 -0
  36. package/nodes/SendZen/SendZen.node.json +20 -0
  37. package/nodes/SendZen/sendzen.svg +1 -0
  38. package/package.json +76 -0
  39. package/shared/constants.ts +1 -0
  40. package/shared/nodeProperties.ts +197 -0
  41. package/shared/template/template.api.types.ts +435 -0
  42. package/shared/template/template.builder.ts +223 -0
  43. package/shared/type.ts +40 -0
  44. package/shared/utils.ts +16 -0
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 WhatsAble
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,359 @@
1
+ # n8n-nodes-sendzen
2
+
3
+ This is an n8n community node. It lets you use SendZen in your n8n workflows.
4
+
5
+ SendZen is a platform for automating SMS and WhatsApp messages. This node package allows you to integrate SendZen's WhatsApp Cloud API capabilities directly into your n8n automation workflows, enabling you to send messages, manage templates, and handle incoming messages seamlessly.
6
+
7
+ [n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/reference/license/) workflow automation platform.
8
+
9
+ [Installation](#installation)
10
+ [Operations](#operations)
11
+ [Credentials](#credentials)
12
+ [Compatibility](#compatibility)
13
+ [Usage](#usage)
14
+ [Resources](#resources)
15
+ [Version history](#version-history)
16
+
17
+ ---
18
+
19
+ ## Installation
20
+
21
+ Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.
22
+
23
+ ---
24
+
25
+ ## Operations
26
+
27
+ ### SendZen Node (Action Node)
28
+
29
+ The SendZen action node supports the following operations:
30
+
31
+ #### Send Session Message
32
+ Send a free-form text message to a WhatsApp recipient. This operation allows you to send messages within an active 24-hour conversation window.
33
+
34
+ **Features:**
35
+ - Send text messages with optional URL preview
36
+ - Support for E.164 phone number format
37
+ - Automatic phone number validation
38
+
39
+ **Required Fields:**
40
+ - WABA Account: Select your WhatsApp Business Account
41
+ - Recipient Phone Number: Phone number in E.164 format (e.g., +1234567890)
42
+ - Reply Message: The message text to send
43
+
44
+ **Optional Fields:**
45
+ - Enable URL Preview: Automatically generate link previews for URLs in the message
46
+
47
+ #### Send Template Message
48
+ Send a pre-approved WhatsApp message template to recipients. Templates are required for initiating conversations outside the 24-hour window or for sending structured messages.
49
+
50
+ **Features:**
51
+ - Dynamic template variable mapping
52
+ - Support for templates with headers, body, buttons, and carousels
53
+ - Automatic template discovery from your WABA account
54
+ - Resource mapper for easy variable mapping
55
+
56
+ **Required Fields:**
57
+ - WABA Account: Select your WhatsApp Business Account
58
+ - Recipient Phone Number: Phone number in E.164 format
59
+ - Template: Select from your approved templates
60
+ - Template Variables: Map values to template variables (automatically detected)
61
+
62
+ **Template Support:**
63
+ - Text headers with variables
64
+ - Body text with variables
65
+ - Media headers (Image, Video, Document)
66
+ - Interactive buttons (URL, Quick Reply, Flow)
67
+ - Carousel components
68
+
69
+ #### Mark as Read
70
+ Mark an incoming message as read. This operation helps maintain proper message status tracking in your WhatsApp conversations.
71
+
72
+ **Features:**
73
+ - Automatic message ID detection from trigger data
74
+ - Automatic phone number ID detection
75
+ - Manual override options for both IDs
76
+
77
+ **Required Fields:**
78
+ - Phone Number ID: Automatically detected from trigger, or manually specified
79
+ - Message ID: Automatically detected from trigger, or manually specified
80
+
81
+ #### Show Typing Indicator
82
+ Display a typing indicator to the recipient, indicating that a response is being prepared.
83
+
84
+ **Features:**
85
+ - Automatic message ID detection from trigger data
86
+ - Automatic phone number ID detection
87
+ - Manual override options for both IDs
88
+
89
+ **Required Fields:**
90
+ - Phone Number ID: Automatically detected from trigger, or manually specified
91
+ - Message ID: Automatically detected from trigger, or manually specified
92
+
93
+ ### SendZen Trigger Node
94
+
95
+ The SendZen trigger node allows you to receive incoming WhatsApp messages in real-time.
96
+
97
+ **Features:**
98
+ - Webhook-based message reception
99
+ - Automatic workflow activation on message receipt
100
+ - Full message payload passed to workflow
101
+
102
+ **Setup:**
103
+ 1. Add the SendZen Trigger node to your workflow
104
+ 2. Copy the webhook URL from the node
105
+ 3. Configure the webhook URL in your SendZen dashboard
106
+ 4. Activate the workflow to start receiving messages
107
+
108
+ ---
109
+
110
+ ## Credentials
111
+
112
+ To use the SendZen nodes, you need to authenticate with your SendZen API key.
113
+
114
+ ### Prerequisites
115
+
116
+ 1. **Sign up for SendZen**
117
+ - Visit [SendZen Website](https://www.sendzen.io/)
118
+ - [Create an account](https://app.sendzen.io/signup) or [log in to your existing account](https://app.sendzen.io/login)
119
+
120
+ 2. **Get Your API Key**
121
+ - Navigate to your SendZen dashboard
122
+ - Go to API Keys section
123
+ - Generate or copy your API key
124
+ - Keep your API key secure and never share it publicly
125
+
126
+ 3. **Set Up WhatsApp Business Account (WABA)**
127
+ - Connect your WhatsApp Business Account in SendZen
128
+ - Complete Meta's business verification if required
129
+ - Ensure your WABA accounts are properly configured
130
+
131
+ ### Setting Up Credentials in n8n
132
+
133
+ 1. **Create New Credential**
134
+ - In the SendZen node settings, click on "Credentials"
135
+ - Select "Create New" or "New Credential"
136
+ - Choose "SendZen API" from the credential type list
137
+
138
+ 2. **Enter Your API Key**
139
+ - Paste your SendZen API key in the "API Key" field
140
+ - Optionally enable "Return Full Response" if you need complete HTTP response details
141
+ - Give your credential a descriptive name (e.g., "SendZen Production")
142
+
143
+ 3. **Save and Test**
144
+ - Click "Save" to store your credentials
145
+ - Test the connection by selecting a WABA account in the node
146
+
147
+ > **Security Note:** Your API key is stored securely in n8n's credential system. Never commit API keys to version control or share them publicly.
148
+
149
+ ---
150
+
151
+ ## Compatibility
152
+
153
+ - **Minimum n8n version:** 1.0.0
154
+ - **Node.js version:** >=18.10
155
+ - **Tested with n8n:** 1.89.2+
156
+
157
+ This node is compatible with all n8n versions that support community nodes and the n8n Nodes API version 1.
158
+
159
+ ---
160
+
161
+ ## Usage
162
+
163
+ ### Basic Workflow: Send a Session Message
164
+
165
+ 1. **Create a new workflow** in n8n
166
+ 2. **Add a trigger node** (e.g., Manual Trigger, Webhook, Schedule)
167
+ 3. **Add the SendZen node**
168
+ 4. **Configure the node:**
169
+ - Select your SendZen API credentials
170
+ - Choose "Send Session Message" as the operation
171
+ - Select your WABA Account
172
+ - Enter the recipient phone number (E.164 format: +1234567890)
173
+ - Enter your message text
174
+ - Optionally enable URL preview
175
+ 5. **Test and activate** your workflow
176
+
177
+ ### Advanced Workflow: Send Template Message with Variables
178
+
179
+ 1. **Set up your template** in SendZen/Meta Business Manager
180
+ 2. **Create a workflow** with a trigger (e.g., form submission, database update)
181
+ 3. **Add the SendZen node**
182
+ 4. **Configure the node:**
183
+ - Select "Send Template Message" operation
184
+ - Choose your WABA Account
185
+ - Select your template from the dropdown
186
+ - Use the Resource Mapper to map template variables:
187
+ - Body variables (e.g., `{{1}}`, `{{2}}`)
188
+ - Header variables (if applicable)
189
+ - Button variables (if applicable)
190
+ - Media URLs (for media headers)
191
+ 5. **Map your data** from previous nodes to template variables
192
+ 6. **Test and activate** your workflow
193
+
194
+ ### Incoming Message Workflow
195
+
196
+ 1. **Add the SendZen Trigger node** to your workflow
197
+ 2. **Copy the webhook URL** from the node
198
+ 3. **Configure webhook in SendZen:**
199
+ - Go to your SendZen dashboard
200
+ - Navigate to Webhooks settings
201
+ - Paste the webhook URL
202
+ - Save the configuration
203
+ 4. **Add action nodes** to process incoming messages:
204
+ - Use "Mark as Read" to acknowledge messages
205
+ - Use "Show Typing Indicator" to show you're responding
206
+ - Use "Send Session Message" to reply
207
+ 5. **Activate the workflow** to start receiving messages
208
+
209
+ ### Phone Number Format
210
+
211
+ All phone numbers must be in **E.164 format**:
212
+ - Start with `+` followed by country code
213
+ - Include area code and number
214
+ - Example: `+1234567890` (US), `+447911123456` (UK)
215
+
216
+ The node automatically adds the `+` prefix if missing, but you should ensure the full number including country code is provided.
217
+
218
+ ### Template Variables
219
+
220
+ When using template messages, the node automatically detects variables in your templates:
221
+ - **Body variables:** Detected from `{{1}}`, `{{2}}`, etc. in template body
222
+ - **Header variables:** Detected from `{{1}}` in text headers
223
+ - **Button variables:** Detected from URL or text parameters in buttons
224
+ - **Media headers:** Require a media URL to be provided
225
+
226
+ Use the Resource Mapper feature to easily map your workflow data to template variables.
227
+
228
+ ---
229
+
230
+ ## Resources
231
+
232
+ * [n8n community nodes documentation](https://docs.n8n.io/integrations/community-nodes/)
233
+ * [SendZen Documentation](https://sendzen.io/docs)
234
+ * [SendZen Website](https://www.sendzen.io/)
235
+ * [n8n Documentation](https://docs.n8n.io)
236
+ * [WhatsApp Business Platform Documentation](https://developers.facebook.com/docs/whatsapp)
237
+
238
+ ---
239
+
240
+ ## Version history
241
+
242
+ ### Version 1.0.0
243
+ - Initial release
244
+ - Support for sending session messages
245
+ - Support for sending template messages with dynamic variables
246
+ - Support for marking messages as read
247
+ - Support for showing typing indicators
248
+ - Webhook trigger for incoming messages
249
+ - Automatic WABA account discovery
250
+ - Automatic template discovery
251
+ - Resource mapper for template variables
252
+ - Support for templates with headers, body, buttons, and carousels
253
+
254
+ ---
255
+
256
+ ## Running Locally
257
+
258
+ To run and test this node on your local machine:
259
+
260
+ 1. **Clone the repository**
261
+ ```bash
262
+ git clone https://github.com/sendzen-io/n8n-nodes-sendzen.git
263
+ cd n8n-nodes-sendzen
264
+ ```
265
+
266
+ 2. **Install dependencies**
267
+ ```bash
268
+ pnpm install
269
+ ```
270
+
271
+ 3. **Build the project**
272
+ ```bash
273
+ pnpm build
274
+ ```
275
+
276
+ 4. **Run tests**
277
+ ```bash
278
+ pnpm test
279
+ ```
280
+
281
+ 5. **Link the node to your local n8n instance**
282
+ - Follow [n8n's community node development guide](https://docs.n8n.io/integrations/community-nodes/create/)
283
+ - Typically, you can run:
284
+ ```bash
285
+ pnpm link --global
286
+ cd ~/.n8n/custom
287
+ pnpm link --global n8n-nodes-sendzen
288
+ ```
289
+ - Restart your n8n instance to load the custom node
290
+
291
+ 6. **Test your node**
292
+ - Open n8n in your browser (usually at `http://localhost:5678`)
293
+ - Create a workflow and add your custom node to test its functionality
294
+
295
+ > **Note:** Make sure you have [Node.js](https://nodejs.org/) (>=18.10) and [pnpm](https://pnpm.io/) installed on your machine.
296
+
297
+ ---
298
+
299
+ ## Contributing
300
+
301
+ We welcome contributions from the community! To contribute:
302
+
303
+ 1. **Fork the repository**: [https://github.com/sendzen-io/n8n-nodes-sendzen](https://github.com/sendzen-io/n8n-nodes-sendzen)
304
+ 2. **Create a new branch** for your feature or bugfix:
305
+ ```bash
306
+ git checkout -b feature/your-feature-name
307
+ ```
308
+ 3. **Make your changes** and ensure code quality:
309
+ - Follow the existing code style
310
+ - Add or update documentation as needed
311
+ - Run linter and tests before submitting
312
+ ```bash
313
+ pnpm lint
314
+ pnpm test
315
+ ```
316
+ 4. **Commit your changes**
317
+ ```bash
318
+ git commit -m "Add your message here"
319
+ ```
320
+ 5. **Push to your fork**
321
+ ```bash
322
+ git push origin feature/your-feature-name
323
+ ```
324
+ 6. **Open a Pull Request**
325
+ - Go to the GitHub page for your fork
326
+ - Click "Compare & pull request"
327
+ - Describe your changes and submit the PR
328
+
329
+ ### Reporting Issues
330
+
331
+ If you find a bug or have a feature request, please [open an issue](https://github.com/sendzen-io/n8n-nodes-sendzen/issues) with:
332
+ - Detailed description of the issue
333
+ - Steps to reproduce
334
+ - Expected vs actual behavior
335
+ - n8n version and node version
336
+ - Any relevant error messages or logs
337
+
338
+ ### Code of Conduct
339
+
340
+ Please be respectful and follow our [Code of Conduct](CODE_OF_CONDUCT.md) when participating in this project.
341
+
342
+ ---
343
+
344
+ ## License
345
+
346
+ [MIT](LICENSE.md)
347
+
348
+ ---
349
+
350
+ ## Support
351
+
352
+ For technical support and assistance:
353
+
354
+ - **Documentation**: Visit [SendZen Documentation](https://sendzen.io/docs)
355
+ - **Email Support**: Contact support at milan@sendzen.io
356
+ - **GitHub Issues**: [Report issues](https://github.com/sendzen-io/n8n-nodes-sendzen/issues)
357
+
358
+ For enterprise-level support or custom solutions, contact the SendZen team.
359
+
@@ -0,0 +1,8 @@
1
+ import { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-workflow';
2
+ export declare class SendZenApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: INodeProperties[];
7
+ authenticate: IAuthenticateGeneric;
8
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SendZenApi = void 0;
4
+ class SendZenApi {
5
+ constructor() {
6
+ this.name = 'sendZenApi';
7
+ this.displayName = 'SendZen API';
8
+ this.documentationUrl = 'https://sendzen.io/docs';
9
+ this.properties = [
10
+ {
11
+ displayName: 'API Key',
12
+ name: 'apiKey',
13
+ type: 'string',
14
+ typeOptions: { password: true },
15
+ default: '',
16
+ },
17
+ {
18
+ displayName: 'Return Full Response',
19
+ name: 'returnFullResponse',
20
+ type: 'boolean',
21
+ default: false,
22
+ description: 'If enabled, the full HTTP response will be returned including the status code, headers, and body.',
23
+ },
24
+ ];
25
+ this.authenticate = {
26
+ type: 'generic',
27
+ properties: {
28
+ headers: {
29
+ Authorization: '=Bearer {{$credentials.apiKey}}',
30
+ },
31
+ },
32
+ };
33
+ }
34
+ }
35
+ exports.SendZenApi = SendZenApi;
36
+ //# sourceMappingURL=SendZenApi.credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SendZenApi.credentials.js","sourceRoot":"","sources":["../../credentials/SendZenApi.credentials.ts"],"names":[],"mappings":";;;AAME,MAAa,UAAU;IAAvB;QACE,SAAI,GAAG,YAAY,CAAC;QACpB,gBAAW,GAAG,aAAa,CAAC;QAC5B,qBAAgB,GAAG,yBAAyB,CAAC;QAE7C,eAAU,GAAsB;YAC9B;gBACE,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;aACZ;YACJ;gBACC,WAAW,EAAE,sBAAsB;gBACnC,IAAI,EAAE,oBAAoB;gBAC1B,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,KAAK;gBACd,WAAW,EAAE,mGAAmG;aAChH;SACC,CAAC;QAEF,iBAAY,GAAyB;YACnC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACV,OAAO,EAAE;oBACT,aAAa,EAAE,iCAAiC;iBAC/C;aACF;SACF,CAAC;IACJ,CAAC;CAAA;AA9BD,gCA8BC"}
@@ -0,0 +1,14 @@
1
+ import { IExecuteFunctions, ILoadOptionsFunctions, INodeExecutionData, INodePropertyOptions, INodeType, INodeTypeDescription, ResourceMapperFields } from 'n8n-workflow';
2
+ export declare class SendZen implements INodeType {
3
+ description: INodeTypeDescription;
4
+ methods: {
5
+ loadOptions: {
6
+ getTemplates(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
7
+ getWabaAccounts(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
8
+ };
9
+ resourceMapping: {
10
+ getTemplateVariables(this: ILoadOptionsFunctions): Promise<ResourceMapperFields>;
11
+ };
12
+ };
13
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
14
+ }