Skip to content

Commit 1db23b5

Browse files
committed
fix: Adjusts to receive contact with no whatsapp
1 parent 584f0cb commit 1db23b5

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/whatsapp/services/chatwoot.service.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ export class ChatwootService {
247247
accountId: this.provider.account_id,
248248
conversationId: conversation.id,
249249
data: {
250-
content: '/iniciar',
250+
content: '/init',
251251
message_type: 'outgoing',
252252
},
253253
});
@@ -936,8 +936,8 @@ export class ChatwootService {
936936

937937
const command = messageReceived.replace('/', '');
938938

939-
if (command === 'iniciar') {
940-
this.logger.verbose('command iniciar found');
939+
if (command === 'init') {
940+
this.logger.verbose('command init found');
941941
const state = waInstance?.connectionStatus?.state;
942942

943943
if (state !== 'open') {
@@ -947,7 +947,7 @@ export class ChatwootService {
947947
this.logger.verbose('whatsapp already connected');
948948
await this.createBotMessage(
949949
instance,
950-
`🚨 Instância ${body.inbox.name} já está conectada.`,
950+
`🚨 ${body.inbox.name} instance is connected.`,
951951
'incoming',
952952
);
953953
}
@@ -962,7 +962,7 @@ export class ChatwootService {
962962
this.logger.verbose('state not found');
963963
await this.createBotMessage(
964964
instance,
965-
`⚠️ Instância ${body.inbox.name} não existe.`,
965+
`⚠️ ${body.inbox.name} instance not found.`,
966966
'incoming',
967967
);
968968
}
@@ -971,16 +971,16 @@ export class ChatwootService {
971971
this.logger.verbose('state: ' + state + ' found');
972972
await this.createBotMessage(
973973
instance,
974-
`⚠️ Status da instância ${body.inbox.name}: *${state}*`,
974+
`⚠️ ${body.inbox.name} instance status: *${state}*`,
975975
'incoming',
976976
);
977977
}
978978
}
979979

980-
if (command === 'desconectar') {
981-
this.logger.verbose('command desconectar found');
980+
if (command === 'disconnect') {
981+
this.logger.verbose('command disconnect found');
982982

983-
const msgLogout = `🚨 Desconectando Whatsapp da caixa de entrada *${body.inbox.name}*: `;
983+
const msgLogout = `🚨 Disconnecting Whatsapp from inbox *${body.inbox.name}*: `;
984984

985985
this.logger.verbose('send message to chatwoot');
986986
await this.createBotMessage(instance, msgLogout, 'incoming');
@@ -1189,7 +1189,7 @@ export class ChatwootService {
11891189

11901190
let numberCount = 1;
11911191
Object.keys(contactInfo).forEach((key) => {
1192-
if (key.startsWith('item') && key.includes('TEL;waid=')) {
1192+
if (key.startsWith('item') && key.includes('TEL')) {
11931193
const phoneNumber = contactInfo[key];
11941194
formattedContact += `\n**number ${numberCount}:** ${phoneNumber}`;
11951195
numberCount++;
@@ -1217,7 +1217,7 @@ export class ChatwootService {
12171217

12181218
let numberCount = 1;
12191219
Object.keys(contactInfo).forEach((key) => {
1220-
if (key.startsWith('item') && key.includes('TEL;waid=')) {
1220+
if (key.startsWith('item') && key.includes('TEL')) {
12211221
const phoneNumber = contactInfo[key];
12221222
formattedContact += `\n**number ${numberCount}:** ${phoneNumber}`;
12231223
numberCount++;
@@ -1488,7 +1488,7 @@ export class ChatwootService {
14881488
return;
14891489
}
14901490

1491-
const msgStatus = `⚡️ Status da instância ${inbox.name}: ${data.status}`;
1491+
const msgStatus = `⚡️ Instance status ${inbox.name}: ${data.status}`;
14921492

14931493
this.logger.verbose('send message to chatwoot');
14941494
await this.createBotMessage(instance, msgStatus, 'incoming');
@@ -1498,7 +1498,7 @@ export class ChatwootService {
14981498
this.logger.verbose('event connection.update');
14991499

15001500
if (body.status === 'open') {
1501-
const msgConnection = `🚀 Conexão estabelecida com sucesso!`;
1501+
const msgConnection = `🚀 Connection successfully established!`;
15021502

15031503
this.logger.verbose('send message to chatwoot');
15041504
await this.createBotMessage(instance, msgConnection, 'incoming');
@@ -1533,7 +1533,7 @@ export class ChatwootService {
15331533
this.logger.verbose('event qrcode.updated');
15341534
if (body.statusCode === 500) {
15351535
this.logger.verbose('qrcode error');
1536-
const erroQRcode = `🚨 Limite de geração de QRCode atingido, para gerar um novo QRCode, envie a mensagem /iniciar novamente.`;
1536+
const erroQRcode = `🚨 QRCode generation limit reached, to generate a new QRCode, send the /init message again.`;
15371537

15381538
this.logger.verbose('send message to chatwoot');
15391539
return await this.createBotMessage(instance, erroQRcode, 'incoming');
@@ -1563,7 +1563,7 @@ export class ChatwootService {
15631563
fileName,
15641564
);
15651565

1566-
const msgQrCode = `⚡️ QRCode gerado com sucesso!\n\nDigitalize este código QR nos próximos 40 segundos:`;
1566+
const msgQrCode = `⚡️ QRCode successfully generated!\n\nScan this QR code within the next 40 seconds:`;
15671567

15681568
this.logger.verbose('send message to chatwoot');
15691569
await this.createBotMessage(instance, msgQrCode, 'incoming');

0 commit comments

Comments
 (0)