n8n-nodes-viber-bot 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.
- package/README.md +165 -0
- package/dist/credentials/ViberBotApi.credentials.d.ts +10 -0
- package/dist/credentials/ViberBotApi.credentials.js +42 -0
- package/dist/credentials/ViberBotApi.credentials.js.map +1 -0
- package/dist/credentials/viber.svg +4 -0
- package/dist/nodes/ViberBot/ViberBot.node.d.ts +5 -0
- package/dist/nodes/ViberBot/ViberBot.node.js +649 -0
- package/dist/nodes/ViberBot/ViberBot.node.js.map +1 -0
- package/dist/nodes/ViberBot/viber.svg +4 -0
- package/dist/package.json +48 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# n8n-nodes-viber-bot
|
|
2
|
+
|
|
3
|
+
This is an n8n community node that allows you to seamlessly integrate the **Viber Bot REST API** with your workflows. It provides native support for messaging, broadcasting, registration of webhooks, and retrieval of account and subscriber details.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
### 1. Message Management
|
|
10
|
+
* **Send Message:** Dispatch individual messages to subscribed Viber users.
|
|
11
|
+
* **Broadcast Message:** Send the same message to up to 300 subscriber IDs simultaneously in a single request.
|
|
12
|
+
* **Message Types Supported:**
|
|
13
|
+
* **Text:** Simple text messages up to 7,000 characters.
|
|
14
|
+
* **Picture:** High-quality image URL (HTTPS only), optional text caption, and custom thumbnail override.
|
|
15
|
+
* **Video:** Video URL (HTTPS), file size in bytes, and optional duration constraint.
|
|
16
|
+
* **File:** Any document or media file URL (HTTPS), file size in bytes, and explicit file name.
|
|
17
|
+
* **Location:** Geographical coordinates (latitude and longitude).
|
|
18
|
+
* **Contact:** Direct contact details (name and phone number).
|
|
19
|
+
* **Sticker:** Native Viber sticker ID.
|
|
20
|
+
* **URL:** Clickable link URL.
|
|
21
|
+
* **Advanced Message Parameters:** Include custom tracking data (`trackingData`) and display profile overrides (`senderName` and `senderAvatar`).
|
|
22
|
+
|
|
23
|
+
### 2. Webhook Settings
|
|
24
|
+
* **Set Webhook:** Register an HTTPS callback URL to receive real-time Viber events.
|
|
25
|
+
* **Granular Events:** Subscribe to any combination of `conversation_started`, `delivered`, `seen`, `failed`, `subscribed`, and `unsubscribed`.
|
|
26
|
+
* **Privacy Parameters:** Toggle whether the sender's name (`sendName`) and photo (`sendPhoto`) are delivered in callback payloads.
|
|
27
|
+
|
|
28
|
+
### 3. Account Profile
|
|
29
|
+
* **Get Account Info:** Instantly fetch details of your Viber Bot account, including subscriber count, active webhook status, and bot name/uri.
|
|
30
|
+
|
|
31
|
+
### 4. Subscriber Management
|
|
32
|
+
* **Get User Details:** Retrieve private profile metadata for a specific user (name, primary device OS, device type, language, and country code).
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Directory Layout
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
n8n-nodes-viber-bot/
|
|
40
|
+
├── credentials/
|
|
41
|
+
│ ├── ViberBotApi.credentials.ts # Viber API Authentication definition
|
|
42
|
+
│ └── viber.svg # Polished logo for credentials modal
|
|
43
|
+
├── nodes/
|
|
44
|
+
│ └── ViberBot/
|
|
45
|
+
│ ├── ViberBot.node.ts # Custom Node definition & parameter mapping
|
|
46
|
+
│ └── viber.svg # Polished logo for n8n workspace canvas
|
|
47
|
+
├── tests/
|
|
48
|
+
│ ├── mocks/
|
|
49
|
+
│ │ └── mockExecuteFunctions.ts # n8n runtime execution mock helper
|
|
50
|
+
│ └── ViberBot.node.test.ts # Extensive Jest unit tests
|
|
51
|
+
├── package.json # Package scripts & n8n entry configurations
|
|
52
|
+
├── tsconfig.json # TypeScript compilation settings
|
|
53
|
+
├── eslint.config.mjs # ESLint configuration file
|
|
54
|
+
├── jest.config.js # Jest environment configurations
|
|
55
|
+
└── README.md # Documentation index
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Local Installation (For Testing)
|
|
61
|
+
|
|
62
|
+
To load and test this node in a local n8n instance before releasing it:
|
|
63
|
+
|
|
64
|
+
1. **Build the Package:**
|
|
65
|
+
Compile the TypeScript source files and copy visual assets to the `dist/` build directory:
|
|
66
|
+
```bash
|
|
67
|
+
npm run build
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
2. **Link Your Local Package:**
|
|
71
|
+
Create a global symlink for your workspace folder:
|
|
72
|
+
```bash
|
|
73
|
+
npm link
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
3. **Link into Your n8n Folder:**
|
|
77
|
+
Navigate to your local n8n configurations directory (typically `~/.n8n/`) and link the package:
|
|
78
|
+
```bash
|
|
79
|
+
cd ~/.n8n
|
|
80
|
+
npm link n8n-nodes-viber-bot
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
4. **Restart n8n:**
|
|
84
|
+
Launch your local n8n process. The workspace canvas will load the custom "Viber Bot" node automatically.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Credentials Configuration
|
|
89
|
+
|
|
90
|
+
1. Create a **Viber Bot** account through the [Viber Admin Panel](https://partners.viber.com/).
|
|
91
|
+
2. Retrieve your unique **App Key (Auth Token)**.
|
|
92
|
+
3. In n8n, add a new **Viber Bot API** credential and paste your App Key into the **Auth Token** field.
|
|
93
|
+
4. Click **Test connection** to verify the credential validity (calls Viber's account endpoint in the background).
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Operations Guide
|
|
98
|
+
|
|
99
|
+
### **Resource: Message**
|
|
100
|
+
|
|
101
|
+
#### **Operation: Send**
|
|
102
|
+
* **Receiver:** The unique Viber subscriber ID (string, required).
|
|
103
|
+
* **Message Type:** Select between `Contact`, `File`, `Location`, `Picture`, `Sticker`, `Text`, `URL`, and `Video`.
|
|
104
|
+
* **Additional Fields:**
|
|
105
|
+
* *Sender Name:* Custom profile name shown in chat (max 28 characters).
|
|
106
|
+
* *Sender Avatar:* Custom profile photo URL (must be HTTPS, JPEG/PNG).
|
|
107
|
+
* *Tracking Data:* Custom metadata returned inside user callback reactions (max 4,096 characters).
|
|
108
|
+
|
|
109
|
+
#### **Operation: Broadcast**
|
|
110
|
+
* **Broadcast List:** A comma-separated list of user IDs or a raw JSON array of user ID strings (e.g., `["user1", "user2"]`). Maximum of 300 IDs per request.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
### **Resource: Webhook**
|
|
115
|
+
|
|
116
|
+
#### **Operation: Set**
|
|
117
|
+
* **URL:** The webhook endpoint to receive notifications (must be HTTPS, required).
|
|
118
|
+
* **Event Types:** Select which events trigger callbacks. Defaults to all standard viber events.
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
### **Resource: Account**
|
|
123
|
+
|
|
124
|
+
#### **Operation: Get**
|
|
125
|
+
* Fetches public information about the bot account. No parameters are required.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
### **Resource: User**
|
|
130
|
+
|
|
131
|
+
#### **Operation: Get**
|
|
132
|
+
* **User ID:** The unique Viber subscriber ID to fetch metadata for (string, required).
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Development & Maintenance Scripts
|
|
137
|
+
|
|
138
|
+
Inside your workspace root, you can invoke the following CLI commands:
|
|
139
|
+
|
|
140
|
+
* **Build Compilation:**
|
|
141
|
+
```bash
|
|
142
|
+
npm run build
|
|
143
|
+
```
|
|
144
|
+
* **TypeScript Watcher:**
|
|
145
|
+
```bash
|
|
146
|
+
npm run build:watch
|
|
147
|
+
```
|
|
148
|
+
* **Style & Best Practices Linter:**
|
|
149
|
+
```bash
|
|
150
|
+
npm run lint
|
|
151
|
+
```
|
|
152
|
+
* **Code Formatter (Lint Fix):**
|
|
153
|
+
```bash
|
|
154
|
+
npm run lint:fix
|
|
155
|
+
```
|
|
156
|
+
* **Execute Test Suite:**
|
|
157
|
+
```bash
|
|
158
|
+
npm run test
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, Icon, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class ViberBotApi implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
icon: Icon;
|
|
6
|
+
documentationUrl: string;
|
|
7
|
+
properties: INodeProperties[];
|
|
8
|
+
authenticate: IAuthenticateGeneric;
|
|
9
|
+
test: ICredentialTestRequest;
|
|
10
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ViberBotApi = void 0;
|
|
4
|
+
class ViberBotApi {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'viberBotApi';
|
|
7
|
+
this.displayName = 'Viber Bot API';
|
|
8
|
+
this.icon = 'file:viber.svg';
|
|
9
|
+
this.documentationUrl = 'https://developers.viber.com/docs/api/rest-bot-api/#authentication';
|
|
10
|
+
this.properties = [
|
|
11
|
+
{
|
|
12
|
+
displayName: 'Auth Token',
|
|
13
|
+
name: 'authToken',
|
|
14
|
+
type: 'string',
|
|
15
|
+
typeOptions: {
|
|
16
|
+
password: true,
|
|
17
|
+
},
|
|
18
|
+
default: '',
|
|
19
|
+
required: true,
|
|
20
|
+
description: 'The authentication token for your Viber Bot',
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
this.authenticate = {
|
|
24
|
+
type: 'generic',
|
|
25
|
+
properties: {
|
|
26
|
+
headers: {
|
|
27
|
+
'X-Viber-Auth-Token': '={{$credentials.authToken}}',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
this.test = {
|
|
32
|
+
request: {
|
|
33
|
+
baseURL: 'https://chatapi.viber.com/pa',
|
|
34
|
+
url: '/get_account_info',
|
|
35
|
+
method: 'POST',
|
|
36
|
+
body: {},
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.ViberBotApi = ViberBotApi;
|
|
42
|
+
//# sourceMappingURL=ViberBotApi.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViberBotApi.credentials.js","sourceRoot":"","sources":["../../credentials/ViberBotApi.credentials.ts"],"names":[],"mappings":";;;AAQA,MAAa,WAAW;IAAxB;QACC,SAAI,GAAG,aAAa,CAAC;QACrB,gBAAW,GAAG,eAAe,CAAC;QAC9B,SAAI,GAAS,gBAAgB,CAAC;QAC9B,qBAAgB,GAAG,oEAAoE,CAAC;QAExF,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,YAAY;gBACzB,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE;oBACZ,QAAQ,EAAE,IAAI;iBACd;gBACD,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,6CAA6C;aAC1D;SACD,CAAC;QAEF,iBAAY,GAAyB;YACpC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACX,OAAO,EAAE;oBACR,oBAAoB,EAAE,6BAA6B;iBACnD;aACD;SACD,CAAC;QAEF,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,OAAO,EAAE,8BAA8B;gBACvC,GAAG,EAAE,mBAAmB;gBACxB,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,EAAE;aACR;SACD,CAAC;IACH,CAAC;CAAA;AArCD,kCAqCC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="24" height="24">
|
|
2
|
+
<rect width="512" height="512" rx="120" fill="#7360F2"/>
|
|
3
|
+
<path d="M374.2 301.9c-11.8-4-34.9-16-40.8-18.1-5.9-2.1-10.2-3.2-14.5 3.2-4.3 6.4-16.6 20.8-20.4 25.1-3.7 4.3-7.5 4.8-19.3.8-11.8-4-49.8-18.4-94.9-58.6-35.1-31.3-58.8-70-65.7-81.8-6.9-11.8-.7-18.1 5.2-24 5.4-5.3 11.8-13.8 17.7-20.8 5.9-6.9 7.9-11.8 11.8-19.7 4-7.9 2-14.9-1-21.3-3-6.4-26.2-63.2-35.9-86.6-9.5-22.7-19.1-19.6-26.2-19.6-6.7 0-14.4-.8-22 1-7.7 1.8-20.2 6.6-28.7 15.9s-32.5 31.8-32.5 77.6c0 45.8 33.3 90 38 96.4 4.6 6.4 65.5 100.1 158.7 140.4 22.1 9.6 39.4 15.3 52.8 19.6 22.3 7.1 42.6 6.1 58.6 3.7 17.9-2.7 36.8-15 42-29.4 5.2-14.4 5.2-26.8 3.7-29.4-1.5-2.6-5.4-4.2-17.2-10.2z" fill="#FFF" transform="translate(48, 48) scale(0.8)"/>
|
|
4
|
+
</svg>
|