Skip to content

Commit 038cd6f

Browse files
Merge pull request #293 from gabrielpastori1/chatwoot-format
Chatwoot format
2 parents 38978dd + fb24b7e commit 038cd6f

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

CHANGELOG.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* Added the sign_delimiter property to the Chatwoot configuration, allowing you to set a different delimiter for the signature. Default when not defined \n
1212
* Include instance Id field in the instance configuration
1313

14+
1415
# 1.6.0 (2023-12-12 17:24)
1516

1617
### Feature
@@ -43,8 +44,8 @@
4344

4445
### Integrations
4546

46-
- Chatwoot: v3.3.1
47-
- Typebot: v2.20.0
47+
* Chatwoot: v3.3.1
48+
* Typebot: v2.20.0
4849

4950
# 1.5.4 (2023-10-09 20:43)
5051

@@ -123,9 +124,9 @@
123124

124125
### Integrations
125126

126-
- Chatwoot: v2.18.0 - v3.0.0
127-
- Typebot: v2.16.0
128-
- Manager Evolution API
127+
* Chatwoot: v2.18.0 - v3.0.0
128+
* Typebot: v2.16.0
129+
* Manager Evolution API
129130

130131
# 1.4.8 (2023-07-27 10:27)
131132

@@ -178,7 +179,7 @@
178179

179180
### Fixed
180181

181-
* Fixed validation is set settings
182+
* Fixed validation is set settings
182183
* Adjusts in group validations
183184
* Ajusts in sticker message to chatwoot
184185

@@ -213,7 +214,7 @@
213214

214215
### Integrations
215216

216-
- Chatwoot: v2.18.0 - v3.0.0 (Beta)
217+
* Chatwoot: v2.18.0 - v3.0.0 (Beta)
217218

218219
# 1.3.2 (2023-07-21 17:19)
219220

@@ -229,7 +230,7 @@
229230

230231
### Integrations
231232

232-
- Chatwoot: v2.18.0
233+
* Chatwoot: v2.18.0
233234

234235
# 1.3.1 (2023-07-20 07:48)
235236

@@ -239,7 +240,7 @@
239240

240241
### Integrations
241242

242-
- Chatwoot: v2.18.0
243+
* Chatwoot: v2.18.0
243244

244245
# 1.3.0 (2023-07-19 11:33)
245246

@@ -255,7 +256,7 @@
255256
* Translation set to default (english) in chatwoot
256257

257258
### Fixed
258-
259+
259260
* Fixed error to send message in large groups
260261
* Docker files adjusted
261262
* Fixed in the postman collection the webhookByEvent parameter by webhook_by_events
@@ -276,7 +277,7 @@
276277

277278
### Integrations
278279

279-
- Chatwoot: v2.18.0
280+
* Chatwoot: v2.18.0
280281

281282
# 1.2.2 (2023-07-15 09:36)
282283

@@ -287,7 +288,7 @@
287288

288289
### Integrations
289290

290-
- Chatwoot: v2.18.0
291+
* Chatwoot: v2.18.0
291292

292293
# 1.2.1 (2023-07-14 19:04)
293294

@@ -443,4 +444,4 @@
443444
* Sending the local webhook url as destination in the webhook data for webhook redirection
444445
* Startup modes, server or container
445446
* Server Mode works normally as everyone is used to
446-
* Container mode made to use one instance per container, when starting the application an instance is already created and the qrcode is generated and it starts sending webhook without having to call it manually, it only allows one instance at a time.
447+
* Container mode made to use one instance per container, when starting the application an instance is already created and the qrcode is generated and it starts sending webhook without having to call it manually, it only allows one instance at a time.

src/whatsapp/services/chatwoot.service.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,10 +1019,12 @@ export class ChatwootService {
10191019
this.logger.verbose('check if is group');
10201020
const chatId =
10211021
body.conversation.meta.sender?.phone_number?.replace('+', '') || body.conversation.meta.sender?.identifier;
1022+
// Chatwoot to Whatsapp
10221023
const messageReceived = body.content
1023-
.replaceAll(/\*((?!\s)([^\n*]+?)(?<!\s))\*/g, '_$1_') // Substitui * por _
1024+
.replaceAll(/(?<!\*)\*((?!\s)([^\n*]+?)(?<!\s))\*(?!\*)/g, '_$1_') // Substitui * por _
10241025
.replaceAll(/\*{2}((?!\s)([^\n*]+?)(?<!\s))\*{2}/g, '*$1*') // Substitui ** por *
1025-
.replace(/~{2}((?!\s)([^\n*]+?)(?<!\s))~{2}/g, '~$1~'); // Substitui ~~ por ~
1026+
.replaceAll(/~{2}((?!\s)([^\n*]+?)(?<!\s))~{2}/g, '~$1~') // Substitui ~~ por ~
1027+
.replaceAll(/(?<!`)`((?!\s)([^`*]+?)(?<!\s))`(?!`)/g, '```$1```'); // Substitui ` por ```
10261028

10271029
const senderName = body?.sender?.name;
10281030
const waInstance = this.waMonitor.waInstances[instance.instanceName];
@@ -1481,6 +1483,7 @@ export class ChatwootService {
14811483

14821484
this.logger.verbose('get conversation message');
14831485

1486+
// Whatsapp to Chatwoot
14841487
const bodyMessage = await this.getConversationMessage(body.message)
14851488
.replaceAll(/\*((?!\s)([^\n*]+?)(?<!\s))\*/g, '**$1**')
14861489
.replaceAll(/_((?!\s)([^\n_]+?)(?<!\s))_/g, '*$1*')

0 commit comments

Comments
 (0)