Skip to content

Commit 3a37fd9

Browse files
committed
fix: typebot's wait now pauses the flow and composing is defined by the delay_message parameter in set typebot
1 parent b095c9d commit 3a37fd9

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* Read messages from whatsapp in chatwoot
99
* Add support to use use redis in cacheservice
1010
* Add support for labels
11+
* Command to clearcache from chatwoot inbox
1112

1213
### Fixed
1314

@@ -32,6 +33,11 @@
3233
* Fix looping when deleting a message in chatwoot
3334
* When receiving a file from whatsapp, use the original filename in chatwoot if possible
3435
* Correction in the sendList Function
36+
* Implement contact upsert in messaging-history.set
37+
* Improve proxy error handling
38+
* Refactor fetching participants for group in WhatsApp service
39+
* Fixed problem where the typebot final keyword did not work
40+
* Typebot's wait now pauses the flow and composing is defined by the delay_message parameter in set typebot
3541

3642
# 1.6.1 (2023-12-22 11:43)
3743

src/whatsapp/services/typebot.service.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,6 @@ export class TypebotService {
450450

451451
async function processMessages(instance, messages, input, clientSideActions, eventEmitter, applyFormatting) {
452452
for (const message of messages) {
453-
const wait = findItemAndGetSecondsToWait(clientSideActions, message.id);
454-
455453
if (message.type === 'text') {
456454
let formattedText = '';
457455

@@ -467,7 +465,7 @@ export class TypebotService {
467465
await instance.textMessage({
468466
number: remoteJid.split('@')[0],
469467
options: {
470-
delay: wait ? wait * 1000 : instance.localTypebot.delay_message || 1000,
468+
delay: instance.localTypebot.delay_message || 1000,
471469
presence: 'composing',
472470
},
473471
textMessage: {
@@ -480,7 +478,7 @@ export class TypebotService {
480478
await instance.mediaMessage({
481479
number: remoteJid.split('@')[0],
482480
options: {
483-
delay: wait ? wait * 1000 : instance.localTypebot.delay_message || 1000,
481+
delay: instance.localTypebot.delay_message || 1000,
484482
presence: 'composing',
485483
},
486484
mediaMessage: {
@@ -494,7 +492,7 @@ export class TypebotService {
494492
await instance.mediaMessage({
495493
number: remoteJid.split('@')[0],
496494
options: {
497-
delay: wait ? wait * 1000 : instance.localTypebot.delay_message || 1000,
495+
delay: instance.localTypebot.delay_message || 1000,
498496
presence: 'composing',
499497
},
500498
mediaMessage: {
@@ -508,7 +506,7 @@ export class TypebotService {
508506
await instance.audioWhatsapp({
509507
number: remoteJid.split('@')[0],
510508
options: {
511-
delay: wait ? wait * 1000 : instance.localTypebot.delay_message || 1000,
509+
delay: instance.localTypebot.delay_message || 1000,
512510
presence: 'recording',
513511
encoding: true,
514512
},
@@ -517,6 +515,13 @@ export class TypebotService {
517515
},
518516
});
519517
}
518+
519+
const wait = findItemAndGetSecondsToWait(clientSideActions, message.id);
520+
521+
console.log('wait', wait);
522+
if (wait) {
523+
await new Promise((resolve) => setTimeout(resolve, wait * 1000));
524+
}
520525
}
521526

522527
if (input) {
@@ -534,7 +539,7 @@ export class TypebotService {
534539
await instance.textMessage({
535540
number: remoteJid.split('@')[0],
536541
options: {
537-
delay: 1200,
542+
delay: instance.localTypebot.delay_message || 1000,
538543
presence: 'composing',
539544
},
540545
textMessage: {

0 commit comments

Comments
 (0)