@renatoascencio/n8n-nodes-chatwoot 0.1.1
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/LICENSE +21 -0
- package/README.md +186 -0
- package/dist/credentials/ChatwootApi.credentials.d.ts +9 -0
- package/dist/credentials/ChatwootApi.credentials.js +63 -0
- package/dist/credentials/ChatwootApi.credentials.js.map +1 -0
- package/dist/nodes/Chatwoot/Chatwoot.node.d.ts +5 -0
- package/dist/nodes/Chatwoot/Chatwoot.node.js +284 -0
- package/dist/nodes/Chatwoot/Chatwoot.node.js.map +1 -0
- package/dist/nodes/Chatwoot/GenericFunctions.d.ts +6 -0
- package/dist/nodes/Chatwoot/GenericFunctions.js +160 -0
- package/dist/nodes/Chatwoot/GenericFunctions.js.map +1 -0
- package/dist/nodes/Chatwoot/chatwoot.svg +7 -0
- package/dist/nodes/Chatwoot/resources/contact/create.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/contact/create.operation.js +78 -0
- package/dist/nodes/Chatwoot/resources/contact/create.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/contact/delete.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/contact/delete.operation.js +20 -0
- package/dist/nodes/Chatwoot/resources/contact/delete.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/contact/get.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/contact/get.operation.js +20 -0
- package/dist/nodes/Chatwoot/resources/contact/get.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/contact/getAll.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/contact/getAll.operation.js +93 -0
- package/dist/nodes/Chatwoot/resources/contact/getAll.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/contact/index.d.ts +3 -0
- package/dist/nodes/Chatwoot/resources/contact/index.js +68 -0
- package/dist/nodes/Chatwoot/resources/contact/index.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/contact/search.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/contact/search.operation.js +107 -0
- package/dist/nodes/Chatwoot/resources/contact/search.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/contact/update.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/contact/update.operation.js +86 -0
- package/dist/nodes/Chatwoot/resources/contact/update.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/conversation/get.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/conversation/get.operation.js +20 -0
- package/dist/nodes/Chatwoot/resources/conversation/get.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/conversation/getAll.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/conversation/getAll.operation.js +145 -0
- package/dist/nodes/Chatwoot/resources/conversation/getAll.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/conversation/index.d.ts +3 -0
- package/dist/nodes/Chatwoot/resources/conversation/index.js +44 -0
- package/dist/nodes/Chatwoot/resources/conversation/index.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/conversation/updateStatus.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/conversation/updateStatus.operation.js +70 -0
- package/dist/nodes/Chatwoot/resources/conversation/updateStatus.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/message/create.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/message/create.operation.js +117 -0
- package/dist/nodes/Chatwoot/resources/message/create.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/message/getAll.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/message/getAll.operation.js +51 -0
- package/dist/nodes/Chatwoot/resources/message/getAll.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/message/index.d.ts +3 -0
- package/dist/nodes/Chatwoot/resources/message/index.js +33 -0
- package/dist/nodes/Chatwoot/resources/message/index.js.map +1 -0
- package/dist/nodes/Chatwoot/types.d.ts +99 -0
- package/dist/nodes/Chatwoot/types.js +3 -0
- package/dist/nodes/Chatwoot/types.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +78 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Renato Ascencio
|
|
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,186 @@
|
|
|
1
|
+
# n8n-nodes-chatwoot
|
|
2
|
+
|
|
3
|
+
This is an n8n community node for [Chatwoot](https://www.chatwoot.com/), the open-source customer engagement platform. It allows you to automate conversations, messages, and contacts in your n8n workflows.
|
|
4
|
+
|
|
5
|
+
[n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/reference/license/) workflow automation platform.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Conversations**: List, get, and update conversation status (open, resolved, pending, snoozed)
|
|
10
|
+
- **Messages**: Send messages and retrieve message history from conversations
|
|
11
|
+
- **Contacts**: Full CRUD operations (create, read, update, delete) plus search functionality
|
|
12
|
+
- **Pagination**: Automatic handling of paginated results with "Return All" option
|
|
13
|
+
- **Error Handling**: Clear error messages for common issues (authentication, rate limits, not found)
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
### Community Nodes (Recommended)
|
|
18
|
+
|
|
19
|
+
1. Go to **Settings > Community Nodes** in your n8n instance
|
|
20
|
+
2. Select **Install**
|
|
21
|
+
3. Enter `@renatoascencio/n8n-nodes-chatwoot` in the input field
|
|
22
|
+
4. Agree to the risks and select **Install**
|
|
23
|
+
|
|
24
|
+
### Manual Installation
|
|
25
|
+
|
|
26
|
+
To install this node manually in a self-hosted n8n instance:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
cd ~/.n8n/nodes
|
|
30
|
+
npm install @renatoascencio/n8n-nodes-chatwoot
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Then restart n8n.
|
|
34
|
+
|
|
35
|
+
### Local Development
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Clone the repository
|
|
39
|
+
git clone https://github.com/RenatoAscencio/n8n-nodes-chatwoot.git
|
|
40
|
+
cd n8n-nodes-chatwoot
|
|
41
|
+
|
|
42
|
+
# Install dependencies
|
|
43
|
+
npm install
|
|
44
|
+
|
|
45
|
+
# Build the node
|
|
46
|
+
npm run build
|
|
47
|
+
|
|
48
|
+
# Link for local development
|
|
49
|
+
npm link
|
|
50
|
+
|
|
51
|
+
# In your n8n installation directory
|
|
52
|
+
npm link @renatoascencio/n8n-nodes-chatwoot
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Configuration
|
|
56
|
+
|
|
57
|
+
### Setting Up Credentials
|
|
58
|
+
|
|
59
|
+
1. In n8n, go to **Credentials > Add Credential > Search for "Chatwoot API"**
|
|
60
|
+
2. Configure the following fields:
|
|
61
|
+
|
|
62
|
+
| Field | Description | Example |
|
|
63
|
+
|-------|-------------|---------|
|
|
64
|
+
| **Base URL** | Your Chatwoot instance URL | `https://app.chatwoot.com` (cloud) or `https://chatwoot.yourdomain.com` (self-hosted) |
|
|
65
|
+
| **Account ID** | Your Chatwoot account ID | Found in Settings → Account Settings or in URL (`/app/accounts/1/...`) |
|
|
66
|
+
| **API Access Token** | Your API token | Found in Profile Settings → Access Token |
|
|
67
|
+
|
|
68
|
+
### Getting Your API Access Token
|
|
69
|
+
|
|
70
|
+
1. Log in to your Chatwoot instance
|
|
71
|
+
2. Click on your profile icon (bottom left)
|
|
72
|
+
3. Go to **Profile Settings**
|
|
73
|
+
4. Find the **Access Token** section
|
|
74
|
+
5. Copy or generate your token
|
|
75
|
+
|
|
76
|
+
## Resources & Operations
|
|
77
|
+
|
|
78
|
+
### Conversation
|
|
79
|
+
|
|
80
|
+
| Operation | Description |
|
|
81
|
+
|-----------|-------------|
|
|
82
|
+
| **Get** | Get a single conversation by ID |
|
|
83
|
+
| **Get Many** | List conversations with filters (status, inbox, team, labels, search) |
|
|
84
|
+
| **Update Status** | Change conversation status (open, resolved, pending, snoozed) |
|
|
85
|
+
|
|
86
|
+
### Message
|
|
87
|
+
|
|
88
|
+
| Operation | Description |
|
|
89
|
+
|-----------|-------------|
|
|
90
|
+
| **Create** | Send a message to a conversation |
|
|
91
|
+
| **Get Many** | Get all messages from a conversation |
|
|
92
|
+
|
|
93
|
+
### Contact
|
|
94
|
+
|
|
95
|
+
| Operation | Description |
|
|
96
|
+
|-----------|-------------|
|
|
97
|
+
| **Create** | Create a new contact |
|
|
98
|
+
| **Get** | Get a single contact by ID |
|
|
99
|
+
| **Get Many** | List all contacts with sorting options |
|
|
100
|
+
| **Update** | Update contact information |
|
|
101
|
+
| **Delete** | Delete a contact |
|
|
102
|
+
| **Search** | Search contacts by name, email, phone, or identifier |
|
|
103
|
+
|
|
104
|
+
## Usage Examples
|
|
105
|
+
|
|
106
|
+
### Example 1: Auto-reply to New Conversations
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
Webhook → Chatwoot (Create Message)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
When a new conversation is created in Chatwoot (via webhook), automatically send a welcome message.
|
|
113
|
+
|
|
114
|
+
### Example 2: Sync Contacts from CRM
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
CRM Trigger → Chatwoot (Create Contact)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
When a new lead is created in your CRM, automatically create a contact in Chatwoot.
|
|
121
|
+
|
|
122
|
+
### Example 3: Close Old Conversations
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
Schedule Trigger → Chatwoot (Get Many) → Filter → Chatwoot (Update Status)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Run daily to find conversations older than 7 days and mark them as resolved.
|
|
129
|
+
|
|
130
|
+
### Example 4: Search and Update Customer Data
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
HTTP Request → Chatwoot (Search Contact) → IF → Chatwoot (Update Contact)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Search for a customer by email and update their information.
|
|
137
|
+
|
|
138
|
+
## Troubleshooting
|
|
139
|
+
|
|
140
|
+
### Common Errors
|
|
141
|
+
|
|
142
|
+
| Error | Cause | Solution |
|
|
143
|
+
|-------|-------|----------|
|
|
144
|
+
| **401 Unauthorized** | Invalid API token | Verify your API Access Token is correct |
|
|
145
|
+
| **403 Forbidden** | Insufficient permissions | Check your user role (Administrator vs Agent) |
|
|
146
|
+
| **404 Not Found** | Resource doesn't exist | Verify the ID exists in Chatwoot |
|
|
147
|
+
| **429 Rate Limited** | Too many requests | Wait before retrying (limit: 60 requests/minute) |
|
|
148
|
+
|
|
149
|
+
### Base URL Issues
|
|
150
|
+
|
|
151
|
+
- **Cloud users**: Use `https://app.chatwoot.com`
|
|
152
|
+
- **Self-hosted**: Use your custom domain (e.g., `https://chatwoot.yourdomain.com`)
|
|
153
|
+
- **Don't** include trailing slashes or `/api/v1`
|
|
154
|
+
|
|
155
|
+
### Agent vs Administrator Permissions
|
|
156
|
+
|
|
157
|
+
- **Administrators**: Can access all conversations and contacts
|
|
158
|
+
- **Agents**: Can only access conversations in their assigned inboxes
|
|
159
|
+
|
|
160
|
+
## API Reference
|
|
161
|
+
|
|
162
|
+
This node uses the [Chatwoot Application API v1](https://www.chatwoot.com/developers/api/).
|
|
163
|
+
|
|
164
|
+
## Contributing
|
|
165
|
+
|
|
166
|
+
Contributions are welcome! Please read the [CLAUDE.md](./CLAUDE.md) file for development guidelines.
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Development workflow
|
|
170
|
+
npm install # Install dependencies
|
|
171
|
+
npm run build # Build the node
|
|
172
|
+
npm run lint # Run ESLint
|
|
173
|
+
npm run lint:fix # Fix ESLint issues
|
|
174
|
+
npm test # Run tests
|
|
175
|
+
npm run format # Format code with Prettier
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## License
|
|
179
|
+
|
|
180
|
+
[MIT](./LICENSE)
|
|
181
|
+
|
|
182
|
+
## Support
|
|
183
|
+
|
|
184
|
+
- **Issues**: [GitHub Issues](https://github.com/RenatoAscencio/n8n-nodes-chatwoot/issues)
|
|
185
|
+
- **Chatwoot Docs**: [developers.chatwoot.com](https://developers.chatwoot.com/)
|
|
186
|
+
- **n8n Community**: [community.n8n.io](https://community.n8n.io/)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class ChatwootApi implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
documentationUrl: string;
|
|
6
|
+
properties: INodeProperties[];
|
|
7
|
+
authenticate: IAuthenticateGeneric;
|
|
8
|
+
test: ICredentialTestRequest;
|
|
9
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChatwootApi = void 0;
|
|
4
|
+
class ChatwootApi {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'chatwootApi';
|
|
7
|
+
this.displayName = 'Chatwoot API';
|
|
8
|
+
this.documentationUrl = 'https://www.chatwoot.com/developers/api/';
|
|
9
|
+
this.properties = [
|
|
10
|
+
{
|
|
11
|
+
displayName: 'Base URL',
|
|
12
|
+
name: 'baseUrl',
|
|
13
|
+
type: 'string',
|
|
14
|
+
default: 'https://app.chatwoot.com',
|
|
15
|
+
placeholder: 'https://app.chatwoot.com',
|
|
16
|
+
description: 'The base URL of your Chatwoot instance. Use https://app.chatwoot.com for Chatwoot Cloud, or your self-hosted instance URL (e.g., https://chatwoot.yourdomain.com)',
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
displayName: 'Account ID',
|
|
21
|
+
name: 'accountId',
|
|
22
|
+
type: 'number',
|
|
23
|
+
default: 1,
|
|
24
|
+
description: 'Your Chatwoot Account ID. You can find this in Chatwoot under Settings → Account Settings, or in the URL when logged in (e.g., /app/accounts/1/...)',
|
|
25
|
+
required: true,
|
|
26
|
+
typeOptions: {
|
|
27
|
+
minValue: 1,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
displayName: 'API Access Token',
|
|
32
|
+
name: 'apiAccessToken',
|
|
33
|
+
type: 'string',
|
|
34
|
+
typeOptions: {
|
|
35
|
+
password: true,
|
|
36
|
+
},
|
|
37
|
+
default: '',
|
|
38
|
+
description: 'Your API Access Token from Chatwoot. Go to Profile Settings → Access Token to generate or copy your token',
|
|
39
|
+
required: true,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
this.authenticate = {
|
|
43
|
+
type: 'generic',
|
|
44
|
+
properties: {
|
|
45
|
+
headers: {
|
|
46
|
+
api_access_token: '={{$credentials.apiAccessToken}}',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
this.test = {
|
|
51
|
+
request: {
|
|
52
|
+
baseURL: '={{$credentials.baseUrl.replace(/\\/$/, "")}}',
|
|
53
|
+
url: '=/api/v1/accounts/{{$credentials.accountId}}/conversations',
|
|
54
|
+
method: 'GET',
|
|
55
|
+
qs: {
|
|
56
|
+
page: 1,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.ChatwootApi = ChatwootApi;
|
|
63
|
+
//# sourceMappingURL=ChatwootApi.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatwootApi.credentials.js","sourceRoot":"","sources":["../../credentials/ChatwootApi.credentials.ts"],"names":[],"mappings":";;;AAOA,MAAa,WAAW;IAAxB;QACE,SAAI,GAAG,aAAa,CAAC;QACrB,gBAAW,GAAG,cAAc,CAAC;QAC7B,qBAAgB,GAAG,0CAA0C,CAAC;QAC9D,eAAU,GAAsB;YAC9B;gBACE,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,0BAA0B;gBACnC,WAAW,EAAE,0BAA0B;gBACvC,WAAW,EACT,mKAAmK;gBACrK,QAAQ,EAAE,IAAI;aACf;YACD;gBACE,WAAW,EAAE,YAAY;gBACzB,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,CAAC;gBACV,WAAW,EACT,qJAAqJ;gBACvJ,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE;oBACX,QAAQ,EAAE,CAAC;iBACZ;aACF;YACD;gBACE,WAAW,EAAE,kBAAkB;gBAC/B,IAAI,EAAE,gBAAgB;gBACtB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE;oBACX,QAAQ,EAAE,IAAI;iBACf;gBACD,OAAO,EAAE,EAAE;gBACX,WAAW,EACT,2GAA2G;gBAC7G,QAAQ,EAAE,IAAI;aACf;SACF,CAAC;QAEF,iBAAY,GAAyB;YACnC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,gBAAgB,EAAE,kCAAkC;iBACrD;aACF;SACF,CAAC;QAEF,SAAI,GAA2B;YAC7B,OAAO,EAAE;gBACP,OAAO,EAAE,+CAA+C;gBACxD,GAAG,EAAE,4DAA4D;gBACjE,MAAM,EAAE,KAAK;gBACb,EAAE,EAAE;oBACF,IAAI,EAAE,CAAC;iBACR;aACF;SACF,CAAC;IACJ,CAAC;CAAA;AA5DD,kCA4DC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class Chatwoot implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Chatwoot = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const GenericFunctions_1 = require("./GenericFunctions");
|
|
6
|
+
const conversation_1 = require("./resources/conversation");
|
|
7
|
+
const message_1 = require("./resources/message");
|
|
8
|
+
const contact_1 = require("./resources/contact");
|
|
9
|
+
class Chatwoot {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.description = {
|
|
12
|
+
displayName: 'Chatwoot',
|
|
13
|
+
name: 'chatwoot',
|
|
14
|
+
icon: 'file:chatwoot.svg',
|
|
15
|
+
group: ['transform'],
|
|
16
|
+
version: 1,
|
|
17
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
18
|
+
description: 'Interact with Chatwoot API to manage conversations, messages, and contacts',
|
|
19
|
+
defaults: {
|
|
20
|
+
name: 'Chatwoot',
|
|
21
|
+
},
|
|
22
|
+
inputs: ['main'],
|
|
23
|
+
outputs: ['main'],
|
|
24
|
+
credentials: [
|
|
25
|
+
{
|
|
26
|
+
name: 'chatwootApi',
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
properties: [
|
|
31
|
+
{
|
|
32
|
+
displayName: 'Resource',
|
|
33
|
+
name: 'resource',
|
|
34
|
+
type: 'options',
|
|
35
|
+
noDataExpression: true,
|
|
36
|
+
options: [
|
|
37
|
+
{
|
|
38
|
+
name: 'Contact',
|
|
39
|
+
value: 'contact',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'Conversation',
|
|
43
|
+
value: 'conversation',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'Message',
|
|
47
|
+
value: 'message',
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
default: 'conversation',
|
|
51
|
+
},
|
|
52
|
+
conversation_1.conversationOperations,
|
|
53
|
+
message_1.messageOperations,
|
|
54
|
+
contact_1.contactOperations,
|
|
55
|
+
...conversation_1.conversationFields,
|
|
56
|
+
...message_1.messageFields,
|
|
57
|
+
...contact_1.contactFields,
|
|
58
|
+
],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
async execute() {
|
|
62
|
+
const items = this.getInputData();
|
|
63
|
+
const returnData = [];
|
|
64
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
65
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
66
|
+
for (let i = 0; i < items.length; i++) {
|
|
67
|
+
try {
|
|
68
|
+
let responseData;
|
|
69
|
+
if (resource === 'conversation') {
|
|
70
|
+
if (operation === 'get') {
|
|
71
|
+
const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
|
|
72
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/conversations/${conversationId}`);
|
|
73
|
+
}
|
|
74
|
+
else if (operation === 'getAll') {
|
|
75
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
76
|
+
const filters = this.getNodeParameter('filters', i);
|
|
77
|
+
const qs = {};
|
|
78
|
+
if (filters.status && filters.status !== 'all') {
|
|
79
|
+
qs.status = filters.status;
|
|
80
|
+
}
|
|
81
|
+
if (filters.assignee_type && filters.assignee_type !== 'all') {
|
|
82
|
+
qs.assignee_type = filters.assignee_type;
|
|
83
|
+
}
|
|
84
|
+
if (filters.inbox_id) {
|
|
85
|
+
qs.inbox_id = filters.inbox_id;
|
|
86
|
+
}
|
|
87
|
+
if (filters.team_id) {
|
|
88
|
+
qs.team_id = filters.team_id;
|
|
89
|
+
}
|
|
90
|
+
if (filters.labels) {
|
|
91
|
+
qs.labels = filters.labels.split(',').map((l) => l.trim());
|
|
92
|
+
}
|
|
93
|
+
if (filters.q) {
|
|
94
|
+
qs.q = filters.q;
|
|
95
|
+
}
|
|
96
|
+
if (returnAll) {
|
|
97
|
+
responseData = await GenericFunctions_1.chatwootApiRequestAllItems.call(this, 'GET', '/conversations', {}, qs, 'payload');
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
const limit = this.getNodeParameter('limit', i);
|
|
101
|
+
qs.page = 1;
|
|
102
|
+
const result = (await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/conversations', {}, qs));
|
|
103
|
+
const payload = (result.payload || []);
|
|
104
|
+
responseData = payload.slice(0, limit);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else if (operation === 'updateStatus') {
|
|
108
|
+
const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
|
|
109
|
+
const status = this.getNodeParameter('status', i);
|
|
110
|
+
const body = { status };
|
|
111
|
+
if (status === 'snoozed') {
|
|
112
|
+
const snoozedUntil = this.getNodeParameter('snoozed_until', i, '');
|
|
113
|
+
if (snoozedUntil) {
|
|
114
|
+
body.snoozed_until = Math.floor(new Date(snoozedUntil).getTime() / 1000);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/conversations/${conversationId}/toggle_status`, body);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" is not supported for resource "conversation"`, { itemIndex: i });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else if (resource === 'message') {
|
|
124
|
+
if (operation === 'create') {
|
|
125
|
+
const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
|
|
126
|
+
const content = this.getNodeParameter('content', i);
|
|
127
|
+
const options = this.getNodeParameter('options', i);
|
|
128
|
+
const body = { content };
|
|
129
|
+
if (options.message_type) {
|
|
130
|
+
body.message_type = options.message_type;
|
|
131
|
+
}
|
|
132
|
+
if (options.private !== undefined) {
|
|
133
|
+
body.private = options.private;
|
|
134
|
+
}
|
|
135
|
+
if (options.content_type) {
|
|
136
|
+
body.content_type = options.content_type;
|
|
137
|
+
}
|
|
138
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/conversations/${conversationId}/messages`, body);
|
|
139
|
+
}
|
|
140
|
+
else if (operation === 'getAll') {
|
|
141
|
+
const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
|
|
142
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
143
|
+
if (returnAll) {
|
|
144
|
+
responseData = await GenericFunctions_1.chatwootApiRequestAllMessages.call(this, conversationId);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
const limit = this.getNodeParameter('limit', i);
|
|
148
|
+
responseData = await GenericFunctions_1.chatwootApiRequestAllMessages.call(this, conversationId, limit);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" is not supported for resource "message"`, { itemIndex: i });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
else if (resource === 'contact') {
|
|
156
|
+
if (operation === 'create') {
|
|
157
|
+
const inboxId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('inboxId', i), 'Inbox ID');
|
|
158
|
+
const name = this.getNodeParameter('name', i);
|
|
159
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
160
|
+
const body = {
|
|
161
|
+
inbox_id: inboxId,
|
|
162
|
+
};
|
|
163
|
+
if (name) {
|
|
164
|
+
body.name = name;
|
|
165
|
+
}
|
|
166
|
+
if (additionalFields.email) {
|
|
167
|
+
body.email = additionalFields.email;
|
|
168
|
+
}
|
|
169
|
+
if (additionalFields.phone_number) {
|
|
170
|
+
body.phone_number = additionalFields.phone_number;
|
|
171
|
+
}
|
|
172
|
+
if (additionalFields.identifier) {
|
|
173
|
+
body.identifier = additionalFields.identifier;
|
|
174
|
+
}
|
|
175
|
+
if (additionalFields.custom_attributes) {
|
|
176
|
+
body.custom_attributes =
|
|
177
|
+
typeof additionalFields.custom_attributes === 'string'
|
|
178
|
+
? JSON.parse(additionalFields.custom_attributes)
|
|
179
|
+
: additionalFields.custom_attributes;
|
|
180
|
+
}
|
|
181
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/contacts', body);
|
|
182
|
+
}
|
|
183
|
+
else if (operation === 'get') {
|
|
184
|
+
const contactId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('contactId', i), 'Contact ID');
|
|
185
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/contacts/${contactId}`);
|
|
186
|
+
}
|
|
187
|
+
else if (operation === 'getAll') {
|
|
188
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
189
|
+
const options = this.getNodeParameter('options', i);
|
|
190
|
+
const qs = {};
|
|
191
|
+
if (options.sort) {
|
|
192
|
+
qs.sort = options.sort;
|
|
193
|
+
}
|
|
194
|
+
if (returnAll) {
|
|
195
|
+
responseData = await GenericFunctions_1.chatwootApiRequestAllItems.call(this, 'GET', '/contacts', {}, qs, 'payload');
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
const limit = this.getNodeParameter('limit', i);
|
|
199
|
+
qs.page = 1;
|
|
200
|
+
const result = (await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/contacts', {}, qs));
|
|
201
|
+
const payload = (result.payload || []);
|
|
202
|
+
responseData = payload.slice(0, limit);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else if (operation === 'update') {
|
|
206
|
+
const contactId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('contactId', i), 'Contact ID');
|
|
207
|
+
const updateFields = this.getNodeParameter('updateFields', i);
|
|
208
|
+
const body = {};
|
|
209
|
+
if (updateFields.name) {
|
|
210
|
+
body.name = updateFields.name;
|
|
211
|
+
}
|
|
212
|
+
if (updateFields.email) {
|
|
213
|
+
body.email = updateFields.email;
|
|
214
|
+
}
|
|
215
|
+
if (updateFields.phone_number) {
|
|
216
|
+
body.phone_number = updateFields.phone_number;
|
|
217
|
+
}
|
|
218
|
+
if (updateFields.identifier) {
|
|
219
|
+
body.identifier = updateFields.identifier;
|
|
220
|
+
}
|
|
221
|
+
if (updateFields.avatar_url) {
|
|
222
|
+
body.avatar_url = updateFields.avatar_url;
|
|
223
|
+
}
|
|
224
|
+
if (updateFields.blocked !== undefined) {
|
|
225
|
+
body.blocked = updateFields.blocked;
|
|
226
|
+
}
|
|
227
|
+
if (updateFields.custom_attributes) {
|
|
228
|
+
body.custom_attributes =
|
|
229
|
+
typeof updateFields.custom_attributes === 'string'
|
|
230
|
+
? JSON.parse(updateFields.custom_attributes)
|
|
231
|
+
: updateFields.custom_attributes;
|
|
232
|
+
}
|
|
233
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'PUT', `/contacts/${contactId}`, body);
|
|
234
|
+
}
|
|
235
|
+
else if (operation === 'delete') {
|
|
236
|
+
const contactId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('contactId', i), 'Contact ID');
|
|
237
|
+
await GenericFunctions_1.chatwootApiRequest.call(this, 'DELETE', `/contacts/${contactId}`);
|
|
238
|
+
responseData = { success: true, id: contactId };
|
|
239
|
+
}
|
|
240
|
+
else if (operation === 'search') {
|
|
241
|
+
const query = this.getNodeParameter('query', i);
|
|
242
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
243
|
+
const options = this.getNodeParameter('options', i);
|
|
244
|
+
const qs = { q: query };
|
|
245
|
+
if (options.sort) {
|
|
246
|
+
qs.sort = options.sort;
|
|
247
|
+
}
|
|
248
|
+
if (returnAll) {
|
|
249
|
+
responseData = await GenericFunctions_1.chatwootApiRequestAllItems.call(this, 'GET', '/contacts/search', {}, qs, 'payload');
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
const limit = this.getNodeParameter('limit', i);
|
|
253
|
+
qs.page = 1;
|
|
254
|
+
const result = (await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/contacts/search', {}, qs));
|
|
255
|
+
const payload = (result.payload || []);
|
|
256
|
+
responseData = payload.slice(0, limit);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" is not supported for resource "contact"`, { itemIndex: i });
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Resource "${resource}" is not supported`, {
|
|
265
|
+
itemIndex: i,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
|
|
269
|
+
returnData.push(...executionData);
|
|
270
|
+
}
|
|
271
|
+
catch (error) {
|
|
272
|
+
if (this.continueOnFail()) {
|
|
273
|
+
const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
|
|
274
|
+
returnData.push(...executionData);
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
throw error;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return [returnData];
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
exports.Chatwoot = Chatwoot;
|
|
284
|
+
//# sourceMappingURL=Chatwoot.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Chatwoot.node.js","sourceRoot":"","sources":["../../../nodes/Chatwoot/Chatwoot.node.ts"],"names":[],"mappings":";;;AAOA,+CAAkD;AAElD,yDAK4B;AAE5B,2DAAsF;AACtF,iDAAuE;AACvE,iDAAuE;AAEvE,MAAa,QAAQ;IAArB;QACE,gBAAW,GAAyB;YAClC,WAAW,EAAE,UAAU;YACvB,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,mBAAmB;YACzB,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,8DAA8D;YACxE,WAAW,EAAE,4EAA4E;YACzF,QAAQ,EAAE;gBACR,IAAI,EAAE,UAAU;aACjB;YACD,MAAM,EAAE,CAAC,MAAM,CAAC;YAChB,OAAO,EAAE,CAAC,MAAM,CAAC;YACjB,WAAW,EAAE;gBACX;oBACE,IAAI,EAAE,aAAa;oBACnB,QAAQ,EAAE,IAAI;iBACf;aACF;YACD,UAAU,EAAE;gBACV;oBACE,WAAW,EAAE,UAAU;oBACvB,IAAI,EAAE,UAAU;oBAChB,IAAI,EAAE,SAAS;oBACf,gBAAgB,EAAE,IAAI;oBACtB,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,SAAS;4BACf,KAAK,EAAE,SAAS;yBACjB;wBACD;4BACE,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AC,OAAO,CAAC,eAAe,CAAC,YAA2C,CAAC,EACzE,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAC1B,CAAC;gBAEF,UAAU,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;YACpC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;oBAC1B,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,0BAA0B,CAC3D,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE,CAAC,EACjE,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAC1B,CAAC;oBACF,UAAU,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;oBAClC,SAAS;gBACX,CAAC;gBACD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACtB,CAAC;CACF;AAxbD,4BAwbC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IDataObject, IExecuteFunctions, IHookFunctions, IHttpRequestMethods, ILoadOptionsFunctions } from 'n8n-workflow';
|
|
2
|
+
export declare function chatwootApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, method: IHttpRequestMethods, endpoint: string, body?: IDataObject, qs?: IDataObject): Promise<IDataObject | IDataObject[]>;
|
|
3
|
+
export declare function chatwootApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, method: IHttpRequestMethods, endpoint: string, body?: IDataObject, qs?: IDataObject, propertyName?: string): Promise<IDataObject[]>;
|
|
4
|
+
export declare function chatwootApiRequestAllMessages(this: IExecuteFunctions, conversationId: number, limit?: number): Promise<IDataObject[]>;
|
|
5
|
+
export declare function simplifyResponse(items: IDataObject[], fieldsToKeep: string[]): IDataObject[];
|
|
6
|
+
export declare function validateId(value: unknown, fieldName: string): number;
|